ARCore – Session、Frame、Camera 和 Pose [英] ARCore – Session, Frame, Camera and Pose
问题描述
我正在研究 ARCore
代码示例:
private Session mSession;Config config = new Config(mSession);如果(!mSession.isSupported(配置)){showSnackbarMessage(这款手机不支持 AR", true);}mSession.configure(config);
还有 Session 的配置可以包含嵌套类:
- Config.AugmentedFaceMode(选择
Augmented Faces
子系统的行为) - Config.CloudAnchorMode(
Config
中的云锚点模式) - Config.FocusMode(选择
camera focus
子系统所需的行为) - Config.LightEstimationMode(选择
光照估计
子系统的行为) - Config.PlaneFindingMode(选择
plane detection
子系统的行为) - Config.UpdateMode(选择
update()
的行为)
#关于姿势
<块引用>Pose
表示从一个坐标空间到另一个坐标空间的不可变刚性变换.正如所有 ARCore API 提供的那样,姿势总是描述从对象的局部坐标空间到世界坐标空间的转换.变换是使用围绕原点的四元数旋转和平移来定义的.
代码示例:
float[] position = { 0, 0, -2.2 };//{ x, y, z } 位置float[] 旋转 = { 0, 0, 0, 1 };//{ x, y, z, w } 四元数旋转会话会话 = arFragment.getArSceneView().getSession();锚点 myAnchor = session.createAnchor(new Pose(position, rotation));
#关于 ARCamera
<块引用>ARCamera
代表一个虚拟相机,它决定了观察场景的视角.如果相机是 ArSceneView
的一部分,则相机会自动跟踪来自 ARCore 的相机姿势.ARCamera 是一个长期存在的对象,每次调用 Session.update()
时都会更新相机的属性.Camera
类提供有关用于捕获图像的相机的信息以及每个 ArFrame
内的附加信息.
代码示例:
//与 ARCore 共享相机访问sharedSession = new Session(this, EnumSet.of(Session.Feature.SHARED_CAMERA))sharedCamera = sharedSession.getSharedCamera();cameraId = sharedSession.getCameraConfig().getCameraId();
#关于ArFrame
<块引用>当 ARCore 对环境的理解发生变化时,它会调整其世界模型以保持一致.发生这种情况时,ARCamera
和 ARAnchors
的数字位置(坐标)会发生显着变化,以保持它们所代表的物理位置的适当相对位置.这些变化意味着每个 ArFrame
应该被认为是在一个完全唯一的世界坐标空间.ARAnchors
和 ARCamera
的数字坐标不应在检索它们的渲染帧之外使用.
<块引用>
每个ArFrame
都存储了以下有关 ARCore 状态的信息::
- RGB 图像本身
- 跟踪状态
- 相机相对于世界的姿势
- 估计的照明参数
- 有关对象更新的信息(如点云)
代码示例:
private void onUpdateFrame(FrameTime frameTime) {帧 frame = arFragment.getArSceneView().getArFrame();//.....................}
此外,您可以阅读这篇有用的帖子.
I'm studying the ARCore References, Develop, make the course from Coursera, and read, understood and learn from the Samples.
But I still missing some definition with some real use examples.
What is a session? Every time that I need a ARCore use I need a session? Session always has a camera connect so I can see and draw/renderer my 3D models in the screen? Can I do this without a Session?
Camera has a getPose and Frame has a GetPose, what are the diferences between they?
I thought about make this questions split but somehow I know that they are all connected. Sessions, CameraAr, Frame and Pose.
#About 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, 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.
Code's example:
private Session mSession;
Config config = new Config(mSession);
if (!mSession.isSupported(config)) {
showSnackbarMessage("This phone doesn't support AR", true);
}
mSession.configure(config);
Also Session's configuration can include nested classes:
- Config.AugmentedFaceMode (Selects the behaviour of
Augmented Faces
subsystem) - Config.CloudAnchorMode (The cloud anchor mode in
Config
) - Config.FocusMode (Selects the desired behaviour of the
camera focus
subsystem) - Config.LightEstimationMode (Select the behaviour of the
lighting estimation
subsystem) - Config.PlaneFindingMode (Select the behaviour of the
plane detection
subsystem) - Config.UpdateMode (Selects the behaviour of
update()
)
#About Pose
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.
Code's example:
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));
#About ARCamera
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
.
Code's example:
// Shared camera access with ARCore
sharedSession = new Session(this, EnumSet.of(Session.Feature.SHARED_CAMERA))
sharedCamera = sharedSession.getSharedCamera();
cameraId = sharedSession.getCameraConfig().getCameraId();
#About 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
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::
- RGB image itself
- Tracking status
- The pose of the camera relative to the world
- Estimated lighting parameters
- Information on updates to objects (like Point Clouds)
Code's example:
private void onUpdateFrame(FrameTime frameTime) {
Frame frame = arFragment.getArSceneView().getArFrame();
// .............
}
Additionally, you can read this useful post.
这篇关于ARCore – Session、Frame、Camera 和 Pose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!