Я изучаю ARCore использованная литература, Развивать, делаю курс из Coursera, читаю, понимаю и учусь на Образцы.
Но мне все еще не хватает определения с некоторыми примерами реального использования.
Что такое сеанс? Каждый раз, когда мне нужно использовать ARCore, мне нужен сеанс? К сеансу всегда подключена камера, поэтому я могу видеть и рисовать / обрабатывать свои 3D-модели на экране? Могу ли я сделать это без сеанса?
У камеры есть getPose, а у Frame есть GetPose, в чем разница между ними?
Я думал разделить эти вопросы, но почему-то знаю, что все они связаны. Сессии, CameraAr, кадр и поза.
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, receiveArFrames
that allow access toARCamera
image and device Pose.In order to use ARCore you need an
ArSession
. ARCore doesn't render 3D models (Renderables
). This job is forSceneform
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 может включать вложенные классы:
Augmented Faces
)Config
)camera focus
)lighting estimation
)plane detection
)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
represents a virtual camera, which determines the perspective through which the scene is viewed. If the camera is part of anArSceneView
, then the camera automatically tracks the Camera Pose from ARCore. ARCamera is a long-lived object and the properties of camera are updated every timeSession.update()
is called.Camera
class provides information about the camera that is used to capture images and additional info inside eachArFrame
.
Пример кода:
// Shared camera access with ARCore
sharedSession = new Session(this, EnumSet.of(Session.Feature.SHARED_CAMERA))
sharedCamera = sharedSession.getSharedCamera();
cameraId = sharedSession.getCameraConfig().getCameraId();
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
andARAnchors
can change significantly to maintain appropriate relative positions of the physical locations they represent.These changes mean that everyArFrame
should be considered to be in a completely unique world coordinate space. The numerical coordinates ofARAnchors
and theARCamera
should never be used outside the rendering frame during which they were retrieved.Every
ArFrame
stores the following info about ARCore's state::
Пример кода:
private void onUpdateFrame(FrameTime frameTime) {
Frame frame = arFragment.getArSceneView().getArFrame();
// .............
}