Skip to content

Commit b295872

Browse files
committed
update version and readme
1 parent 6659b82 commit b295872

File tree

2 files changed

+79
-64
lines changed

2 files changed

+79
-64
lines changed

README.md

Lines changed: 78 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -32,69 +32,83 @@ make sure you correctly setup react-native-reanimated and add this to your babel
3232

3333
## Usage
3434

35-
```js
36-
import * as React from 'react';
37-
import { StyleSheet, Text } from 'react-native';
38-
import { Camera, useCameraDevices, useFrameProcessor } from 'react-native-vision-camera';
39-
import { DBRConfig, decode, TextResult } from 'vision-camera-dynamsoft-barcode-reader';
40-
import * as REA from 'react-native-reanimated';
41-
42-
export default function App() {
43-
const [hasPermission, setHasPermission] = React.useState(false);
44-
const [barcodeResults, setBarcodeResults] = React.useState([] as TextResult[]);
45-
const devices = useCameraDevices();
46-
const device = devices.back;
47-
const frameProcessor = useFrameProcessor((frame) => {
48-
'worklet'
49-
const config:DBRConfig = {};
50-
config.template="{\"ImageParameter\":{\"BarcodeFormatIds\":[\"BF_QR_CODE\"],\"Description\":\"\",\"Name\":\"Settings\"},\"Version\":\"3.0\"}"; //scan qrcode only
51-
52-
const results:TextResult[] = decode(frame,config)
53-
REA.runOnJS(setBarcodeResults)(results);
54-
}, [])
55-
56-
React.useEffect(() => {
57-
(async () => {
58-
const status = await Camera.requestCameraPermission();
59-
setHasPermission(status === 'authorized');
60-
})();
61-
}, []);
62-
63-
return (
64-
device != null &&
65-
hasPermission && (
66-
<>
67-
<Camera
68-
style={StyleSheet.absoluteFill}
69-
device={device}
70-
isActive={true}
71-
frameProcessor={frameProcessor}
72-
frameProcessorFps={5}
73-
/>
74-
{barcodeResults.map((barcode, idx) => (
75-
<Text key={idx} style={styles.barcodeText}>
76-
{barcode.barcodeFormat +": "+ barcode.barcodeText}
77-
</Text>
78-
))}
79-
</>
80-
)
81-
);
82-
}
83-
84-
const styles = StyleSheet.create({
85-
container: {
86-
flex: 1,
87-
alignItems: 'center',
88-
justifyContent: 'center',
89-
},
90-
barcodeText: {
91-
fontSize: 20,
92-
color: 'white',
93-
fontWeight: 'bold',
94-
},
95-
});
96-
97-
```
35+
1. Scan barcodes from the camera preview.
36+
37+
```ts
38+
import * as React from 'react';
39+
import { StyleSheet, Text } from 'react-native';
40+
import { Camera, useCameraDevices, useFrameProcessor } from 'react-native-vision-camera';
41+
import { DBRConfig, decode, TextResult } from 'vision-camera-dynamsoft-barcode-reader';
42+
import * as REA from 'react-native-reanimated';
43+
44+
export default function App() {
45+
const [hasPermission, setHasPermission] = React.useState(false);
46+
const [barcodeResults, setBarcodeResults] = React.useState([] as TextResult[]);
47+
const devices = useCameraDevices();
48+
const device = devices.back;
49+
const frameProcessor = useFrameProcessor((frame) => {
50+
'worklet'
51+
const config:DBRConfig = {};
52+
config.template="{\"ImageParameter\":{\"BarcodeFormatIds\":[\"BF_QR_CODE\"],\"Description\":\"\",\"Name\":\"Settings\"},\"Version\":\"3.0\"}"; //scan qrcode only
53+
54+
const results:TextResult[] = decode(frame,config)
55+
REA.runOnJS(setBarcodeResults)(results);
56+
}, [])
57+
58+
React.useEffect(() => {
59+
(async () => {
60+
const status = await Camera.requestCameraPermission();
61+
setHasPermission(status === 'authorized');
62+
})();
63+
}, []);
64+
65+
return (
66+
device != null &&
67+
hasPermission && (
68+
<>
69+
<Camera
70+
style={StyleSheet.absoluteFill}
71+
device={device}
72+
isActive={true}
73+
frameProcessor={frameProcessor}
74+
frameProcessorFps={5}
75+
/>
76+
{barcodeResults.map((barcode, idx) => (
77+
<Text key={idx} style={styles.barcodeText}>
78+
{barcode.barcodeFormat +": "+ barcode.barcodeText}
79+
</Text>
80+
))}
81+
</>
82+
)
83+
);
84+
}
85+
86+
const styles = StyleSheet.create({
87+
container: {
88+
flex: 1,
89+
alignItems: 'center',
90+
justifyContent: 'center',
91+
},
92+
barcodeText: {
93+
fontSize: 20,
94+
color: 'white',
95+
fontWeight: 'bold',
96+
},
97+
});
98+
99+
```
100+
101+
2. Scan barcodes from a base64-encoded static image.
102+
103+
```ts
104+
let results = await decodeBase64(base64);
105+
```
106+
107+
3. License initialization ([apply for a trial license](https://www.dynamsoft.com/customer/license/trialLicense/?product=dbr)).
108+
109+
```ts
110+
await initLicense("your license");
111+
```
98112

99113
### Interfaces
100114

@@ -104,6 +118,7 @@ TextResult:
104118
TextResult{
105119
barcodeText:string;
106120
barcodeFormat:string;
121+
barcodeBytesBase64:string;
107122
x1:number;
108123
x2:number;
109124
x3:number;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vision-camera-dynamsoft-barcode-reader",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"description": "React Native Vision Camera Frame Processor Plugin of Dynamsoft Barcode Reader",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

0 commit comments

Comments
 (0)