I am building an app in Android studio in Java where I want to access realtime video from camera without saving it and get it as a ByteBuffer. Any help will be appreciated.
It Depends on the API you use (CameraX, Camera2). If you use Camera2 API the general flow would be:
val manager = getSystemService(CAMERA_SERVICE) as CameraManager
manager.openCamera(cameraId, cameraStateCallback, cameraHandler)
private val cameraStateCallback: CameraDevice.StateCallback = object : CameraDevice.StateCallback() {
override fun onOpened(cameraDevice: CameraDevice) {
//Start a capture session
}
override fun onDisconnected(cameraDevice: CameraDevice) {
cameraOpenCloseLock.release()
cameraDevice.close()
}
override fun onError(cameraDevice: CameraDevice, error: Int) {
cameraOpenCloseLock.release()
cameraDevice.close()
}
}
You can check this project for a small basic working example of the entire flow.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.