Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Android phones not reporting all existing cameras #595

Closed
4 tasks done
viljark opened this issue Nov 18, 2021 · 24 comments · Fixed by #1466
Closed
4 tasks done

🐛 Android phones not reporting all existing cameras #595

viljark opened this issue Nov 18, 2021 · 24 comments · Fixed by #1466
Labels
🐛 bug Something isn't working

Comments

@viljark
Copy link

viljark commented Nov 18, 2021

What were you trying to do?

I want to use ultrawide and telephoto cameras that exist on my Samsung Galaxy A12 (it has quad camera setup) and Oneplus 7T (triple camera setup)

Reproduceable Code

useEffect(() => {
		Camera.getAvailableCameraDevices().then((devices) => {
			console.log(JSON.stringify(devices.map((d) => ({ [d.position]: d.devices }))))
		})

	}, [])

What happened instead?

Camera.getAvailableCameraDevices() for Samsung Galaxy A12 reports it only has the following cameras:
[{"back":["wide-angle-camera"]},{"front":["wide-angle-camera"]},{"front":["wide-angle-camera"]}]

A12 back cameras:
48 MP, f/2.0, 26mm (wide),
AF5 MP, f/2.2, 123˚ (ultrawide)
2 MP, f/2.4, (macro)
2 MP, f/2.4, (depth)

Oneplus 7T also only reports single back wide-angle-camera, while it has these back cameras:
48 MP, f/1.6, 26mm (wide), 1/2.0", 0.8µm, PDAF, OIS
12 MP, f/2.2, 51mm (telephoto), 1.0µm, PDAF, 2x optical zoom
16 MP, f/2.2, 17mm (ultrawide), AF

Relevant log output

No response

Device

Samsung Galaxy A12, Oneplus 7T

VisionCamera Version

2.9.4-expo.11

Additional information

@viljark viljark added the 🐛 bug Something isn't working label Nov 18, 2021
@mrousavy
Copy link
Owner

Hi!

That's not yet supported by the underlying native Android CameraX library, I've created an issue in their issue tracker and they're working on it.

@Yennnful
Copy link

Hi, any update on this issue?

@matiaspan
Copy link

@mrousavy do you have a link to the issue you reported on CameraX? would like to give this more visibility

@cristianoccazinsp
Copy link

I'm curious whether or not this has been resolved. I'm observing similar issues with the ancient react-native-camera on Samsung Galaxy S22 and this may be a good excuse to migrate libraries.

@viljark
Copy link
Author

viljark commented Mar 4, 2022

I'm curious whether or not this has been resolved. I'm observing similar issues with the ancient react-native-camera on Samsung Galaxy S22 and this may be a good excuse to migrate libraries.

I think this is not resolved, modern multi camera setups still report only single back camera.
But when zooming in and out, the camera is switched to zoom / wide angle automatically on my Pixel 6 pro, so it still can use the cameras. I'm not sure if there is a way to trigger camera switching by setting the zoom values manually.

@cristianoccazinsp
Copy link

So how do you know the camera supports an ultra wide / or telephoto camera on android? If the cameras are not reported, does that mean you need to rely on min/max zoom values and the user zooming out enough to trigger the camera? I haven’t read through the docs so apologies if that’s explained there.

Does the library handle native zoom and camera switching automatically? Including tap to focus? As I’ve seen issues with native zoom support blocking other tap actions to, for example, implement tap to focus.

@mrousavy
Copy link
Owner

mrousavy commented Mar 7, 2022

But when zooming in and out, the camera is switched to zoom / wide angle automatically on my Pixel 6 pro

Wait, really? This means CameraX does have multi-cam support after all?

As far as I know, they don't. And there's an open issue somewhere in the google issue tracker about this, don't have a link right now

@viljark
Copy link
Author

viljark commented Mar 7, 2022

But when zooming in and out, the camera is switched to zoom / wide angle automatically on my Pixel 6 pro

Wait, really? This means CameraX does have multi-cam support after all?

As far as I know, they don't. And there's an open issue somewhere in the google issue tracker about this, don't have a link right now

Seems like it works on Pixel 6 Pro (Android 12)

@mrousavy
Copy link
Owner

mrousavy commented Mar 7, 2022

Haha awesome, maybe they do it fully on hardware level.

@rfischer20
Copy link

Is there a way to detect if it's camerax. We're trying to work on a solution to not set the devices when the device uses android camerax.

@mrousavy
Copy link
Owner

What? If you don't use CameraX you don't have a camera at all?

@jokertrip
Copy link

Hi, any update on this issue?

@awcchungster
Copy link

I also have this problem, and it's very frustrating Android manufactures don't improve their software to support developers.

@awcchungster
Copy link

awcchungster commented Jul 28, 2022

Hi!

That's not yet supported by the underlying native Android CameraX library, I've created an issue in their issue tracker and they're working on it.

Could you please link us the ticket? I have friends on the Android team.

@arcticfly
Copy link
Contributor

Seeing the ticket would be super helpful for my team @mrousavy. If possible, we can try to fork the repo and submit a PR with our best work around?

@cloudmu
Copy link

cloudmu commented Nov 7, 2022

But when zooming in and out, the camera is switched to zoom / wide angle automatically on my Pixel 6 pro

Wait, really? This means CameraX does have multi-cam support after all?
As far as I know, they don't. And there's an open issue somewhere in the google issue tracker about this, don't have a link right now

Seems like it works on Pixel 6 Pro (Android 12)

I can confirm that when zooming out, the camera cannot zoom out all the way on S20 and Note 10.

@nikonhub
Copy link

nikonhub commented Nov 18, 2022

New user here.

So the google ticket is here
It's commented under the getAvailableCameraDevices method.

Would be helpful to know if someone managed to get the video mode work fluidly ?
I get 4 physical cameras on android. None of them get a good result, despite the stock camera app working perfectly fine.

Not sure if this issue even would fix my problem. But wouldn't it be possible to get a logical camera for back camera instead of physical ? Something more automatic, and working just out of the box.

Today letting useCameraDevices hook choose the camera for us, results in a 5 fps camera, unusable.

If on android side, to use the camera is not just plug & play, I'd be glad to get more documentation on this.

Edit 1 : Nvm. My issue is resolved in this ticket. With 1.2.0-rc01 camerax version.
I thought it had something to do with camera selection which created a bad fps for preview. But the default back 0 works great now, it was just an issue with huawei devices.

@wibes
Copy link

wibes commented Apr 14, 2023

I am facing similar issue, not able to get ultra wide angle camera. Any update on fix ?

@Tiropz
Copy link

Tiropz commented Jul 26, 2023

I'm facing the same issue, the only camera available on android is the "wide-angle-camera". Couldn't find a workaround

@mrousavy
Copy link
Owner

Hey! I've rewritten the entire Android codebase of VisionCamera from CameraX to Camera2 in the efforts of ✨ VisionCamera V3.

I just now completed the Camera2 rewrite and I believe the core structure is running, but there might be some edge cases to iron out. Can you try and test the PR #1674 for me to see if you can still reproduce this issue here?

Here's an instruction on how you can test that: #1674 (comment)

If the issue cannot be reproduced with that version/PR anymore, then hoorayy, I fixed it! 🎉
Otherwise please let me know and I'll keep this issue open to keep track of it.

Thank you!

@mdottavi
Copy link

Hi, we are trying to integrate v3 in our project...
We tested the example app on several Android phones and found the following issues:

  • OnePlus 10 Pro (Android 13):
    starts but shows Front Cam + 1 Back wide-angle camera
    but the phone includes 3 Back cameras (including 1 ultra-wide-angle- camera 0.6 zoom)
  • OnePlus Nord2 (Android 13):
    starts but shows Front Cam + 1 Back wide-angle camera
    but the phone includes 3 Back cameras (including 1 ultra-wide-angle- camera 0.6 zoom)
  • Samsung S10+ (Android 12):
    detects Front Cam + 3 Back cameras ( 2 wide-angle camera + 1 ultra-wide-angle camera)
    but throws an error when displaying camera frames:
    ERROR [session/camera-has-been-disconnected: [session/camera-has-been-disconnected] The given Camera device (id: 0) has been disconnected! Error: UNKNOWN_CAMERA_DEVICE_ERROR]
  • Motoral One Macro (Android 10)
    detects shows Front Cam + 1 Back wide-angle camera
    but throws an error when displaying camera frames:
    ERROR [session/camera-has-been-disconnected: [session/camera-has-been-disconnected] The given Camera device (id: 0) has been disconnected! Error: DISCONNECTED]

@mrousavy
Copy link
Owner

mrousavy commented Sep 19, 2023

@mdottavi thank you for those insights, that is actually very helpful. I don't have those devices, so you testing it help me improve the library.

Can you just put the output of this here?

const devices = await Camera.getAvailableCameraDevices()
for (const device of devices) {
  device.formats = null // just remove the formats for logging
}
console.log(JSON.stringify(devices, null, 2))

Thanks! 🙏

@mrousavy
Copy link
Owner

Regarding Samsung S10+ and Motoral One Macro, maybe this also has something to do with the custom format. There have been multiple reports on that.

Can you please try removing those 24 lines

// FPS
val fpsRange = if (fps != null && CAN_SET_FPS) Range(fps, fps) else Range(30, 30)
captureRequest.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange)
// Video Stabilization
captureRequest.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, videoStabilizationMode?.toDigitalStabilizationMode())
captureRequest.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, videoStabilizationMode?.toOpticalStabilizationMode())
// Night/HDR Mode
val sceneMode = if (hdr == true) CaptureRequest.CONTROL_SCENE_MODE_HDR else if (lowLightBoost == true) CaptureRequest.CONTROL_SCENE_MODE_NIGHT else null
captureRequest.set(CaptureRequest.CONTROL_SCENE_MODE, sceneMode)
captureRequest.set(CaptureRequest.CONTROL_MODE, if (sceneMode != null) CaptureRequest.CONTROL_MODE_USE_SCENE_MODE else CaptureRequest.CONTROL_MODE_AUTO)
// Zoom
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
captureRequest.set(CaptureRequest.CONTROL_ZOOM_RATIO, zoom)
} else {
val cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId!!)
val size = cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE)!!
captureRequest.set(CaptureRequest.SCALER_CROP_REGION, size.zoomed(zoom))
}
// Torch Mode
val torchMode = if (torch == true) CaptureRequest.FLASH_MODE_TORCH else CaptureRequest.FLASH_MODE_OFF
captureRequest.set(CaptureRequest.FLASH_MODE, torchMode)

and see if the camera then starts?
If it does, try adding feature by feature back and see which one causes it. My guess is either fps or video stabilization, those manufacturers tend to be weird/off-platform for those things 😅

@mrousavy
Copy link
Owner

Also, if you want you can join our community discord to talk about this there (i sometimes miss github notificaitons, I get too many)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.