Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@ismaelmoreiraa/vision-camera-code-scanner
Advanced tools
VisionCamera Frame Processor Plugin to read barcodes using MLKit Vision Barcode Scanning
VisionCamera Frame Processor Plugin to read barcodes using MLKit Vision Barcode Scanning
yarn add vision-camera-code-scanner
make sure you correctly setup react-native-worklets and insert as a first line of your index.tsx
import "react-native-worklets/src";
Add this to your babel.config.js
["react-native-worklets/plugin"],
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.
Note: The underlying MLKit barcode reader is only created once meaning that changes to the array will not be reflected in the app.
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';
export default function App() {
const [hasPermission, setHasPermission] = React.useState(false);
const devices = useCameraDevices();
const device = devices.back;
const [frameProcessor, barcodes] = useScanBarcodes([BarcodeFormat.QR_CODE], {
checkInverted: true,
});
// Alternatively you can use the underlying function:
//
// const [barcodes, setBarcodes] = React.useState<Barcode[]>([]);
// const setBarcodesJS = Worklets.createRunInJsFn(setBarcodes);
//
// const frameProcessor = useFrameProcessor((frame) => {
// 'worklet';
// const detectedBarcodes = scanBarcodes(frame, [BarcodeFormat.ALL_FORMATS], {
// checkInverted: true,
// });
// setBarcodesJS(detectedBarcodes);
// }, []);
React.useEffect(() => {
(async () => {
const status = await Camera.requestCameraPermission();
setHasPermission(status === 'authorized');
})();
}, []);
return (
device != null &&
hasPermission && (
<>
<Camera
style={StyleSheet.absoluteFill}
device={device}
isActive={true}
frameProcessor={frameProcessor}
frameProcessorFps={5}
/>
{barcodes.map((barcode, idx) => (
<Text key={idx} style={styles.barcodeTextURL}>
{barcode.displayValue}
</Text>
))}
</>
)
);
}
const styles = StyleSheet.create({
barcodeTextURL: {
fontSize: 20,
color: 'white',
fontWeight: 'bold',
},
});
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
FAQs
VisionCamera Frame Processor Plugin to read barcodes using MLKit Vision Barcode Scanning
We found that @ismaelmoreiraa/vision-camera-code-scanner demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.