CameraSource takePicture崩溃

时间:2018-08-19 14:38:43

标签: java android google-vision

我正在使用Play Services愿景:“ com.google.android.gms:play-services-vision:15.0.2”

当我为CameraSource对象调用方法“ takePicture”时,应用程序经常崩溃

mCameraSource.takePicture(null, new CameraSource.PictureCallback() {
    @Override
    public void onPictureTaken(byte[] bytes) {
        try {
            FileUtils.saveImage(bytes, String.valueOf(PHOTO_NAME), "png");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
});

日志

  

08-19 17:10:3​​8.283 30456-30456 / ru.facereg.facerecognitiontest   E / AndroidRuntime:致命异常:主要过程:   ru.facereg.facerecognitiontest,PID:30456 java.lang.RuntimeException:   takePicture失败       在android.hardware.Camera.native_takePicture(本机方法)       在android.hardware.Camera.takePicture(Camera.java:1489)       在com.google.android.gms.vision.CameraSource.takePicture(未知来源:26)       在ru.facereg.facerecognitiontest.FaceDetectionActivity.onCreatePicture(FaceDetectionActivity.java:114)处       在ru.facereg.facerecognitiontest.camera.GraphicOverlay.onDraw(GraphicOverlay.java:130)       在android.view.View.draw(View.java:19192)       在android.view.View.updateDisplayListIfDirty(View.java:18142)       在android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4220)       在android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4200)       在android.view.View.updateDisplayListIfDirty(View.java:18101)       在android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4220)       在android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4200)       在android.view.View.updateDisplayListIfDirty(View.java:18101)       在android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4220)       在android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4200)       在android.view.View.updateDisplayListIfDirty(View.java:18101)       在android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4220)       在android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4200)       在android.view.View.updateDisplayListIfDirty(View.java:18101)       在android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4220)       在android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4200)       在android.view.View.updateDisplayListIfDirty(View.java:18101)       在android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4220)       在android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4200)       在android.view.View.updateDisplayListIfDirty(View.java:18101)       在android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4220)       在android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4200)       在android.view.View.updateDisplayListIfDirty(View.java:18101)       在android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:669)       在android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:675)       在android.view.ThreadedRenderer.draw(ThreadedRenderer.java:783)       在android.view.ViewRootImpl.draw(ViewRootImpl.java:2992)       在android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2806)       在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2359)       在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)       在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6752)       在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:911)       在android.view.Choreographer.doCallbacks(Choreographer.java:723)       在android.view.Choreographer.doFrame(Choreographer.java:658)       在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:897)       在android.os.Handler.handleCallback(Handler.java:790)       在android.os.Handler.dispatchMessage(Handler.java:99)       在android.os.Looper.loop(Looper.java:164)       在android.app.ActivityThread.main(ActivityThread.java:6494)       在java.lang.reflect.Method.invoke(本机方法)       在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:438)       在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

我尝试了从工作线程和UI线程进行调用,但结果相似。 也许有人遇到这个问题?

0 个答案:

没有答案