Skip to content

Commit

Permalink
fix init
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Aug 1, 2023
1 parent bdb61a0 commit be20f8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions android/src/main/java/com/mrousavy/camera/CameraView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,15 @@ class CameraView(context: Context) : FrameLayout(context) {

imageReader.setOnImageAvailableListener({ reader ->
Log.d(TAG, "New Image available!")
val image = reader.acquireLatestImage()
val image = reader.acquireNextImage()
if (image == null) {
Log.e(TAG, "Failed to get new Image from ImageReader, dropping it...")
}
// TODO: Rotation
// TODO: isMirrored
val frame = Frame(image, System.currentTimeMillis(), Surface.ROTATION_0, false)
frameProcessor?.call(frame)
}, null)
}, CameraQueues.videoQueue.handler)

val frameProcessorOutput = SurfaceOutput(imageReader.surface)
val outputs = listOf(frameProcessorOutput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import kotlin.coroutines.suspendCoroutine

data class SurfaceOutput(val surface: Surface,
val isMirrored: Boolean = false,
val streamUseCase: Long = 0x0 /* DEFAULT */,
val dynamicRangeProfile: Long = 0 /* STANDARD */)
val streamUseCase: Long? = null,
val dynamicRangeProfile: Long? = null)

enum class SessionType {
REGULAR,
Expand Down Expand Up @@ -49,9 +49,9 @@ suspend fun CameraDevice.createCaptureSession(sessionType: SessionType, outputs:
val outputConfigurations = outputs.map {
val result = OutputConfiguration(it.surface)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
result.mirrorMode = if (it.isMirrored) OutputConfiguration.MIRROR_MODE_H else OutputConfiguration.MIRROR_MODE_NONE
result.dynamicRangeProfile = it.dynamicRangeProfile
result.streamUseCase = it.streamUseCase
if (it.isMirrored) result.mirrorMode = OutputConfiguration.MIRROR_MODE_H
if (it.dynamicRangeProfile != null) result.dynamicRangeProfile = it.dynamicRangeProfile
if (it.streamUseCase != null) result.streamUseCase = it.streamUseCase
}
return@map result
}
Expand Down

0 comments on commit be20f8b

Please sign in to comment.