Как получить Frame (). Camera ARCore

Я пытаюсь поставить якорь прямо перед камерой на расстоянии 1 м.

Я нашел код для этого.

mAnchors.add(session.createAnchor(
frame.getCamera().getPose()
    .compose(Pose.makeTranslation(0, 0, -1f))
    .extractTranslation()))

Мой код выглядит так:

val anchor =Session(this).createAnchor(
Frame().camera.pose.compose(Pose.makeTranslation(0f,0f,-1f)))

Проблема в конструкторе Frame (). Компилятор выдает ошибку:

"Невозможно получить доступ": он защищен / защищен и упакован / в Frame '

Есть ли способ инициализировать Frame (). Camera или я что-то делаю не так?


person radekdob    schedule 03.04.2019    source источник


Ответы (1)


вы не инициализируете фрейм. Вы получаете это от сеанса

ты делаешь это примерно так

@Override

  public void onDrawFrame(GL10 gl) {

    // Clear screen to notify driver it should not load any pixels from previous frame.

    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);



    if (session == null) {

      return;

    }

    // Notify ARCore session that the view size changed so that the perspective matrix and

    // the video background can be properly adjusted.

    displayRotationHelper.updateSessionIfNeeded(session);



    try {

      session.setCameraTextureName(backgroundRenderer.getTextureId());



      // Obtain the current frame from ARSession. When the configuration is set to

      // UpdateMode.BLOCKING (it is by default), this will throttle the rendering to the

      // camera framerate.

      Frame frame = session.update();
    } catch (Throwable t) {

      // Avoid crashing the application due to unhandled exceptions.

      Log.e(TAG, "Exception on the OpenGL thread", t);

    }
}
person Fixus    schedule 04.04.2019