代码之家  ›  专栏  ›  技术社区  ›  diogenesgg

RNCamera文本识别在纵向模式下失败

  •  0
  • diogenesgg  · 技术社区  · 7 年前

    我正在开发一个应用程序,使用React Native Camera、RNCamera和弹出模式。

    顺便说一句,文本识别功能只适用于Android。

    在纵向模式下,它只检测每个检测事件上的单个或双字符,如“o”、“ic”。

    当我旋转到横向模式时,它工作得很好。

    以下是我如何处理事件并呈现它:

    onTextRecognized = ({textBlocks}) => this.setState({ detectedTexts: textBlocks.map(b => b.value) })
    
    renderDetectedText() {
        return (
          <View style={[styles.facesContainer,{left: 10, top:"50%"}]}>
            <Text style={styles.flipText}>{this.state.detectedTexts.join("\n")}</Text>
          </View>
        )
      }
    renderCamera() {
    <RNCamera
      ref={ref => {this.camera = ref;}}
      style={{flex: 1}}
      type={this.state.type}
      flashMode={this.state.flash}
      autoFocus={this.state.autoFocus}
      zoom={this.state.zoom}
      whiteBalance={this.state.whiteBalance}
      ratio={this.state.ratio}
      onTextRecognized={this.onTextRecognized}
      focusDepth={this.state.depth}
      permissionDialogTitle={'Permission to use camera'}
      permissionDialogMessage={'We need your permission to use your camera phone'}>
      {this.renderDetectedText()}
    </RNCamera>
    }
    

    A正在使用真正的Android 7.0设备测试int

    这是 link 对于React Native Community问题Github页面。

    1 回复  |  直到 7 年前
        1
  •  0
  •   diogenesgg    7 年前

    org.reactnative.camera.RNCameraView

      @Override
      public void onFramePreview(CameraView cameraView, byte[] data, int width, int height, int rotation) {
        int correctRotation = RNCameraViewHelper.getCorrectCameraRotation(rotation, getFacing());
        int correctWidth = width;
        int correctHeight = height;
        byte[] correctData = data;
        //if (correctRotation == 90) {
        //  correctWidth = height;
        //  correctHeight = width;
        //  correctData = rotateImage(data, correctHeight, correctWidth);
        //}
        if (mShouldScanBarCodes && !barCodeScannerTaskLock && cameraView instanceof BarCodeScannerAsyncTaskDelegate) {
        //...
      }