I use the following android code CameraManager
service:
CameraManager cameraManager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
String[] cameraIdList = cameraManager.getCameraIdList();
Now, I want to get the image from one of the cameraIds
in this list in order to be able to execute the following code on this image:
ShortBuffer shortDepthBuffer = image.getPlanes()[0].getBuffer().asShortBuffer();
How can I get this Image from a defined cameraId
?
Thanks !
There is no fast and easy way to do this with the Camera2
API. For a particular cameraId
you need to:
cameraManager.openCamera(...)
cameraDevice.createCaptureSession(...)
ImageReader
for output and create capture request:: cameraDevice.createCaptureRequest(...)
captureSession
to process your capture request: captureSession.capture(...)
Image
from ImageReader
that you have configured for capture output. Therefore, for simple camera app I would suggest to look at CameraX
instead.
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.