ARCore –会话,框架,相机和姿势 [英] ARCore – Session, Frame, Camera and Pose
问题描述
我正在研究ARCore 参考文献, Coursera ,并从示例.
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.
什么是会话?每次我需要使用ARCore时,都需要一个会话吗?会话始终连接相机,这样我就可以在屏幕上查看和绘制/渲染我的3D模型吗?我可以在没有会话的情况下做到这一点吗?
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?
相机有一个getPose,框架有一个GetPose,它们之间有什么区别?
Camera has a getPose and Frame has a GetPose, what are the diferences between they?
我考虑过将这些问题分开,但不知何故我知道它们都已连接.会话,CameraAr,帧和姿势.
I thought about make this questions split but somehow I know that they are all connected. Sessions, CameraAr, Frame and Pose.
推荐答案
关于ArSession
ArSession
是AR拼图中最关键的元素 .会话管理AR系统状态并处理会话生命周期. 会话类是ARCore API的主要入口点.此类允许用户创建会话,配置会话,启动或停止会话,最重要的是,接收允许访问ARCamera
图片和设备 Pose 的ArFrames
.
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.
要使用ARCore,您需要一个ArSession
. ARCore不会渲染3D模型(Renderables
).这项工作是针对Sceneform
框架的.
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的配置可以包括嵌套类:
Also Session's configuration can include nested classes:
- Config.AugmentedFaceMode (选择
Augmented Faces
子系统的行为) - Config.CloudAnchorMode (
Config
中的云锚模式) - Config.FocusMode (选择
camera focus
子系统的所需行为) - Config.LightEstimationMode (选择
lighting estimation
子系统的行为) - Config.PlaneFindingMode (选择
plane detection
子系统的行为) - Config.UpdateMode (选择
update()
的行为)
- 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()
)
Pose
表示从一个坐标空间到另一个坐标空间的不变的刚性变换.正如所有ARCore API提供的那样,姿势总是描述从对象的局部坐标空间到世界坐标空间的转换.使用围绕原点的四元数旋转定义一个变换,然后进行平移.
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
代表一个虚拟摄像机,该摄像机确定查看场景的视角.如果相机是ArSceneView
的一部分,则相机会自动跟踪ARCore的相机姿势. ARCamera是一个长期存在的对象,每次调用Session.update()
时,相机的属性都会更新.Camera
类提供有关用于捕获图像的相机的信息以及每个ArFrame
内部的其他信息.
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();
关于ArFrame
当ARCore对环境的理解发生变化时,它会调整其世界模型以保持事物的一致性.发生这种情况时,
ARCamera
和ARAnchors
的数字位置(坐标)会发生很大变化,以保持它们代表的物理位置的适当相对位置.这些变化意味着应将每个ArFrame
都视为一个完整的位置.唯一的世界坐标空间.ARAnchors
和ARCamera
的数字坐标永远不能在检索它们的渲染框架之外使用.
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.
每个 ArFrame
存储有关ARCore状态的以下信息:
Every ArFrame
stores the following info about ARCore's state::
- RGB图像本身
- 跟踪状态
- 相机相对于世界的姿势
- 估计的照明参数
- 有关对象(如点云)更新的信息
- 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)
代码示例:
private void onUpdateFrame(FrameTime frameTime) {
Frame frame = arFragment.getArSceneView().getArFrame();
// .............
}
这篇关于ARCore –会话,框架,相机和姿势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!