ARCore - сеанс, кадр, камера и поза

Я изучаю ARCore использованная литература, Развивать, делаю курс из Coursera, читаю, понимаю и учусь на Образцы.

Но мне все еще не хватает определения с некоторыми примерами реального использования.

Что такое сеанс? Каждый раз, когда мне нужно использовать ARCore, мне нужен сеанс? К сеансу всегда подключена камера, поэтому я могу видеть и рисовать / обрабатывать свои 3D-модели на экране? Могу ли я сделать это без сеанса?

У камеры есть getPose, а у Frame есть GetPose, в чем разница между ними?

Я думал разделить эти вопросы, но почему-то знаю, что все они связаны. Сессии, CameraAr, кадр и поза.

Пользовательский скаляр GraphQL
Пользовательский скаляр GraphQL
Листовые узлы системы типов GraphQL называются скалярами. Достигнув скалярного типа, невозможно спуститься дальше по иерархии типов. Скалярный тип...
Как вычислять биты и понимать побитовые операторы в Java - объяснение с примерами
Как вычислять биты и понимать побитовые операторы в Java - объяснение с примерами
В компьютерном программировании биты играют важнейшую роль в представлении и манипулировании данными на двоичном уровне. Побитовые операции...
Поднятие тревоги для долго выполняющихся методов в Spring Boot
Поднятие тревоги для долго выполняющихся методов в Spring Boot
Приходилось ли вам сталкиваться с требованиями, в которых вас могли попросить поднять тревогу или выдать ошибку, когда метод Java занимает больше...
Полный курс Java для разработчиков веб-сайтов и приложений
Полный курс Java для разработчиков веб-сайтов и приложений
Получите сертификат Java Web и Application Developer, используя наш курс.
5
0
2 351
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Об ArSession

ArSession is the most crucial element in AR puzzle. Session manages AR system state and handles the session lifecycle. Session class is the main entry point to the ARCore API. This class allows the user to create a session, configure it, start or stop it and, most importantly, receive ArFrames that allow access to ARCamera image and device Pose.

In order to use ARCore you need an ArSession. ARCore doesn't render 3D models (Renderables). This job is for Sceneform framework.

Пример кода:

private Session mSession;
Config config = new Config(mSession);

if (!mSession.isSupported(config)) {
    showSnackbarMessage("This phone doesn't support AR", true);
}
mSession.configure(config);

Также конфигурация Session может включать вложенные классы:

  • Config.AugmentedFaceMode (выбирает поведение подсистемы Augmented Faces)
  • Config.CloudAnchorMode (режим привязки к облаку в Config)
  • Config.FocusMode (выбирает желаемое поведение подсистемы camera focus)
  • Config.LightEstimationMode (Выбрать поведение подсистемы lighting estimation)
  • Config.PlaneFindingMode (Выбрать поведение подсистемы plane detection)
  • Config.UpdateMode (выбирает поведение update())

О позе

Pose represents an immutable rigid transformation from one coordinate space to another. As provided from all ARCore APIs, Poses always describe the transformation from object's local coordinate space to the world coordinate space. The transformation is defined using a quaternion rotation about the origin followed by a translation.

Пример кода:

float[] position = { 0, 0, -2.2 };          //  { x, y, z } position 
float[] rotation = { 0, 0, 0, 1 };          //  { x, y, z, w } quaternion rotation

Session session = arFragment.getArSceneView().getSession();
Anchor myAnchor = session.createAnchor(new Pose(position, rotation));

О ARCamera

ARCamera represents a virtual camera, which determines the perspective through which the scene is viewed. If the camera is part of an ArSceneView, then the camera automatically tracks the Camera Pose from ARCore. ARCamera is a long-lived object and the properties of camera are updated every time Session.update() is called. Camera class provides information about the camera that is used to capture images and additional info inside each ArFrame.

Пример кода:

// Shared camera access with ARCore

sharedSession = new Session(this, EnumSet.of(Session.Feature.SHARED_CAMERA))
sharedCamera = sharedSession.getSharedCamera();
cameraId = sharedSession.getCameraConfig().getCameraId();

О ArFrame

When ARCore's understanding of the environment changes, it adjusts its model of the world to keep things consistent. When this happens, the numerical location (coordinates) of the ARCamera and ARAnchors can change significantly to maintain appropriate relative positions of the physical locations they represent.These changes mean that every ArFrame should be considered to be in a completely unique world coordinate space. The numerical coordinates of ARAnchors and the ARCamera should never be used outside the rendering frame during which they were retrieved.

Every ArFrame stores the following info about ARCore's state::

  • Само изображение RGB
  • Статус отслеживания
  • Поза фотоаппарата относительно мира
  • Расчетные параметры освещения
  • Информация об обновлениях объектов (например, облаков точек)

Пример кода:

private void onUpdateFrame(FrameTime frameTime) {

    Frame frame = arFragment.getArSceneView().getArFrame();

    // .............
}

Другие вопросы по теме