使用相机在React Native中捕获方盒内的区域

时间:2019-09-26 06:22:47

标签: react-native react-native-camera

this is the image of the view我想在相机屏幕上显示一个方形框,并且想要捕获该方形框内的区域,我该如何实现? 它不会扫描任何条形码或QR码,只会捕获方框内的区域,而跳过其余的所有区域。

1 个答案:

答案 0 :(得分:0)

你不能直接实现。按照以下步骤操作:

  1. 快照:this.camera.takePictureAsync({ fixOrientation: true, mirrorImage: true })

  2. 使用 ImageEditor 进行裁剪,将cropData 设置为

    const { uri, width, height } = captureImg;

    { 偏移量:{ x: 0, y: 0 }, 尺寸:{ 图像宽度,高度},显示尺寸:{ 宽度:相机尺寸.宽度,高度:相机尺寸.高度} }

  3. 现在使用框原点和大小裁剪相机大小的照片