react-native-vision-camera
                                
                                 react-native-vision-camera copied to clipboard
                                
                                    react-native-vision-camera copied to clipboard
                            
                            
                            
                        ❓ Should useCameraDevices always return the "default" device? Front camera in black and white
Question
I'm not sure if this is a bug. I'm using a Pixel 4 and the default front camera appears to be the infrared camera (it's grainy and in black and white). When using the back camera I seem to get the "default" camera. I say default because it's the same one other apps seem to use or other libraries return.
Should useCameraDevices return the "default" front and back cameras? It seems like that' would make the most sense otherwise you'd have to be filtering cameras for each device. I've looked through the other issues and I can't see anyone else hitting this. Is this something I'm doing wrong?
What I tried
const Foo = () => {
   const devices = useCameraDevices()
   const device = devices.front
   return (
       <Camera
          ref={(ref) => (cameraRef.current = ref)}
          device={device}
          isActive={true}
        />
    )
}
VisionCamera Version
2.12.2
Additional information
- [ ] I am using Expo
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar questions in the issues page as well as in the discussions page and found none.
Lol that's definitely a bug. You could try filtering devices yourself, it's pretty straight forward:
useEffect(() => {
  const devices = await Camera.getAvailableDevices()
  // ...
}, []
Ha ok good to know. It's a relatively niche feature for my app so I think Pixel 4 users will just have to deal with their new black and white selfie feature :smile:
Also facing this issue, front camera only records in black / white, back camera fine
It appears the "wide-angle-camera" is black and white for the front camera on pixels.
We resolved by filtering for the "ultra-wide-angle-camera"
const availableDevices = await Camera.getAvailableCameraDevices();
const frontDevices = availableDevices.filter((dev) => dev.position === "front");
 const wideAngleCamera = frontDevices.filter((dev) =>
    dev.devices.includes("ultra-wide-angle-camera")
  );
Black and white photos for us on huawei P20 and huawei P20 Pro. Seems to be with back wide-angle camera
We met the exact issue in Google Pixel 4, it seems the issue might partially be caused by Camera.getAvailableCameraDevices()'s result is not consistent.
As the following screenshot:
- in react-native-vision-camera/src/hooks/useCameraDevices.ts the Camera.getAvailableCameraDevices() sorts 'wide-angle-camera' first, so useCameraDevices() would use this one as front camera.
- while in our app, the Camera.getAvailableCameraDevices() sorts 'ultra-wide-angle-camera' first


sorts first
No one said that Camera.getAvailableDevices does do any sorting. You are responsible for sorting that list.
This should be now fixed with the all new Devices API in V3! 🥳