ananthrajsingh / front-rear-simultaneous-camera

Android application to preview both front and rear cameras simultaneously. The application uses Camera2 API to get previews from cameras.

Home Page:https://medium.com/better-programming/simultaneous-front-and-rear-camera-preview-in-android-using-camera2-api-d9f2eb9af6b5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hardware

dirk61 opened this issue · comments

What device did you use? I'm using Huawei mate 30 and only one camera preview works.

I have tried this on Xiaomi Mi 5, Android 8.0.0 API 26

mCaptureRequestBuilderFront = mCameraDeviceFront.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); mCaptureRequestBuilderFront.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF); mCaptureRequestBuilderFront.set(CaptureRequest.CONTROL_AE_LOCK, true);

Try this while creating capture request for front or both cameras. This made the application work on a custom Quectel hardware running Android 9.

Hello,
Thank you for this wonderful code. I am using a Quectel SC600Y and the application crashes when opening the rear camera. Here is the error message: Access denied finding property "vendor.camera.aux.packagelist". I thought it's a permission issue, so I added this in the manifest:
uses-permission android: name = "android.permission.CAMERA"
uses-feature android: name = "android.hardware.camera"
uses-feature android: name = "android.hardware.camera.autofocus"
but nothing to do. Do you have an idea ?
Thanks & Best Regards,

Hey @seann99, you are welcome. Did you try this:

mPreviewBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);

mPreviewBuilder.set(CaptureRequest.CONTROL_AE_LOCK, true);

mPreviewBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_OFF);

If problem persists, mind posting the crashlogs?

Thank you very much for this quick feedback. In your code it is already mentioned:
previewRequestBuilderRear.set (CaptureRequest.CONTROL_AF_MODE,
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE).

and i'chnaged in:

previewRequestBuilderFront.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF)
previewRequestBuilderFront.set(CaptureRequest.CONTROL_AE_LOCK, true)
previewRequestBuilderFront.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_OFF)

here are my logs:

2020-07-22 14:09:14.047 17413-17413/com.ananth.frontrearcamera E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-07-22 14:09:14.055 17413-17413/com.ananth.frontrearcamera D/CameraFragment: selected aspect ratio 120x160 : 0
2020-07-22 14:09:14.052 17413-17413/com.ananth.frontrearcamera W/frontrearcamera: type=1400 audit(0.0:1044): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=14928 scontext=u:r:untrusted_app:s0:c99,c256,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-07-22 14:09:14.063 17413-17413/com.ananth.frontrearcamera E/libc: Access denied finding property "persist.vendor.camera.privapp.list"
2020-07-22 14:09:14.062 17413-17413/com.ananth.frontrearcamera W/Binder:17413_2: type=1400 audit(0.0:1045): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=14928 scontext=u:r:untrusted_app:s0:c99,c256,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-07-22 14:09:14.069 17413-17426/com.ananth.frontrearcamera E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-07-22 14:09:14.151 17413-17413/com.ananth.frontrearcamera E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-07-22 14:09:14.158 17413-17413/com.ananth.frontrearcamera D/CameraFragment: selected aspect ratio 120x160 : 0
2020-07-22 14:09:14.166 17413-17413/com.ananth.frontrearcamera E/libc: Access denied finding property "persist.vendor.camera.privapp.list"
2020-07-22 14:09:14.175 17413-17426/com.ananth.frontrearcamera E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-07-22 14:09:14.176 17413-17426/com.ananth.frontrearcamera E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-07-22 14:09:14.878 17413-17426/com.ananth.frontrearcamera E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-07-22 14:09:14.890 17413-17426/com.ananth.frontrearcamera E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-07-22 14:09:15.163 17413-17426/com.ananth.frontrearcamera E/libc: Access denied finding property "vendor.camera.aux.packagelist"

2020-07-22 14:09:15.152 17413-17413/com.ananth.frontrearcamera W/Binder:17413_2: type=1400 audit(0.0:1056): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=14928 scontext=u:r:untrusted_app:s0:c99,c256,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-07-22 14:09:20.835 17413-17422/com.ananth.frontrearcamera W/System: A resource failed to call release.
2020-07-22 14:09:20.835 17413-17422/com.ananth.frontrearcamera W/System: A resource failed to call release.

Hey @seann99, I am not sure these are crash logs.

mCaptureRequestBuilderFront = mCameraDeviceFront.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); mCaptureRequestBuilderFront.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF); mCaptureRequestBuilderFront.set(CaptureRequest.CONTROL_AE_LOCK, true);
can you tell me exactly where i have to paste this code my rear is working fine but front is not working