Table of Contents

Class CameraParameters

命名空间
easyar
程序集
EasyAR.Sense.dll

camera参数,包括图像大小、焦距、主点、camera类型和camera相对设备自然方向的旋转角度。

public class CameraParameters : RefBase, IDisposable
继承
CameraParameters
实现
继承成员

构造函数

CameraParameters(Vec2I, Vec2F, Vec2F, CameraDeviceType, int)

public CameraParameters(Vec2I imageSize, Vec2F focalLength, Vec2F principalPoint, CameraDeviceType cameraDeviceType, int cameraOrientation)

参数

imageSize
focalLength
principalPoint
cameraDeviceType
cameraOrientation

方法

Clone()

public CameraParameters Clone()

CloneObject()

protected override object CloneObject()

cameraDeviceType()

相机设备类型。默认camera、后置camera或前置camera。桌面设备均为默认camera,移动设备区分后置camera和前置camera。

public virtual CameraDeviceType cameraDeviceType()

cameraModelType()

相机模型。

public virtual CameraModelType cameraModelType()

cameraOrientation()

camera图像在设备的自然方向上显示时需要顺时针旋转的角度。范围为[0, 360)。 Android手机和部分Android平板为90度。 Android眼镜和部分Android平板为0度。 现有iOS设备均为90度。

public virtual int cameraOrientation()

createWithDefaultIntrinsics(Vec2I, CameraDeviceType, int)

以默认相机内参创建CameraParameters。默认相机内参(焦距、主点)根据图像大小自动计算,但并不是特别准确。

public static CameraParameters createWithDefaultIntrinsics(Vec2I imageSize, CameraDeviceType cameraDeviceType, int cameraOrientation)

参数

imageSize
cameraDeviceType
cameraOrientation

equalsTo(CameraParameters)

判断两组参数是否相等。

public virtual bool equalsTo(CameraParameters other)

参数

other

focalLength()

焦距。相机的等效光心到CCD平面的距离除以宽高两个方向的单位像素密度。单位为像素。

public virtual Vec2F focalLength()

getResized(Vec2I)

获取相机图像大小改变后的等效CameraParameters。

public virtual CameraParameters getResized(Vec2I imageSize)

参数

imageSize

imageCoordinatesFromScreenCoordinates(float, int, bool, bool, Vec2F)

从屏幕坐标系([0, 1]^2)变换到图像坐标系([0, 1]^2),两个坐标系均x朝右、y朝下,原点在左上角。

public virtual Vec2F imageCoordinatesFromScreenCoordinates(float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, Vec2F screenCoordinates)

参数

viewportAspectRatio
screenRotation
combiningFlip
manualHorizontalFlip
screenCoordinates

imageHorizontalFlip(bool)

计算图像是否需要左右翻转。图像渲染时,先进行旋转,再进行翻转。当cameraDeviceType为前置摄像头时,会自动进行翻转,可在此基础上,传入manualHorizontalFlip再叠加一次手动翻转。

public virtual bool imageHorizontalFlip(bool manualHorizontalFlip)

参数

manualHorizontalFlip

imageOrientation(int)

计算图像需要相对于屏幕进行顺时针旋转以和屏幕对齐所需要的角度。 screenRotation为屏幕图像相对于自然方向顺时针旋转的角度。 对于iOS,有 * UIInterfaceOrientationPortrait: screenRotation = 0 * UIInterfaceOrientationLandscapeRight: screenRotation = 90 * UIInterfaceOrientationPortraitUpsideDown: screenRotation = 180 * UIInterfaceOrientationLandscapeLeft: screenRotation = 270 对于Android,有 * Surface.ROTATION_0: screenRotation = 0 * Surface.ROTATION_90: screenRotation = 90 * Surface.ROTATION_180: screenRotation = 180 * Surface.ROTATION_270: screenRotation = 270

public virtual int imageOrientation(int screenRotation)

参数

screenRotation

imageProjection(float, int, bool, bool)

计算渲染摄像机背景图像所需要的正交投影矩阵,将图像矩形坐标系下([-1, 1]^2)的点变换到剪裁坐标系([-1, 1]^4)中(包括绕z轴的旋转),未定义的两维保持不变。正交投影矩阵的形式和OpenGL相同,为矩阵右边乘以点的齐次坐标,而非Direct3D的矩阵左边乘以点的齐次坐标。但数据的排列方式为row-major,与OpenGL的column-major相反。剪裁坐标系和单位化设备坐标系的定义与OpenGL默认相同。

public virtual Matrix44F imageProjection(float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip)

参数

viewportAspectRatio
screenRotation
combiningFlip
manualHorizontalFlip

principalPoint()

主点。相机的主光轴在CCD平面上的交点到图像左上角的像素坐标。单位为像素。

public virtual Vec2F principalPoint()

projection(float, float, float, int, bool, bool)

计算渲染虚拟物体所需要的透视投影矩阵,将camera坐标系下的点变换到剪裁坐标系([-1, 1]^4)中(包括绕z轴的旋转)。透视投影矩阵的形式和OpenGL相同,为矩阵右边乘以点的齐次坐标的列向量,而非Direct3D的矩阵左边乘以点的齐次坐标的列向量。但数据的排列方式为row-major,与OpenGL的column-major相反。剪裁坐标系和单位化设备坐标系的定义与OpenGL默认相同。

public virtual Matrix44F projection(float nearPlane, float farPlane, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip)

参数

nearPlane
farPlane
viewportAspectRatio
screenRotation
combiningFlip
manualHorizontalFlip

screenCoordinatesFromImageCoordinates(float, int, bool, bool, Vec2F)

从图像坐标系([0, 1]^2)变换到屏幕坐标系([0, 1]^2),两个坐标系均x朝右、y朝下,原点在左上角。

public virtual Vec2F screenCoordinatesFromImageCoordinates(float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, Vec2F imageCoordinates)

参数

viewportAspectRatio
screenRotation
combiningFlip
manualHorizontalFlip
imageCoordinates

size()

图像大小。

public virtual Vec2I size()

tryCreateWithCustomIntrinsics(Vec2I, List<float>, CameraModelType, CameraDeviceType, int)

使用自定义相机内参创建CameraParameters。需要指定相机内参(焦距、主点、畸变系数)以及相机模型。相机模型支持参考CameraModelType。 注意: 谨慎使用该接口,输入数据错误可能导致创建对象失败,返回为空。

public static Optional<CameraParameters> tryCreateWithCustomIntrinsics(Vec2I imageSize, List<float> cameraParamList, CameraModelType cameraModel, CameraDeviceType cameraDeviceType, int cameraOrientation)

参数

imageSize
cameraParamList
cameraModel
cameraDeviceType
cameraOrientation