You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CameraView/docs/_posts/2019-07-14-watermarks-and-o...

74 lines
2.5 KiB

Feature/overlays (#502) * Overlays (#421) * get overlay working * fix overlay drawing * allow disabling overlay in pictures or videos * Fix picture snapshot colors when there is an overlay * Bug fixes * Update example with watermark * Fix bug * Fix overlay orientation in pictures * Fix overlay orientation in videos * Fix overlay when changing preview size * Fix bug * Experiment * Refactor EglViewport * Refactor SnapshotPictureRecorder * Use single EglViewport * Refactor SnapshotVideoRecorder * Bug fix * fix some of the requested changes * clean adding View to OverlayLayout * Specify where to draw the overlay * Refactor * Remove unnecessary variable from CameraPreview * Use mWithOverlay in SnapshotVideoRecorder * Use multiple OverlayLayout * Add explanation for OverlayLayoutManager * override removeView * Remove DisableOverlayFor * Reorder to overlay package * Address issues * Draw selectively on preview, picture or video * Use single Overlay with three targets * Fix picture snapshots * Add demo app control * Fix video snapshot rotation for Camera2 * Fix video snapshot overlay rotation for Camera2 only * Fix tests, improve performance * Add animating watermark * Add tests in CameraViewTest * Add integration tests * Fix race condition * Improve README * Remove isOverlay * Remove isOverlay from docs * Add documentation empty page * Add documentation links * Add real documentation * Remove isOverlay from attrs * Add doc links to main README * Fix tests and logs * Small changes in AudioMediaEncoder * Add changelog line
5 years ago
---
layout: page
title: "Watermarks and Overlays"
subtitle: "Static and animated overlays"
description: "Static and animated overlays"
category: docs
Metering APIs (#580) * Add cameraPictureMetering and cameraPictureSnapshotMetering * Adapt Meter and metering package to picture use * Simplify Full2PictureRecorder, we'll use metering package instead * Add doMetering parameter * Implement cameraPictureMetering and cameraPictureSnapshotMetering in engine * Add options in demo app * Add better logs * Add Snapshot2PictureRecorder * Capture the correct frame based on timestamp * Lock AE and AWB. Account for captureBuilder changes * Fix runtime flash changes bug * Small changes * Flash support for metered snapshots * Remove AE and AWB locks * Lock AE/AWB/AF inside the snapshot recorder * Small changes * Fix AutoExposure metering * Create Locker and locking.* parameters * Implement Locker in Camera2Engine * Implement reset delay in Camera2Engine instead of Meter * Simplify Snapshot2PictureRecorder * Fix success value * Unlock inside Camera2Engine * Do not lock for normal gestures * Simplify logic * Improve locking/AutoFocus * Fix TORCH bug * Small changes to locking and metering * Remove AF and AWB for testing * Create action package * Create OneShotAction * Create LogAction * Revisit Full2VideoRecorder using actions * Revisit Full2PictureRecorder using actions * Enable missing functionality in Snapshot2PictureRecorder * Move Snapshot2PictureRecorder using actions, rewrite lock package * Add TimeoutAction * Add comments to the action package * Add meter package * Remove old metering package * Fix various bugs * Add action.abort() * Abort old MeterAction when running new ones * Fix various bugs * Add doc empty page * Add documentation * Fix tests
5 years ago
order: 11
Feature/overlays (#502) * Overlays (#421) * get overlay working * fix overlay drawing * allow disabling overlay in pictures or videos * Fix picture snapshot colors when there is an overlay * Bug fixes * Update example with watermark * Fix bug * Fix overlay orientation in pictures * Fix overlay orientation in videos * Fix overlay when changing preview size * Fix bug * Experiment * Refactor EglViewport * Refactor SnapshotPictureRecorder * Use single EglViewport * Refactor SnapshotVideoRecorder * Bug fix * fix some of the requested changes * clean adding View to OverlayLayout * Specify where to draw the overlay * Refactor * Remove unnecessary variable from CameraPreview * Use mWithOverlay in SnapshotVideoRecorder * Use multiple OverlayLayout * Add explanation for OverlayLayoutManager * override removeView * Remove DisableOverlayFor * Reorder to overlay package * Address issues * Draw selectively on preview, picture or video * Use single Overlay with three targets * Fix picture snapshots * Add demo app control * Fix video snapshot rotation for Camera2 * Fix video snapshot overlay rotation for Camera2 only * Fix tests, improve performance * Add animating watermark * Add tests in CameraViewTest * Add integration tests * Fix race condition * Improve README * Remove isOverlay * Remove isOverlay from docs * Add documentation empty page * Add documentation links * Add real documentation * Remove isOverlay from attrs * Add doc links to main README * Fix tests and logs * Small changes in AudioMediaEncoder * Add changelog line
5 years ago
date: 2019-07-14 20:14:31
disqus: 1
---
CameraView offers a simple yet powerful framework for watermarks and overlays of any kind.
These overlays can be shown on the live camera preview, plus they appear on the media results
taken with `takePictureSnapshot()` or `takeVideoSnapshot()`.
### Simple Usage
```xml
<com.otaliastudios.cameraview.CameraView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- Watermark in bottom/end corner -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:src="@drawable/watermark"
app:layout_drawOnPreview="true|false"
app:layout_drawOnPictureSnapshot="true|false"
app:layout_drawOnVideoSnapshot="true|false"/>
<!-- More overlays here... -->
</com.otaliastudios.cameraview.CameraView>
```
As you can see, the overlay system is View-based - each overlay is just a real `View` attached
into the hierarchy. This is a powerful and creative tool. You can, for instance, retrieve the
overlay with `findViewById` and:
- Animate it!
- Change its visibility
- Change its position or appearance
- Do so while video is being recorded
Any changes in the overlay appearance will be recorded in real-time in the picture snapshot
or video snapshot that you are capturing.
As you can see in the example, you can also selectively choose, for each overlay, whether it
will draw on the preview (`layout_drawOnPreview`), on picture snapshots (`layout_drawOnPreview`),
on video snapshots (`layout_drawOnPreview`).
### Advanced Usage
If you need to change these flags at runtime, you should cast the overlay `LayoutParams` as follows:
```java
// Cast to OverlayLayout.LayoutParams
View overlay = findViewById(R.id.watermark);
OverlayLayout.LayoutParams params = (OverlayLayout.LayoutParams) overlay.getLayoutParams();
// Perform changes
params.drawOnPreview = true; // draw on preview
params.drawOnPreview = false; // do not draw on preview
params.drawOnPictureSnapshot = true; // draw on picture snapshots
params.drawOnPictureSnapshot = false; // do not draw on picture snapshots
params.drawOnVideoSnapshot = true; // draw on video snapshots
params.drawOnVideoSnapshot = false; // do not draw on video snapshots
// When done, apply
overlay.setLayoutParams(params);
```