CameraParameters Class

Description

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

Constructor

C

void easyar_CameraParameters__ctor(easyar_Vec2I imageSize, easyar_Vec2F focalLength, easyar_Vec2F principalPoint, easyar_CameraDeviceType cameraDeviceType, int cameraOrientation, easyar_CameraParameters * * Return)

C++

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

Java

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

Kotlin

constructor(imageSize: Vec2I, focalLength: Vec2F, principalPoint: Vec2F, cameraDeviceType: Int, cameraOrientation: Int)

Objective-C

+ (easyar_CameraParameters *) create:(easyar_Vec2I *)imageSize focalLength:(easyar_Vec2F *)focalLength principalPoint:(easyar_Vec2F *)principalPoint cameraDeviceType:(easyar_CameraDeviceType)cameraDeviceType cameraOrientation:(int)cameraOrientation

Swift

public convenience init(_ imageSize: Vec2I, _ focalLength: Vec2F, _ principalPoint: Vec2F, _ cameraDeviceType: CameraDeviceType, _ cameraOrientation: Int32)

C#

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

size

图像大小。

C

easyar_Vec2I easyar_CameraParameters_size(const easyar_CameraParameters * This)

C++

Vec2I size()

Java

public @Nonnull Vec2I size()

Kotlin

fun size(): Vec2I

Objective-C

- (easyar_Vec2I *)size

Swift

public func size() -> Vec2I

C#

public virtual Vec2I size()

focalLength

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

C

easyar_Vec2F easyar_CameraParameters_focalLength(const easyar_CameraParameters * This)

C++

Vec2F focalLength()

Java

public @Nonnull Vec2F focalLength()

Kotlin

fun focalLength(): Vec2F

Objective-C

- (easyar_Vec2F *)focalLength

Swift

public func focalLength() -> Vec2F

C#

public virtual Vec2F focalLength()

principalPoint

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

C

easyar_Vec2F easyar_CameraParameters_principalPoint(const easyar_CameraParameters * This)

C++

Vec2F principalPoint()

Java

public @Nonnull Vec2F principalPoint()

Kotlin

fun principalPoint(): Vec2F

Objective-C

- (easyar_Vec2F *)principalPoint

Swift

public func principalPoint() -> Vec2F

C#

public virtual Vec2F principalPoint()

cameraDeviceType

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

C

easyar_CameraDeviceType easyar_CameraParameters_cameraDeviceType(const easyar_CameraParameters * This)

C++

CameraDeviceType cameraDeviceType()

Java

public int cameraDeviceType()

Kotlin

fun cameraDeviceType(): Int

Objective-C

- (easyar_CameraDeviceType)cameraDeviceType

Swift

public func cameraDeviceType() -> CameraDeviceType

C#

public virtual CameraDeviceType cameraDeviceType()

cameraOrientation

camera图像在设备的自然方向上显示时需要顺时针旋转的角度。范围为[0, 360)。

Android手机和部分Android平板为90度。

Android眼镜和部分Android平板为0度。

现有iOS设备均为90度。

C

int easyar_CameraParameters_cameraOrientation(const easyar_CameraParameters * This)

C++

int cameraOrientation()

Java

public int cameraOrientation()

Kotlin

fun cameraOrientation(): Int

Objective-C

- (int)cameraOrientation

Swift

public func cameraOrientation() -> Int32

C#

public virtual int cameraOrientation()

createWithDefaultIntrinsics

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

C

void easyar_CameraParameters_createWithDefaultIntrinsics(easyar_Vec2I imageSize, easyar_CameraDeviceType cameraDeviceType, int cameraOrientation, easyar_CameraParameters * * Return)

C++

static std::shared_ptr<CameraParameters> createWithDefaultIntrinsics(Vec2I imageSize, CameraDeviceType cameraDeviceType, int cameraOrientation)

Java

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

Kotlin

companion object fun createWithDefaultIntrinsics(imageSize: Vec2I, cameraDeviceType: Int, cameraOrientation: Int): CameraParameters

Objective-C

+ (easyar_CameraParameters *)createWithDefaultIntrinsics:(easyar_Vec2I *)imageSize cameraDeviceType:(easyar_CameraDeviceType)cameraDeviceType cameraOrientation:(int)cameraOrientation

Swift

public static func createWithDefaultIntrinsics(_ imageSize: Vec2I, _ cameraDeviceType: CameraDeviceType, _ cameraOrientation: Int32) -> CameraParameters

C#

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

getResized

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

C

void easyar_CameraParameters_getResized(easyar_CameraParameters * This, easyar_Vec2I imageSize, easyar_CameraParameters * * Return)

C++

std::shared_ptr<CameraParameters> getResized(Vec2I imageSize)

Java

public @Nonnull CameraParameters getResized(@Nonnull Vec2I imageSize)

Kotlin

fun getResized(imageSize: Vec2I): CameraParameters

Objective-C

- (easyar_CameraParameters *)getResized:(easyar_Vec2I *)imageSize

Swift

public func getResized(_ imageSize: Vec2I) -> CameraParameters

C#

public virtual CameraParameters getResized(Vec2I imageSize)

imageOrientation

计算图像需要相对于屏幕进行顺时针旋转以和屏幕对齐所需要的角度。

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

C

int easyar_CameraParameters_imageOrientation(const easyar_CameraParameters * This, int screenRotation)

C++

int imageOrientation(int screenRotation)

Java

public int imageOrientation(int screenRotation)

Kotlin

fun imageOrientation(screenRotation: Int): Int

Objective-C

- (int)imageOrientation:(int)screenRotation

Swift

public func imageOrientation(_ screenRotation: Int32) -> Int32

C#

public virtual int imageOrientation(int screenRotation)

imageHorizontalFlip

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

C

bool easyar_CameraParameters_imageHorizontalFlip(const easyar_CameraParameters * This, bool manualHorizontalFlip)

C++

bool imageHorizontalFlip(bool manualHorizontalFlip)

Java

public boolean imageHorizontalFlip(boolean manualHorizontalFlip)

Kotlin

fun imageHorizontalFlip(manualHorizontalFlip: Boolean): Boolean

Objective-C

- (bool)imageHorizontalFlip:(bool)manualHorizontalFlip

Swift

public func imageHorizontalFlip(_ manualHorizontalFlip: Bool) -> Bool

C#

public virtual bool imageHorizontalFlip(bool manualHorizontalFlip)

projection

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

C

easyar_Matrix44F easyar_CameraParameters_projection(const easyar_CameraParameters * This, float nearPlane, float farPlane, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip)

C++

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

Java

public @Nonnull Matrix44F projection(float nearPlane, float farPlane, float viewportAspectRatio, int screenRotation, boolean combiningFlip, boolean manualHorizontalFlip)

Kotlin

fun projection(nearPlane: Float, farPlane: Float, viewportAspectRatio: Float, screenRotation: Int, combiningFlip: Boolean, manualHorizontalFlip: Boolean): Matrix44F

Objective-C

- (easyar_Matrix44F *)projection:(float)nearPlane farPlane:(float)farPlane viewportAspectRatio:(float)viewportAspectRatio screenRotation:(int)screenRotation combiningFlip:(bool)combiningFlip manualHorizontalFlip:(bool)manualHorizontalFlip

Swift

public func projection(_ nearPlane: Float, _ farPlane: Float, _ viewportAspectRatio: Float, _ screenRotation: Int32, _ combiningFlip: Bool, _ manualHorizontalFlip: Bool) -> Matrix44F

C#

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

imageProjection

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

C

easyar_Matrix44F easyar_CameraParameters_imageProjection(const easyar_CameraParameters * This, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip)

C++

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

Java

public @Nonnull Matrix44F imageProjection(float viewportAspectRatio, int screenRotation, boolean combiningFlip, boolean manualHorizontalFlip)

Kotlin

fun imageProjection(viewportAspectRatio: Float, screenRotation: Int, combiningFlip: Boolean, manualHorizontalFlip: Boolean): Matrix44F

Objective-C

- (easyar_Matrix44F *)imageProjection:(float)viewportAspectRatio screenRotation:(int)screenRotation combiningFlip:(bool)combiningFlip manualHorizontalFlip:(bool)manualHorizontalFlip

Swift

public func imageProjection(_ viewportAspectRatio: Float, _ screenRotation: Int32, _ combiningFlip: Bool, _ manualHorizontalFlip: Bool) -> Matrix44F

C#

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

screenCoordinatesFromImageCoordinates

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

C

easyar_Vec2F easyar_CameraParameters_screenCoordinatesFromImageCoordinates(const easyar_CameraParameters * This, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, easyar_Vec2F imageCoordinates)

C++

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

Java

public @Nonnull Vec2F screenCoordinatesFromImageCoordinates(float viewportAspectRatio, int screenRotation, boolean combiningFlip, boolean manualHorizontalFlip, @Nonnull Vec2F imageCoordinates)

Kotlin

fun screenCoordinatesFromImageCoordinates(viewportAspectRatio: Float, screenRotation: Int, combiningFlip: Boolean, manualHorizontalFlip: Boolean, imageCoordinates: Vec2F): Vec2F

Objective-C

- (easyar_Vec2F *)screenCoordinatesFromImageCoordinates:(float)viewportAspectRatio screenRotation:(int)screenRotation combiningFlip:(bool)combiningFlip manualHorizontalFlip:(bool)manualHorizontalFlip imageCoordinates:(easyar_Vec2F *)imageCoordinates

Swift

public func screenCoordinatesFromImageCoordinates(_ viewportAspectRatio: Float, _ screenRotation: Int32, _ combiningFlip: Bool, _ manualHorizontalFlip: Bool, _ imageCoordinates: Vec2F) -> Vec2F

C#

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

imageCoordinatesFromScreenCoordinates

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

C

easyar_Vec2F easyar_CameraParameters_imageCoordinatesFromScreenCoordinates(const easyar_CameraParameters * This, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, easyar_Vec2F screenCoordinates)

C++

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

Java

public @Nonnull Vec2F imageCoordinatesFromScreenCoordinates(float viewportAspectRatio, int screenRotation, boolean combiningFlip, boolean manualHorizontalFlip, @Nonnull Vec2F screenCoordinates)

Kotlin

fun imageCoordinatesFromScreenCoordinates(viewportAspectRatio: Float, screenRotation: Int, combiningFlip: Boolean, manualHorizontalFlip: Boolean, screenCoordinates: Vec2F): Vec2F

Objective-C

- (easyar_Vec2F *)imageCoordinatesFromScreenCoordinates:(float)viewportAspectRatio screenRotation:(int)screenRotation combiningFlip:(bool)combiningFlip manualHorizontalFlip:(bool)manualHorizontalFlip screenCoordinates:(easyar_Vec2F *)screenCoordinates

Swift

public func imageCoordinatesFromScreenCoordinates(_ viewportAspectRatio: Float, _ screenRotation: Int32, _ combiningFlip: Bool, _ manualHorizontalFlip: Bool, _ screenCoordinates: Vec2F) -> Vec2F

C#

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

equalsTo

判断两组参数是否相等。

C

bool easyar_CameraParameters_equalsTo(const easyar_CameraParameters * This, easyar_CameraParameters * other)

C++

bool equalsTo(std::shared_ptr<CameraParameters> other)

Java

public boolean equalsTo(@Nonnull CameraParameters other)

Kotlin

fun equalsTo(other: CameraParameters): Boolean

Objective-C

- (bool)equalsTo:(easyar_CameraParameters *)other

Swift

public func equalsTo(_ other: CameraParameters) -> Bool

C#

public virtual bool equalsTo(CameraParameters other)