Skip to content

Commit

Permalink
Overlay a bitmap on top of Preview/VideoCapture stream
Browse files Browse the repository at this point in the history
  • Loading branch information
xizhgoogle committed Jun 26, 2023
1 parent 60914ce commit 4834b9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Expand Up @@ -17,7 +17,7 @@ class SimpleVideoFrameProcessorListener : VideoFrameProcessor.Listener {
}

override fun onError(exception: VideoFrameProcessingException) {
Log.d(TAG, "On error")
Log.d(TAG, "On error", exception)
}

override fun onEnded() {
Expand Down
Expand Up @@ -302,11 +302,14 @@ class CaptureFragment : Fragment() {

private fun createCameraEffect(): CameraFiltersAdapter? {
// Add Media3/ImageX Effects
val matrix = FloatArray(16)
android.opengl.Matrix.setIdentityM(matrix, 0)
android.opengl.Matrix.translateM(matrix, 0, -0.7f, 0.7f, 0f)
val overlay = BitmapOverlay.createStaticBitmapOverlay(
BitmapFactory.decodeResource(
resources,
R.drawable.ic_launcher
), OverlaySettings.Builder().build()
), OverlaySettings.Builder().setMatrix(matrix).build()
) as TextureOverlay
val allEffects = listOf(OverlayEffect(ImmutableList.of(overlay)))
try {
Expand Down Expand Up @@ -611,7 +614,9 @@ class CaptureFragment : Fragment() {
override fun onDestroyView() {
super.onDestroyView()
_captureViewBinding = null
cameraEffect.release()
if (this::cameraEffect.isInitialized) {
cameraEffect.release()
}
super.onDestroyView()
}

Expand Down

0 comments on commit 4834b9a

Please sign in to comment.