mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.33k stars 1.07k forks source link

🐛 V3 не считывает коды Data-Matrix с черным фоном на Android #3196

Open KarimovAbdullo opened 1 week ago

KarimovAbdullo commented 1 week ago

What's happening?

I have an app designed for scanning QR and Data-Matrix codes. Currently, it works perfectly for scanning QR and Data-Matrix codes on a white background on both Android and iOS. However, the issue is that Android cannot read QR or Data-Matrix codes on a black or other colored backgrounds. image

Reproduceable Code

const ScannerCamera = forwardRef<ScannerAnimationRefI, ScannerCameraProps>(
  (props, animationRef) => {
    const device = useCameraDevice('back', {
      physicalDevices: ['wide-angle-camera'],
    });

    const {hasPermission, requestPermission} = useCameraPermission();

    const dispatch = useAppDispatch();

    const OnSecondCamera = () => {
      dispatch(authActions.setSecondCamera(true));
      if (props.scanFuther) {
        props.scanFuther();
      }
    };

    useEffect(() => {
      if (!hasPermission) {
        requestPermission();
      }
    }, [hasPermission, requestPermission]);

    const [torch, setTorch] = useState<'on' | 'off'>('off');

    return (
      <View style={styles.scannerContainer}>
        <View style={styles.scanner}>
          {device && hasPermission ? (
            <Camera
              {...props}
              torch={torch}
              device={device}
              style={StyleSheet.absoluteFillObject}
            />
          ) : null}
          <ScanerAnimation ref={animationRef} />
        </View>
        {hasPermission ? null : <CText RED>Нет разрешения на камеру</CText>}
        <CButton
          onPress={() => setTorch(prev => (prev === 'on' ? 'off' : 'on'))}
          outline>
          {torch === 'on' ? 'Выключить фонарик' : 'Включить фонарик'}
        </CButton>

        {Platform.OS === 'android' && props.scanFuther ? (
          <CButton
            style={{marginTop: 16}}
            onPress={OnSecondCamera}
            icon={<QrIconSvg strokeWidth={1.5} color="black" />}
          />
        ) : null}
      </View>
    );
  },
);
export default ScannerCamera;

 //////////

  const codeScanner = useCodeScanner({
    codeTypes: ['qr', 'data-matrix'],
    onCodeScanned,
  });

 <ScannerCamera
              ref={animationRef}
              codeScanner={codeScanner}
              isActive={active}
              scanFuther={scanFurther}
            />

Relevant log output

-

Camera Device

{ "formats": [], "sensorOrientation": "landscape-left", "hardwareLevel": "limited", "maxZoom": 8, "minZoom": 1, "maxExposure": 20, "supportsLowLightBoost": false, "neutralZoom": 1, "physicalDevices": [ "wide-angle-camera" ], "supportsFocus": true, "supportsRawCapture": false, "isMultiCam": false, "minFocusDistance": 0, "minExposure": -30, "name": "0 (BACK) androidx.camera.camera2", "hasFlash": true, "hasTorch": true, "position": "back", "id": "0" }

Device

Android

VisionCamera Version

react-native-vision-camera:3.4.6

Can you reproduce this issue in the VisionCamera Example app?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

maintenance-hans[bot] commented 1 week ago

Guten Tag, Hans here 🍻.

Thanks for ze detailed report! It seems you are facing a problem scanning Data-Matrix codes on black backgrounds with ze library. However, I notice you didn’t include any relevant logs which would be very helpful für troubleshooting.

Could you please provide logs from ze Android logcat? You can collect ze logs by running:

adb logcat *:S ReactNative:V ReactNativeJS:V

Once you provide ze logs, we can better assist you with zis issue. Also, don't forget to try reproducing ze issue in ze VisionCamera Example app as it could help narrow down ze cause.

Danke!

Note: If you think I made a mistake, please ping @mrousavy to take a look.