Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Add this to your `babel.config.js`

## Usage

Simply call the `useScanBarcodes()` hook or call `scanBarcodes()` inside of the `useFrameProcessor()` hook. In both cases you will need to pass an array of `BarcodeFormat` to specify the kind of barcode you want to detect.
Simply call the `useScanBarcodes()` hook or call `scanCodes()` inside of the `useFrameProcessor()` hook. In both cases you will need to pass an array of `BarcodeFormat` to specify the kind of barcode you want to detect.

> Note: The underlying MLKit barcode reader is only created once meaning that changes to the array will not be reflected in the app.

Expand All @@ -37,7 +37,7 @@ import * as React from 'react';
import { StyleSheet, Text } from 'react-native';
import { useCameraDevices } from 'react-native-vision-camera';
import { Camera } from 'react-native-vision-camera';
import { useScanBarcodes, BarcodeFormat } from 'vision-camera-code-scanner';
import { useScanBarcodes, BarcodeFormat, /* scanCodes */ } from 'vision-camera-code-scanner';

export default function App() {
const [hasPermission, setHasPermission] = React.useState(false);
Expand All @@ -52,7 +52,7 @@ export default function App() {
//
// const frameProcessor = useFrameProcessor((frame) => {
// 'worklet';
// const detectedBarcodes = scanBarcodes(frame, [BarcodeFormat.QR_CODE], { checkInverted: true });
// const detectedBarcodes = scanCodes(frame, [BarcodeFormat.QR_CODE], { checkInverted: true });
// runOnJS(setBarcodes)(detectedBarcodes);
// }, []);

Expand Down
16 changes: 11 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath("com.android.tools.build:gradle:7.3.1")
}
}
}
Expand All @@ -18,11 +18,11 @@ def safeExtGet(prop, fallback) {
}

android {
compileSdkVersion safeExtGet('VisionCameraCodeScanner_compileSdkVersion', 30)
ndkVersion "21.4.7075529"
compileSdkVersion safeExtGet('VisionCameraCodeScanner_compileSdkVersion', 33)
ndkVersion "23.1.7779620"
defaultConfig {
minSdkVersion safeExtGet('VisionCameraCodeScanner_minSdkVersion', 21)
targetSdkVersion safeExtGet('VisionCameraCodeScanner_targetSdkVersion', 31)
targetSdkVersion safeExtGet('VisionCameraCodeScanner_targetSdkVersion', 33)
versionCode 1
versionName "1.0"

Expand Down Expand Up @@ -57,5 +57,11 @@ dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules
api project(":react-native-vision-camera")
implementation "androidx.camera:camera-core:1.1.0-alpha06"
implementation 'com.google.mlkit:barcode-scanning:17.0.0'
implementation 'com.google.mlkit:barcode-scanning:17.0.3'
}

configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.6.0'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
import com.google.mlkit.vision.barcode.Barcode;
import com.google.mlkit.vision.barcode.common.Barcode;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.google.android.gms.tasks.Tasks;
import com.mrousavy.camera.frameprocessor.FrameProcessorPlugin;
import com.google.android.gms.tasks.Task;
import com.google.mlkit.vision.barcode.Barcode;
import com.google.mlkit.vision.barcode.common.Barcode;
import com.google.mlkit.vision.barcode.BarcodeScanner;
import com.google.mlkit.vision.barcode.BarcodeScanning;
import com.google.mlkit.vision.barcode.BarcodeScannerOptions;
Expand Down
4 changes: 2 additions & 2 deletions src/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Frame, useFrameProcessor } from 'react-native-vision-camera';
import { useState } from 'react';
import { runOnJS } from 'react-native-reanimated';

import { Barcode, BarcodeFormat, CodeScannerOptions, scanBarcodes } from '.';
import { Barcode, BarcodeFormat, CodeScannerOptions, scanCodes } from '.';

export function useScanBarcodes(
types: BarcodeFormat[],
Expand All @@ -12,7 +12,7 @@ export function useScanBarcodes(

const frameProcessor = useFrameProcessor((frame) => {
'worklet';
const detectedBarcodes = scanBarcodes(frame, types, options);
const detectedBarcodes = scanCodes(frame, types, options);
runOnJS(setBarcodes)(detectedBarcodes);
}, []);

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export interface CodeScannerOptions {
* @param types Array of barcode types to detect (for optimal performance, use less types)
* @returns Detected barcodes from MLKit
*/
export function scanBarcodes(
export function scanCodes(
frame: Frame,
types: BarcodeFormat[],
options?: CodeScannerOptions
Expand Down