android / camera-samples

Multiple samples showing the best practices in camera APIs on Android.
Apache License 2.0
5.01k stars 2.35k forks source link

CameraXBasic - increase FPS for image analysis #328

Closed rnrvs closed 3 years ago

rnrvs commented 4 years ago

Hello,

I´ve tried to enhance the CameraXBasic application to analyze images at a faster rate. This is how I tried it:

    val builder = ImageAnalysis.Builder()
    val camera2InterOp = Camera2Interop.Extender(builder)
    camera2InterOp.setCaptureRequestOption(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF)
    camera2InterOp.setCaptureRequestOption(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, Range<Int>(60, 120))
    imageAnalyzer =  builder.build()
    imageAnalyzer!!.setAnalyzer(cameraExecutor, LuminosityAnalyzer { luma ->
                   // Values returned from our analyzer are passed to the attached listener
                   // We log image analysis results here - you should do something useful
                   // instead!
                   Log.d(TAG, "Average luminosity: $luma")
                  })

It is running on AVD (even if I can´t see a FPS increase, but this may be related to the virtual environment) but when I run it on a real device (S7 mobile phone) I just have a black screen. After closing the CameraXBasic app, even the real Android Camera App reports a failure and needs several restarts to work again.

Do you have any idea? Thanks in advance!

owahltinez commented 3 years ago

The issue tracker is being used for problems with the unmodified samples. If you have questions about usage, please use tag android-camerax in StackOverflow or start a thread in the developer forums