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

If I using USB type external camera that not showing in android and it only shows the back(0 index) and front(1 index) but not showing the external(2 index).🐛

Open Sathishkumargrc opened this issue 2 years ago • 0 comments

What's happening?

If I using USB type external camera that not showing in android and it only shows the back(0 index) and front(1 index) but not showing the external(2 index). can you please look around it and fix this. it's not showing the external device in -> getAvailableDevice(). 🐛

Reproduceable Code

import {Alert, StyleSheet, Text, View} from 'react-native';
import React, {useEffect} from 'react';
import {
  Camera,
  useCameraDevice,
  useCameraPermission,
  useMicrophonePermission,
} from 'react-native-vision-camera';
import {useIsFocused} from '@react-navigation/native';
import {useAppState} from '@react-native-community/hooks';

const ExternalCameraScreen = () => {
  const {hasCamPermission, requestCamPermission} = useCameraPermission();
  const {hasMicPermission, requestMicPermission} = useMicrophonePermission();

  const NoCameraDeviceError = () => (
    <View>
      <Text
        style={{
          color: 'black',
          fontSize: 16,
          alignItems: 'center',
          justifyContent: 'center',
          alignSelf: 'center',
          marginTop: 10,
        }}>
        No camera device found
      </Text>
    </View>
  );

  const devices = Camera.getAvailableCameraDevices();

  const device = useCameraDevice('external');
  const usbCamera = useCameraDevice('external');
  const external = usbCamera || device;
  console.log('usbCamera >>>',usbCamera)

  const isFocused = useIsFocused();
  const appState = useAppState();
  const isActive = isFocused && appState === 'active';

    devices.map(device => {
      console.log('device', device.name);
    });
  }, []);

  if ((external || device || usbCamera) == null) return <NoCameraDeviceError />;
  return <Camera style={{flex: 1}} device={external} isActive={isActive} />;
  if (usbCamera != null) {
      return (
          <Camera
              style={{ flex: 1 }}
              device={usbCamera}
              isActive={isActive}
          />
      )
  } else {
      return (
          <Camera
              style={{ flex: 1 }}
              device={device}
              isActive={isActive}
          />
      )
  }
};

export default ExternalCameraScreen;

const styles = StyleSheet.create({});

Relevant log output

LOG: usbCamera >>> undefined
LOG: device back(0), front(1)

Camera Device

{
  "sensorOrientation": "landscape-right",
  "hardwareLevel": "full",
  "maxZoom": 8,
  "minZoom": 1,
  "maxExposure": 8,
  "supportsLowLightBoost": false,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": true,
  "isMultiCam": false,
  "minExposure": -8,
  "name": "BACK (0)",
  "hasFlash": true,
  "hasTorch": true,
  "position": "back",
  "id": "0"
},
{
  "sensorOrientation": "landscape-right",
  "hardwareLevel": "full",
  "maxZoom": 8,
  "minZoom": 1,
  "maxExposure": 8,
  "supportsLowLightBoost": false,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "supportsFocus": true,
  "name": "FRONT (1)",
  "position": "back",
  "id": "0"
}

Device

Vivo Y73

VisionCamera Version

3.6.14

Can you reproduce this issue in the VisionCamera Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

Sathishkumargrc avatar Dec 16 '23 09:12 Sathishkumargrc