08-ARCamera介绍

作者: 60916fc63567 | 来源:发表于2017-06-22 15:20 被阅读730次

8.1概述###

ARCamera是一个相机,它是连接虚拟场景与现实场景之间的枢纽。在ARKit中,它是捕捉现实图像的相机,在SceneKit中它又是3D虚拟世界中的相机。(一般第一人称3D游戏,主角其实就是一个3D相机,我们电脑屏幕看到的画面就是这个相机捕捉的画面)。
一般我们无需去创建一个相机,因为当我们初始化一个AR视图时,他会为我们默认创建一个相机,而且这个相机就是摄像头的位置,同时也是3D世界中的原点所在(x=0,y=0,z=0)ARCamera的API一般我们无需关心,因为ARKit会默认帮助我们配置好。

8.2 ARCamera API截图###

image.png image.png

8.3 ARCamera API源码

<pre>
/**
描述相机追踪的状态
A value describing the camera's tracking state.
*/
@available(iOS 11.0, *)
public enum __ARTrackingState : Int {

/** Tracking is not available.追踪不被允许 */
case notAvailable


/** Tracking is limited. See tracking reason for details.追踪有限,查看追踪原因的详细信息 */
case limited


/** Tracking is Normal. 正常*/
case normal

}

/**说明为什么相机的追踪状态有限的原因
A reason describing why the camera's tracking state is limited.
*/
@available(iOS 11.0, *)
public enum __ARTrackingStateReason : Int {

/** Tracking is not limited. 追踪不受限制*/
case none


/** Tracking is limited due to a excessive motion of the camera.由于相机的过度运动,追踪受到限制 */
case excessiveMotion


/** Tracking is limited due to a lack of features visible to the camera.由于缺少相机可见的功能,追踪受到限制 */
case insufficientFeatures

}

/**
A model representing the camera and its parameters.
*/
@available(iOS 11.0, *)
open class ARCamera : NSObject, NSCopying {

/**4*4矩阵表示相机位置,同ARAnchor
 The transformation matrix that defines the camera's rotation and translation in world coordinates.

在世界坐标系中定义相机旋转和平移的变换矩阵。
*/
open var transform: matrix_float4x4 { get }

/**相机方向(旋转)的矢量欧拉角
   分别是x/y/z
 The camera's orientation defined as Euler angles.
 
 @dicussion The order of components in this vector matches the axes of rotation:
               1. Pitch (the x component) is the rotation about the node's x-axis (in radians)
               2. Yaw   (the y component) is the rotation about the node's y-axis (in radians)
               3. Roll  (the z component) is the rotation about the node's z-axis (in radians)
            ARKit applies these rotations in the reverse order of the components:
               1. first roll
               2. then yaw
               3. then pitch
 */
open var eulerAngles: vector_float3 { get }


/**追踪运动类型
 The tracking state of the camera.
 */
open var __trackingState: __ARTrackingState { get }


/**
 The reason for the camera's current tracking state.
 */
open var __trackingStateReason: __ARTrackingStateReason { get }


/**相机曲率(笔者有点费解,反复揣摩应该是与焦距相关参数)
 The camera intrinsics.
 @discussion The matrix has the following contents:
 fx 0   px
 0  fy  py
 0  0   1
 fx and fy are the focal length in pixels.
 px and py are the coordinates of the principal point in pixels.
 The origin is at the center of the upper-left pixel.
 */
open var intrinsics: matrix_float3x3 { get }


/**摄像头分辨率
 The camera image resolution in pixels.
 */
open var imageResolution: CGSize { get }


/**投影矩阵
 The projection matrix of the camera.
*/
open var projectionMatrix: matrix_float4x4 { get }


/**创建相机投影矩阵
 Creates a projection matrix for the camera given rendering parameters.
 
 @discussion The projection matrix returned provides an aspect fill and rotation for the provided viewport size and orientation.
 @param viewportSize Viewport size.
 @param orientation Viewport orientation.
 @param zNear Near depth limit.
 @param zFar Far depth limit.
 */
open func projectionMatrix(withViewportSize viewportSize: CGSize, orientation: UIInterfaceOrientation, zNear: CGFloat, zFar: CGFloat) -> matrix_float4x4

}
<pre>

相关文章

  • 08-ARCamera介绍

    8.1概述### ARCamera是一个相机,它是连接虚拟场景与现实场景之间的枢纽。在ARKit中,它是捕捉现实图...

  • Runtime介绍---术语介绍

    1. 什么是Runtime Runtime又叫运行时,是一套C语言的API。 我们平时编写的OC代码,底层都是基于...

  • 介绍

    万物终有一天会消失殆尽,诸神出卖黎明,光明为黑暗所湮灭,日月皆痕,海潮鸣泣,幼雏嚎啕,生灵涂炭。 托里奥世纪第20...

  • 介绍😊

    大家好,我是beth,初入简书,不邀自来,还请各位见谅! 先说说我是怎么想着来的吧?这不是刚过了一个寒假嘛...

  • 介绍

    在这个世界上还有三个家族他们不受各个国家联合国管。但他们身上有着使命分别是帝国家族曲国家族圣国家族。他们隐藏在一个...

  • 介绍

    云轩:主角,星罗帝国的二皇子。从小就不能练气,被人们称为废物。直到12岁的时候,自己的武魂觉醒才能练气,双...

  • 介绍

    万花阁 神秘至极的组织,亦正亦邪。万花阁的人行动隐秘,至今未被发现所在地。听说组成成员均以花来命名。所到之处,皆留...

  • 介绍

    此书命曰元.八洲传。属九洲四传第二部。第一部,上古往事。上古往事乃元八洲传外传。前两部为战胜心魔,而第三部,大梦...

  • 介绍

    千肆篇 7月的天气燥热,但在红杏阁里这份燥热就别有一番风味。漫天的胭脂水粉的香味变成了调味剂,女人们千姿百媚,在...

  • 介绍

    该文集属于收录文集,里面的内容不全是本人创作,有收录个人喜欢的内容。 *(偏个人向)

网友评论

    本文标题:08-ARCamera介绍

    本文链接:https://www.haomeiwen.com/subject/shsfcxtx.html