OpenCV / Android BufferQueue Error: Surface Texture Has Been Abandoned

后端 未结 1 784
刺人心
刺人心 2021-01-12 17:28

New to Android and OpenCV. Been trying to to implement code from new book, Mastering OpenCV with Practical Computer Vision Projects. The app basically renders carto

1条回答
  •  清酒与你
    2021-01-12 18:21

    This issue was workarounded in OpenCV some time ago.

    Not sure if it is application or OS bug. The problem is that call to Bitmap.createBitmap detaches SurfaceTexture object used for visualization.

    The workaround was to modify the setupCamera method of the base View class and change

    try {
        setPreview();
    } catch (IOException e) {
        Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
    }
    
    /* Notify that the preview is about to be started and deliver preview size */
    onPreviewStarted(params.getPreviewSize().width, params.getPreviewSize().height);
    

    to

    /* Notify that the preview is about to be started and deliver preview size */
    onPreviewStarted(params.getPreviewSize().width, params.getPreviewSize().height);
    
    try {
        setPreview();
    } catch (IOException e) {
        Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
    }
    

    (the order of lines is changed)

    0 讨论(0)
提交回复
热议问题