Code Monkey home page Code Monkey logo

capture-vision-react-native-samples's People

Contributors

arckongem avatar dynamsoft-henry avatar dynamsoft-jerson avatar dynamsoftallen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

capture-vision-react-native-samples's Issues

App frozen

The app getting freezing on unmounting, any solution?

Task :app:mergeDebugAssets FAILED

I am getting this error ...

image

Please Help me..

Package.json
"@react-native-community/masked-view": "^0.1.11",
"@react-navigation/native": "^6.0.2",
"@react-navigation/native-stack": "^6.0.5",
"react": "17.0.1",
"react-native": "0.64.2",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.2.0",
"react-native-safe-area-context": "^3.3.0",
"react-native-screens": "^3.5.0",
"rn-mobile-barcode-scanner": "^8.6.0"

dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx typescript definition incompatible with RN 0.70.6

Hello,

Most recent version of [email protected] currently experiences typescript conflicts that have been raised during our tsc step.

Is it possible to request the team to have a look in to the typing definitions to solve these conflicts? For now, I'm patching the package and skipping ts compiler from checking this file dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx by adding // @ts-nocheck at the top of the problematic file. This way our CI won't raise the exception. Ideally I should drop this patch as soon as the issue is resolved in the package directly.

Details of the typings errors:

$ tsc
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx(46,7): error TS2322: Type 'ComponentType<any>' is not assignable to type 'HostComponent<any>'.
  Type 'ComponentClass<any, any>' is not assignable to type 'HostComponent<any>'.
    Type 'Component<any, any, any>' is not assignable to type 'Component<any, {}, any> & Readonly<NativeMethods>'.
      Type 'Component<any, any, any>' is missing the following properties from type 'Readonly<NativeMethods>': measure, measureInWindow, measureLayout, setNativeProps, and 2 more.
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx(51,[9](...)): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx([10](...): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ torchState: any; }'.
  No index signature with a parameter of type 'string' was found on type '{ torchState: any; }'.
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx(102,20): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ torchState: any; }'.
  No index signature with a parameter of type 'string' was found on type '{ torchState: any; }'.
Error: node_modules/dynamsoft-capture-vision-react-native/js/DynamsoftCameraView.tsx([14](...): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'UIManagerStatic'.
  No index signature with a parameter of type 'string' was found on type 'UIManagerStatic'.
error Command failed with exit code 2.

Note: forgot to mentioned that some of those typing conflicts present on [email protected]

Error with Severe hang after multiple barcode readers

스크린샷 2023-06-15 오후 4 54 04

It only happens on iOS(I use RN: iOS-13.0, device: 16.4)

Using package version
"dynamsoft-capture-vision-react-native": "^1.1.7",
"react": "18.2.0",
"react-native": "0.71.7",

import React, { useRef, useState, useEffect } from 'react';
import { RouteProp, useNavigation, useNavigationState, useRoute } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { AppStackParamList } from '../../route/routeDef';
import { IFile } from '../../constants/IFile';
import { imgUploadCall } from '../../helper/s3Upload';
import useCustomHeader from '../../hooks/useCustomHeader';
import styled from 'styled-components/native';
import LMText from '../../components/atoms/LMText';
import {
  DCVBarcodeReader,
  DCVCameraView,
  EnumBarcodeFormat,
  EnumTorchState,
} from 'dynamsoft-capture-vision-react-native';
import { BarcodeResult } from '../../node_modules/dynamsoft-capture-vision-react-native/js/BarcodeResult';
import codeMasterStore from '../../stores/codeMasterStore';
import loaderStore from '../../stores/loaderStore';
import Button from '../../components/atoms/button';
import { captureScreen } from 'react-native-view-shot';
import { Platform } from 'react-native';
import { observer } from 'mobx-react';


const Layout = styled.View`
  flex: 1;
  justify-content: space-between;
`;
const NotificationView = styled.View`
  align-items: center;
`;
const NotificationBox = styled.View`
  margin-top: 19px;
  background-color: ${({theme}) => theme.colors.white.base};
  border-radius: ${({theme}) => theme.base.borderRadius}px;
  width: 258px;
  padding: 12px 20px;
  align-items: center;
  justify-content: center;
`;
const NotificationText = styled(LMText)`
  font-size: ${({theme}) => theme.typography.size.s1}px;
  color: ${({theme}) => theme.colors.gray.base};
  text-align: center;
  line-height: 19.56px;
`;
const BottomView = styled.View`
  margin-bottom: 24px;
  padding: 0 ${({theme}) => theme.base.templatePadding}px;
`;
const LicenseText = styled.Text`
  position: absolute;
  top: 25%;
  right: 25%;
  font-size: ${({theme}) => theme.typography.size.l3}px;
  color: ${({theme}) => theme.colors.gray[300]};
`;
const ScanRegion = {
  regionTop: 40,
  regionLeft: 15,
  regionBottom: 60,
  regionRight: 85,
  regionMeasuredByPercentage: true,
};
const Scan = observer(() => {
  const navigation = useNavigation<NativeStackNavigationProp<AppStackParamList>>();
  const router = useRoute<RouteProp<AppStackParamList, '_Scan'>>();
  const routes = useNavigationState(state => state.routes);
  const prevRoute = routes[routes.length - 2];
  const [reader, setReader] = useState<DCVBarcodeReader>();
  // Ref
  const DCVRef = useRef<DCVCameraView>(null);
  const clear = async () => {
    console.log(router.params.key, 'clear start');
    if (reader) {
      reader.removeAllResultListeners();
      await reader.stopScanning();
      setReader(undefined);
    }
    console.log(router.params.key, 'clear end');
  };
  const createReader = async () => {
    console.log(router.params.key, 'createReader start');
    try {
      const _reader = await DCVBarcodeReader.createInstance();
      setReader(_reader);
    } catch (error: any) {
      console.log('create reader error =>', error);
    }
    console.log(router.params.key, 'createReader end');
  };
  const startScanning = async () => {
    console.log(router.params.key, 'const startScanning start');
    try {
      if (!reader) {
        console.log('no reader');
        return;
      }
      await reader.resetRuntimeSettings();
      // Set the expected barcode count to 0 when you are not sure how many barcodes you are scanning.
      // Set the expected barcode count to 1 can maximize the barcode decoding speed.
      let setting = await reader.getRuntimeSettings();
      setting.expectedBarcodesCount = 1;
      // Set the barcode format to read.
      setting.barcodeFormatIds = EnumBarcodeFormat.BF_ALL;
      // Apply the new runtime settings to the barcode reader.
      await reader.updateRuntimeSettings(setting);
      // await reader.startScanning();
    } catch (e) {
      console.log('startScanning');
      console.log(e);
    }
    console.log(router.params.key, 'const startScanning end');
  };
  const regularizeResults = (results: Array<BarcodeResult>) => {
    const resultList = results.map((result) => result.barcodeText);
    const resultBarcodes = removeUnExpectWord(resultList);
    return resultBarcodes;
  };
  const removeUnExpectWord = (barcodes: Array<string>) => {
    const reg = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi;
    const editedBarcodes = barcodes.map((barcode) => {
      let _barcode = barcode.trim();
      if (_barcode.startsWith('{GS}')) {
        _barcode = _barcode.replace('{GS}', '');
      }
      if (_barcode.endsWith('{GS}')) {
        _barcode = _barcode.replace('{GS}', '');
      }
      return _barcode;
    });
    return editedBarcodes;
  };
  // 사진을 촬영하여 이미지 주소를 생성합니다.
  const handleMakePhotoUrl = async (fileUri: string) => {
    try {
      const file: IFile = {
        uri: fileUri,
        name: codeMasterStore.currentTime.toString(),
        type: 'image/jpeg',
      };
      const url = await imgUploadCall(file);
      return url;
    } catch (e) {
      console.log(e);
      console.log('handleMakePhotoUrl');
    }
  };
  // 화면을 캡쳐하고, 이와 별개로 바코드를 스캔합니다.
  const takeScreenShotAndBarcode = async () => {
    console.log(router.params.key, 'takeScreenShotAndBarcode start');
    try {
      if (!reader) {
        console.log('reader 없음');
        return;
      }
      const capture = await captureScreen({format: 'jpg', quality: 0.3});
      if (!capture) {
        return;
      }
      const url = await handleMakePhotoUrl(capture);
      reader.addResultListener(async (data) => {
        if (data) {
          const regularize = regularizeResults(data);
          if (regularize.length > 0) {
            reader.removeAllResultListeners();
            if (router.params.withImage) {
              await clear();
              // NOTE: react-native-view-shot
              // 해당 라이브러리는 ios 환경을 캡쳐할 수 없는 이슈
              if (Platform.OS === 'ios') {
                goPrevRoute(regularize[0].trim(), false);
              } else {
                goPrevRoute(regularize[0].trim(), true, url);
              }
            } else {
              await clear();
              goPrevRoute(regularize[0].trim(), false);
            }
          }
        }
      });
    } catch (e) {
      console.log('takeScreenShotAndBarcode');
      console.log(e);
    }
    console.log(router.params.key, 'takeScreenShotAndBarcode end');
  };
  const goPrevRoute = (barcode: string, withImage: boolean, imageUrl?: string | null) => {
    console.log(router.params.key, 'goPrevRoute start');
    if (!withImage) {
      // @ts-ignore
      navigation.navigate({
        name: prevRoute.name,
        params: {
          barcode: barcode,
          // @ts-ignore
          key: router.params.key,
        },
        merge: true,
      });
      console.log(router.params.key, 'goPrevRoute end');

      return;
    }
    // @ts-ignore
    navigation.navigate({
      name: prevRoute.name,
      params: {
        barcode: barcode,
        scannedImage: imageUrl,
        // @ts-ignore
        key: router.params.key,
      },
      merge: true,
    });
    console.log(router.params.key, 'goPrevRoute end');
  };
  useCustomHeader({
    title: '바코드 스캔',
  });
  useEffect(() => {
    if (reader) {
      // @ts-ignore
      console.log(router.params.key, 'Scan');
      console.log(reader, 'Scan');
      (async () => {
        try {
          loaderStore.setLoading(true);
          console.log(router.params.key, 'reader.startScanning start');
          await reader.startScanning();
          console.log(router.params.key, 'reader.startScanning end');
          loaderStore.setLoading(false);
        } catch (e) {
          console.log(e);
        }
      })();
    } else {
      (async () => {
        loaderStore.setLoading(true);
        await createReader();
        loaderStore.setLoading(false);
      })();
    }
  }, [reader]);
  return (
    <Layout collapsable={false}>
      <DCVCameraView
        style={{flex: 1, justifyContent: 'space-between'}}
        ref={DCVRef}
        overlayVisible={true}
        // @ts-ignore
        torchButton={{visible: true}}
        torchState={EnumTorchState.OFF}
        scanRegionVisible={true}
        scanRegion={ScanRegion}
      >
        <LicenseText>Powered by Dynamsoft</LicenseText>
        <NotificationView>
          <NotificationBox>
            <NotificationText>{`바코드를 사각형에 위치시키고\n바코드 스캔 버튼을 눌러주세요`}</NotificationText>
          </NotificationBox>
        </NotificationView>
        <BottomView>
          {loaderStore.loading ? null :
            <Button
              title="바코드 스캔"
              size="large"
              onPress={async () => {
                loaderStore.setLoading(true);
                await startScanning();
                await takeScreenShotAndBarcode();
                loaderStore.setLoading(false);
              }}
            />}
        </BottomView>
      </DCVCameraView>
    </Layout>
  );
});
export default Scan;

Unfortunately, this is not my code, so I don't know the reason for writing etc. in detail.
So if there is a problem, I think it needs to be fixed.
I would like to know the cause of Severe Hang additionally. Is there a logic that intentionally triggers Hang?

DCVCameraView styling support

Hello,

Please label this query accordingly, as I could only submit an issue.

I was wondering if there is way (maybe not documented yet) to style the scanRegion and overlay look. Currently I could not find any info in the documentation.

From the (web demo) I can see the reader has a different look, so bearing in mind the differences between the APIs, theoretically this could possible, but not supported yet?

So I am wondering if there is any chance to support this functionality? I would like to make scan region with a border radius, different border colour and a darker masking background.

DCVCameraView component not working

The first time you open it, you can scan, then return to the desktop, and the application becomes the background, and then the camera cannot be displayed
one :
image
two:
image

CocoaPods could not find compatible versions for pod "DynamsoftBarcodeReader"

I'm trying to add this barcode scanner to an existing React Native project. After running yarn && npx pod-install ios here is the error I get:

[!] CocoaPods could not find compatible versions for pod "DynamsoftBarcodeReader":
  In Podfile:
    dynamsoft-capture-vision-react-native (from `../node_modules/dynamsoft-capture-vision-react-native`) was resolved to 1.1.7, which depends on
      DynamsoftBarcodeReader (= 9.2.13)

    vision-camera-dynamsoft-barcode-reader (from `../node_modules/vision-camera-dynamsoft-barcode-reader`) was resolved to 0.6.0, which depends on
      DynamsoftBarcodeReader (= 9.4.0)

###Packages
"react-native": "0.67.1",
"dynamsoft-capture-vision-react-native": "^1.1.7",

Any ideas on how to handle this?

Camera permission on launch - ios

Our team relies on separate package for app permissions workflow. We noticed that the app in ios is not following the implemented workflow (android does).

Basically the app in ios requests the camera permission during the app first launch, but in android it only occurs on user demand when the camera is opened for the first time. The ladder is the better user experience.

This behaviour also occurs in the sample app.

Would it be possible to have a unified workflow more similar to what currently happens in android?

iOS simulator stuck in SplashScreen - [email protected]

Hello Dynamsoft team,

We noticed that from version 1.1.8 (also present in latest 1.1.9), the app gets stuck in the SplashScreen when the running the ios simulator. Inspecting logs and runtime activity unfortunately does not raise any insightful info or runtime exceptions that can point to the exact issue.

However backtracking the change history in our codebase we can clearly see that the issue started when the sdk version was bumped to 1.1.8

The app passes the SplashScreen on devices (android and ios) and emulator (android).

We understand that this camera sdk is supported for devices as they're the only ones with camera hardware to validate functionality for DynamsoftBarcodeReader and DynamsoftCameraEnhancer. However version 1.1.7 did not experience this issue and the simulator would work fine. We even downgraded the sdk to validate this is the case.

We cannot rely on device only for development purposes as other team members don't use a device to work on other functionality for the app. They may just use a simulator or an emulator. This issue basically will block their local development environment.

Details of the changes that introduced the issue

Podfile.lock

Perhaps this may have been introduced in the pods DynamsoftBarcodeReader (9.6.10) and DynamsoftCameraEnhancer (2.3.1) when dynamsoft-capture-vision-react-native version bump from 1.1.7 to 1.1.8?

Basically DynamsoftBarcodeReader (9.2.13) and DynamsoftCameraEnhancer (2.3.2) were free of this issue but had other issues such as scanRegion problems.

Could you please have a look and apologies for not offering more details.

Thanks a lot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.