react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

๐Ÿ› Android phones not reporting all existing cameras

Open viljark opened this issue 4 years ago โ€ข 15 comments

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 avatar Nov 18 '21 12:11 viljark

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.

mrousavy avatar Nov 22 '21 08:11 mrousavy

Hi, any update on this issue?

Yennnful avatar Jan 29 '22 15:01 Yennnful

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

matiaspan avatar Mar 03 '22 18:03 matiaspan

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.

cristianoccazinsp avatar Mar 04 '22 21:03 cristianoccazinsp

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.

viljark avatar Mar 04 '22 21:03 viljark

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.

cristianoccazinsp avatar Mar 04 '22 22:03 cristianoccazinsp

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

mrousavy avatar Mar 07 '22 12:03 mrousavy

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)

viljark avatar Mar 07 '22 12:03 viljark

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

mrousavy avatar Mar 07 '22 12:03 mrousavy

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.

rfischer20 avatar Apr 14 '22 16:04 rfischer20

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

mrousavy avatar Apr 15 '22 07:04 mrousavy

Hi, any update on this issue?

jokertrip avatar Jul 21 '22 18:07 jokertrip

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

buildgreatthings avatar Jul 28 '22 05:07 buildgreatthings

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.

buildgreatthings avatar Jul 28 '22 17:07 buildgreatthings

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?

arcticfly avatar Jul 28 '22 23:07 arcticfly

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.

cloudmu avatar Nov 07 '22 19:11 cloudmu

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.

nikonhub avatar Nov 18 '22 17:11 nikonhub

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

wibes avatar Apr 14 '23 11:04 wibes

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

Tiropz avatar Jul 26 '23 11:07 Tiropz

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: https://github.com/mrousavy/react-native-vision-camera/pull/1674#issuecomment-1684104217

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!

mrousavy avatar Aug 18 '23 16:08 mrousavy

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]

mdottavi avatar Sep 19 '23 09:09 mdottavi

@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 avatar Sep 19 '23 09:09 mrousavy

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 https://github.com/mrousavy/react-native-vision-camera/blob/18c7034b5006986a7df6da9bf799dcc745244932/package/android/src/main/java/com/mrousavy/camera/core/CameraSession.kt#L436-L460 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 avatar Sep 19 '23 09:09 mrousavy

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

mrousavy avatar Sep 19 '23 09:09 mrousavy