我有一个捕捉银行卡的功能,我如何裁剪相机面具内的卡的图像。我使用react-native-camera拍摄照片,并使用BarcodeMask创建masks.Here,代码如下:
<View style={{flex: 1}}>
<RNCamera
ref={ref => {
this.camera = ref;
}}
style={
this.state.step == 3 ? styles.camview : styles.preview
}
type={this.state.typeCamera}
autoFocus={RNCamera.Constants.AutoFocus.on}
captureAudio={false}
onFacesDetected={res =>
this.checkStatusFace(res.faces[0])
}
onFaceDetectionError={res => {
console.log('loi vao', res);
}}
faceDetectionClassifications={
RNCamera.Constants.FaceDetection.Classifications.all
}
/>
<BarcodeMask
width={350}
height={250}
showAnimatedLine={false}
/>
<TouchableOpacity
onPress={this.takePicture.bind(this)}
style={styles.capture}>
<FontAwesome5 name="camera" size={40} />
</View>
takePicture = async () => {
console.log('Da chup anh');
if (this.camera) {
const options = {quality: 0.4, base64: true};
const data = await this.camera.takePictureAsync(options);
this.setState({
uriImage: data.base64,
viewImage: true,
});
console.log(data);
}
};发布于 2021-06-23 18:55:40
你必须使用第三方库来裁剪图像。您可以使用诸如https://github.com/callstack/react-native-image-editor之类的工具来实现所需的功能。
https://stackoverflow.com/questions/68098181
复制相似问题