Ben*_*sky 6 ocr scanning react-native expo
我尝试使用各种库(例如react-native-tesseract react-native-text-detectorExpo 中的库)来集成 OCR,但它们不起作用。这是我的代码,我想知道如何在其中集成 OCR。预先感谢您的解决方案!
takePicture = async () => {
if (this.camera) {
const options = { quality: 0.5, base64: true };
const data = await this.camera.takePictureAsync(options);
this.runOcr(data.uri);
}
};
runOcr = async (imageUri) => {
//code here
};
return (
<>
<Camera
ref={(ref) => {
this.camera = ref;
}}
style={{
flex: 1,
position: "absolute",
width: "100%",
height: "100%",
}}
type={Camera.Constants.Type.back}
autoFocus={Camera.Constants.AutoFocus.on}
flashMode={
!this.state.isFlash
? Camera.Constants.FlashMode.off
: Camera.Constants.FlashMode.on
}
/>
<View
style={{
position: "absolute",
bottom: "5%",
display: "flex",
alignItems: "center",
justifyContent: "space-between",
width: "100%",
flexDirection: "row",
}}
>
<TouchableOpacity onPress={this.takePicture}>
<Image
style={{ width: 90, height: 90 }}
source={require("./assets/rec.png")}
/>
</TouchableOpacity>
</View>
</>
);
Run Code Online (Sandbox Code Playgroud)
runOcr 是发生 OCR 的函数,但是我删除了 OCR 代码。
| 归档时间: |
|
| 查看次数: |
344 次 |
| 最近记录: |