rodgomesc / vision-camera-code-scanner

VisionCamera Frame Processor Plugin to read barcodes using MLKit Vision QrCode Scanning
MIT License
337 stars 222 forks source link

__scanCodes is not defined #107

Open chaudev opened 1 year ago

chaudev commented 1 year ago

Help me, please !!!

plugins: [ [ 'react-native-reanimated/plugin', { globals: ['__scanQRCodes'], }, ], ],

project.ext.react = [ enableHermes: false ] project.ext.react = [ enableHermes: true ] yarn start --reset-cache


irodeanu commented 1 year ago

I resolved with that: https://github.com/rodgomesc/vision-camera-code-scanner/issues/79#issuecomment-1276041982

hosijyun commented 1 year ago

Try adding one line to the file 'VisionCameraCodeScanner.m' as shown below.

@interface VISION_EXPORT_SWIFT_FRAME_PROCESSOR(scanCodes, VisionCameraCodeScanner) -(void)stub {} @end

Moatezz commented 1 year ago

Try adding one line to the file 'VisionCameraCodeScanner.m' as shown below.

@interface VISION_EXPORT_SWIFT_FRAME_PROCESSOR(scanCodes, VisionCameraCodeScanner) -(void)stub {} @EnD

Where is the path of this file?

valery-lavrik commented 1 year ago

One of the branches says that the fix was made in version 2.15.2, but I still have this error in android.

Peege151 commented 1 year ago

I still have this error running from the example, running in ios.

kaivamannam commented 1 year ago

In my babel.config.js I have

plugins: [[ 'react-native-reanimated/plugin', { globals: ['__scanCodes'] } ]]

I put 'scanCodes' instead of 'scanQRCodes' and it works for me

nhatnguyen95 commented 1 year ago

the issue happens on Android with typescript enabled.

Note: I updated react native to 0.70.6 and the issue is resolved

bb7hn commented 1 year ago

"react-native": "0.70.6" "react-native-vision-camera": "2.15.2" "vision-camera-code-scanner": "^0.2.0", "react-native-reanimated": "^2.13.0"

Hello Everyone I faced with the same issue and solved like this:

import { Camera, useCameraDevices, useFrameProcessor } from 'react-native-vision-camera';
import { BarcodeFormat, scanBarcodes, Barcode } from 'vision-camera-code-scanner';
import 'react-native-reanimated';
import { runOnJS } from 'react-native-reanimated';
import React, { useState } from 'react';
import { View, StyleSheet } from 'react-native';

const MyComponent = () => {
  const devices = useCameraDevices();
  const device = devices.back;
  const [barcodes, setBarcodes] = useState<Barcode[]>([]);

  const frameProcessor = useFrameProcessor((frame) => {
    'worklet';

    const detectedBarcodes = scanBarcodes(frame, [BarcodeFormat.ALL_FORMATS], { checkInverted: true });
    console.log(detectedBarcodes);
    runOnJS(setBarcodes)(detectedBarcodes);
  }, []);

  return (
    <View
      style={{
        flex: 1,
      }}>
      {device && (
        <Camera style={StyleSheet.absoluteFill} device={device} frameProcessor={frameProcessor} isActive={true} frameProcessorFps={60} />
      )}
    </View>
  );
};

export default MyComponent;

the point is I moved import reanimated into my component also changed FPS(frameProcessorFps) prop to 60 After that, I deleted node_modules, reinstalled and rebuild the app. So now it works fine for me

RenderCoder commented 1 year ago

This problem has bothered me for a long time, after update react-native-vision-camera to 2.15.2, this error disappear.