kotlin 捕获时不应用SENSITIVITY和EXPOSURE_TIME设置

zujrkrfu  于 2023-10-23  发布在  Kotlin
关注(0)|答案(1)|浏览(109)

我只是想做个简单的申请。捕获时不应用SENSITIVITY和EXPOSURE_TIME设置。`cameraManager.openCamera(cameraId,object:CameraDevice.StateCallback(){ override fun onOpened(camera:CameraDevice){ cameraDevice = camera captureRequest = camera. THEMPERATURE CaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE)

captureRequest.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF)
    captureRequest.set(CaptureRequest.SENSOR_SENSITIVITY, 2000)
    captureRequest.set(CaptureRequest.SENSOR_EXPOSURE_TIME, 10000000000)

    imageReader = ImageReader.newInstance(
        3000, // Replace with the desired image width
        3000, // Replace with the desired image height
        ImageFormat.JPEG, // Image format, you can change it if needed
        1 // Max images that can be accessed at once
    )

    val captureRequest = captureRequest.build()

    cameraDevice.createCaptureSession(
        listOf(imageReader.surface, imageReader!!.surface),
        object : CameraCaptureSession.StateCallback() {
            override fun onConfigured(session: CameraCaptureSession) {
                try {
                    session.capture(captureRequest, object : CameraCaptureSession.CaptureCallback() {
                        override fun onCaptureCompleted(
                            session: CameraCaptureSession,
                            request: CaptureRequest,
                            result: TotalCaptureResult
                        ) {
                                    
                            session.close()

                        }`

我得到一个错误
Session 0: Exception while stopping repeating: android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): cancelRequest:652: Camera 0: Error clearing streaming request: Function not implemented (-38)
我会很高兴任何信息。

4xrmg8kj

4xrmg8kj1#

您的设备可能不支持您设置的值。例如,您可以通过以下方式获得有效的rage:

val cameraManager = getSystemService(Context.CAMERA_SERVICE) as CameraManager
val cameraIdList = cameraManager.cameraIdList
val characteristics = cameraManager.getCameraCharacteristics(cameraIdList[0])
val exposureTimeRange = characteristics.get(CameraCharacteristics.SENSOR_INFO_EXPOSURE_TIME_RANGE)

相关问题