com.google.ar.core.exceptions.notyetavailableexception on frame.acquirecameraimage()

i5desfxk  于 2021-07-11  发布在  Java
关注(0)|答案(0)|浏览(438)

案例1:这是代码

private void onUpdateListener(FrameTime frameTime) {
    try
    {
        Frame frame = nodeArFragment.getArSceneView().getArFrame();

        if (frame == null) {
            return;
        }

        computingDetection = true;

        Image androidMediaImage = frame.acquireCameraImage();

        Bitmap rotatedImage = Utilities.getBitmap(androidMediaImage,detector);
        imageView.setImageBitmap(rotatedImage);

        new Thread(() -> {
            List<Classifier.Recognition> results = null;

              results = detector.recognizeImage(rotatedImage);

      //  drawBoxes(results);
        }).start();

    } catch (NotYetAvailableException e) {
        Log.e(TAG, "NotYetAvailableException", e);
        e.printStackTrace();
    } catch (DeadlineExceededException e){
        Log.e(TAG, "DeadlineExceededException", e);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

当这是代码时,我得到了这个错误

FAILED_PRECONDITION: 
    ARCoreError: third_party/arcore/ar/core/cpu_image_manager.cc:252
     [type.googleapis.com/util.ErrorSpacePayload='ArStatusErrorSpace::AR_ERROR_NOT_YET_AVAILABLE']
2020-11-21 06:53:23.389 24361-24361/com.example.nodetypesarcore E/ContentValues: NotYetAvailableException
    com.google.ar.core.exceptions.NotYetAvailableException
        at java.lang.reflect.Constructor.newInstance0(Native Method)

案例2:当我删除线程时,我得到第一帧的错误,但它不会停止应用程序,并从下一帧继续工作!但是在前面的例子中,应用程序在收到错误时停止!

try
    {
        Frame frame = nodeArFragment.getArSceneView().getArFrame();

        if (frame == null) {
            return;
        }

        computingDetection = true;

        Image androidMediaImage = frame.acquireCameraImage();

        Bitmap rotatedImage = Utilities.getBitmap(androidMediaImage,detector);
        imageView.setImageBitmap(rotatedImage);

        List<Classifier.Recognition> results = null;

        results = detector.recognizeImage(rotatedImage);

    } catch (NotYetAvailableException e) {
        Log.e(TAG, "NotYetAvailableException", e);
        e.printStackTrace();
    } catch (DeadlineExceededException e){
        Log.e(TAG, "DeadlineExceededException", e);
    } catch (Exception e) {
        e.printStackTrace();
    }

但是如果我把线取下来,它会很迟钝,但它能正常工作。那么,我如何拥有一个线程并避免错误呢?谢谢您!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题