Table of Contents

Class CameraParameters

Namespace
easyar
Assembly
EasyAR.Sense.dll

camera parameters, including image size, focal length, principal point, camera type, and the rotation angle of the camera relative to the device natural orientation.

public class CameraParameters : RefBase, IDisposable
Inheritance
CameraParameters
Implements
Inherited Members

Constructors

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

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

Parameters

imageSize
focalLength
principalPoint
cameraDeviceType
cameraOrientation

Methods

Clone()

public CameraParameters Clone()

cameraDeviceType()

Camera device type. Default camera, back camera, or front camera. Desktop devices are all default camera, while mobile devices distinguish back camera and front camera.

public virtual CameraDeviceType cameraDeviceType()

cameraModelType()

Camera model.

public virtual CameraModelType cameraModelType()

cameraOrientation()

The clockwise rotation angle required when displaying the camera image in the device natural orientation. The range is [0, 360). Android phones and some Android tablets are 90 degrees. Android glasses and some Android tablets are 0 degrees. Existing iOS devices are all 90 degrees.

public virtual int cameraOrientation()

createWithDefaultIntrinsics(Vec2I, CameraDeviceType, int)

Creates CameraParameters with default camera intrinsics. The default camera intrinsics (focal length and principal point) are automatically calculated from the image size, but they are not especially accurate.

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

Parameters

imageSize
cameraDeviceType
cameraOrientation

equalsTo(CameraParameters)

Determines whether two sets of parameters are equal.

public virtual bool equalsTo(CameraParameters other)

Parameters

other

focalLength()

Focal length. The distance from the equivalent optical center of the camera to the CCD plane divided by the unit pixel density in both width and height directions. The unit is pixels.

public virtual Vec2F focalLength()

getResized(Vec2I)

Gets equivalent CameraParameters after the camera image size changes.

public virtual CameraParameters getResized(Vec2I imageSize)

Parameters

imageSize

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

Transforms from the screen coordinate system ([0, 1]^2) to the image coordinate system ([0, 1]^2). In both coordinate systems, x points right, y points down, and the origin is at the upper-left corner.

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

Parameters

viewportAspectRatio
screenRotation
combiningFlip
manualHorizontalFlip
screenCoordinates

imageHorizontalFlip(bool)

Calculates whether the image needs horizontal flipping. During image rendering, rotation is applied first, then flipping. When cameraDeviceType is front camera, flipping is performed automatically; manualHorizontalFlip can be passed in to apply one additional manual flip on top of that.

public virtual bool imageHorizontalFlip(bool manualHorizontalFlip)

Parameters

manualHorizontalFlip

imageOrientation(int)

Calculates the clockwise angle by which the image needs to be rotated relative to the screen so it aligns with the screen. screenRotation is the clockwise rotation angle of the screen image relative to the natural orientation. For iOS: * UIInterfaceOrientationPortrait: screenRotation = 0 * UIInterfaceOrientationLandscapeRight: screenRotation = 90 * UIInterfaceOrientationPortraitUpsideDown: screenRotation = 180 * UIInterfaceOrientationLandscapeLeft: screenRotation = 270 For 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)

Parameters

screenRotation

imageProjection(float, int, bool, bool)

Calculates the orthographic projection matrix needed to render the camera background image, transforming points in the image rectangle coordinate system ([-1, 1]^2) into the clip coordinate system ([-1, 1]^4), including rotation around the z axis, while the two undefined dimensions remain unchanged. The orthographic projection matrix has the same form as OpenGL: the matrix is multiplied on the right by the homogeneous point coordinates, not multiplied on the left as in Direct3D. The data is arranged in row-major order, opposite to OpenGL's column-major order. The definitions of the clip coordinate system and normalized device coordinate system are the same as OpenGL defaults.

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

Parameters

viewportAspectRatio
screenRotation
combiningFlip
manualHorizontalFlip

principalPoint()

Principal point. The pixel coordinates from the intersection point of the camera principal optical axis on the CCD plane to the upper-left corner of the image. The unit is pixels.

public virtual Vec2F principalPoint()

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

Calculates the perspective projection matrix needed to render virtual objects, transforming points in the camera coordinate system into the clip coordinate system ([-1, 1]^4), including rotation around the z axis. The perspective projection matrix has the same form as OpenGL: the matrix is multiplied on the right by the column vector of homogeneous point coordinates, not multiplied on the left as in Direct3D. The data is arranged in row-major order, opposite to OpenGL's column-major order. The definitions of the clip coordinate system and normalized device coordinate system are the same as OpenGL defaults.

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

Parameters

nearPlane
farPlane
viewportAspectRatio
screenRotation
combiningFlip
manualHorizontalFlip

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

Transforms from the image coordinate system ([0, 1]^2) to the screen coordinate system ([0, 1]^2). In both coordinate systems, x points right, y points down, and the origin is at the upper-left corner.

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

Parameters

viewportAspectRatio
screenRotation
combiningFlip
manualHorizontalFlip
imageCoordinates

size()

Image size.

public virtual Vec2I size()

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

Creates CameraParameters with custom camera intrinsics. Camera intrinsics (focal length, principal point, distortion coefficients) and camera model must be specified. For supported camera models, refer to CameraModelType. Note: use this interface carefully. Incorrect input data may cause object creation to fail and return empty.

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

Parameters

imageSize
cameraParamList
cameraModel
cameraDeviceType
cameraOrientation