duanhong169 / Camera

📸 Use Android camera to take pictures and videos, based on `camera2` api.
Apache License 2.0
130 stars 45 forks source link

Camera flip to front camera #5

Closed Vibinreji closed 5 years ago

Vibinreji commented 5 years ago

Camera flip to front camera not working

duanhong169 commented 5 years ago

Please check this function and see if the front-facing camera cannot be found:

https://github.com/duanhong169/Camera/blob/6077681d059eb5f8f01ffbf373ebc35ed01e3def/camera/src/main/java/top/defaults/camera/Camera2Photographer.java#L303-L351

Vibinreji commented 5 years ago

Yes there is chooseCameraIdByFacing().But still it is not working.I am using moto x play.

duanhong169 commented 5 years ago

Sorry I cannot reproduce this, please try to debug with the source code. I guess there is something wrong with finding the front camera.

Vibinreji commented 5 years ago

okay.

MrBrown09 commented 5 years ago

okay.

Got solution?

MrBrown09 commented 5 years ago

Does CameraView support onTouch for Swipe action?

guillermo-gerard commented 4 years ago

This library is a good starting point to understand the complex Camera2 API, so I'm using it in a client's project. I've found this issue to be a common one among our test devices, so I went through the source code and I this that the issue here is at Camera2Photographer, method chooseCameraIdByFacing. In my case, the camera is not changing to the frontal one, because it has INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY mark in its INFO_SUPPORTED_HARDWARE_LEVEL property at the CameraCharacteristics object. I don't know yet why you are ignoring these cameras, but I think it has to do with the limitations of the hardware, as stated here: https://developer.android.com/reference/android/hardware/camera2/CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY But I don't see any reason to do that, because in my phone, for example, both cameras (front and back) have INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY level, and the library is working with the back camera. But when I try to switch to the front one, it refuses and force selects again the back camera here:

updateCameraInfo(ids[0], cameraManager.getCameraCharacteristics(ids[0]));

Am I right? Any advice about this?

CrazyCoderAndroid commented 4 years ago

Got solution ?