Making a demo for text Recognition with camera using library react-native-camera but camera is not opening
DONE ALL THESE STEPS:
npm install react-native-camera --save
react-native link react-native-camera
In XCode, in the project navigator, select your project. Add libRNCamera.a to your project's Build Phases ➜ Link Binary With Libraries
Click RNCamera.xcodeproj in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic').
In the Search Paths section, look for Header Search Paths and make sure it contains both $(SRCROOT)/../../react-native/React and $(SRCROOT)/../../../React - mark both as recursive
import { RNCamera } from 'react-native-camera';
camerascan(){
console.log("camscan=====")
return(
<RNCamera
ref={ref => {
this.camera = ref;
}}
defaultTouchToFocus
mirrorImage={false}
captureAudio={false}
style={{
flex: 1,
justifyContent: 'space-between',
alignItems: 'center',
height: Dimensions.get('window').height,
width: Dimensions.get('window').width,
}}
permissionDialogTitle={'Permission to use camera'}
permissionDialogMessage={'We need your permission to use your camera phone'}
>
<View
style={{
height: 56,
backgroundColor: 'transparent',
alignSelf: 'flex-end',
}}
>
<TouchableOpacity onPress={this.takePicture.bind(this)}>
<Text style={styles.capture}> [CAPTURE CARD]</Text>
</TouchableOpacity>
</View>
</RNCamera>
);
}
takePicture = async function() {
console.log("takePicture=====")
if (this.camera) {
// const options = { quality: 0.5, base64: true };
// const data = await this.camera.takePictureAsync(options)
const data = await this.camera.takePictureAsync();
console.warn('takePicture ', data);
// this.detectText(data.base64)
}
};
No error but camera is not opening.
Done gave the runtime permissions for camera
import Permissions from 'react-native-permissions'
componentDidMount()
{
this.determinePermission();
}
determinePermission(){
Permissions.request('camera', { type: 'always' }).then(response => {
this.setState({ locationPermission: response })
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With