OCR应用程序错误相机:应用程序传递了NULL曲面

时间:2019-04-23 23:46:11

标签: android android-camera android-vision

我正在使用Google的ocr应用程序的源代码。每次我在ocr演示中点击突出显示的文本时,都会使应用程序通过NULL曲面

build.gradle

android {
    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 28
        applicationId "com.mrengineer13.gratuity.free"
        compileSdkVersion 28

    }
    dataBinding {
    enabled = true
    }


    dataBinding.enabled = true

}

dependencies {
    implementation 'com.google.android.gms:play-services-vision:17.0.2'
}

}

相机源

@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start(SurfaceHolder surfaceHolder) throws IOException {
        synchronized (mCameraLock) {
           if (mCamera != null) {
               return this;
            }

            mCamera = createCamera();
            mCamera.setPreviewDisplay(surfaceHolder);
            mCamera.startPreview();

            mProcessingThread = new Thread(mFrameProcessor);
            mFrameProcessor.setActive(true);
            mProcessingThread.start();
        }
        return this;
    }

StartCamera方法

    private fun startCameraSource() {

        if (mCameraSource != null) {
            try {
                preview!!.start(mCameraSource, graphicOverlay)
            } catch (e: IOException) {
                Log.e(TAG, "Unable to start camera source.", e)
                mCameraSource!!.release()
                mCameraSource = null
            }

        }
    }

我正在使用此处找到的android ocr演示应用程序 https://github.com/googlesamples/android-vision/tree/master/visionSamples/ocr-reader

0 个答案:

没有答案