Skip to content

Commit

Permalink
feat: update example app to use the frame processor hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
markrickert committed Aug 16, 2022
1 parent 76eff94 commit a4704d7
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable react-native/no-inline-styles */
import * as React from 'react';

import { runOnJS } from 'react-native-reanimated';
import {
StyleSheet,
View,
Expand All @@ -12,25 +10,19 @@ import {
Alert,
Clipboard,
} from 'react-native';
import { OCRFrame, scanOCR } from 'vision-camera-ocr';
import { useScanOCR } from 'vision-camera-ocr';
import {
useCameraDevices,
useFrameProcessor,
Camera,
} from 'react-native-vision-camera';

export default function App() {
const [hasPermission, setHasPermission] = React.useState(false);
const [ocr, setOcr] = React.useState<OCRFrame>();
const [pixelRatio, setPixelRatio] = React.useState<number>(1);
const devices = useCameraDevices();
const device = devices.back;

const frameProcessor = useFrameProcessor((frame) => {
'worklet';
const data = scanOCR(frame);
runOnJS(setOcr)(data);
}, []);
const [frameProcessor, ocr] = useScanOCR();

React.useEffect(() => {
(async () => {
Expand Down

0 comments on commit a4704d7

Please sign in to comment.