CameraParameters Class

This type is an EasyAR Sense API in C#: CameraParameters . Some descriptions may not apply to Unity environment on this page.

Some parts of the Sense API may have already been wrapped into Unity components, and directly usages may not be necessary.

Description

Camera parameters, including image size, focal length, principal point, camera type and camera rotation against natural orientation.


Methods

size

C#

public virtual Vec2I size()

Image size.

focalLength

C#

public virtual Vec2F focalLength()

Focal length, the distance from effective optical center to CCD plane, divided by unit pixel density in width and height directions. The unit is pixel.

principalPoint

C#

public virtual Vec2F principalPoint()

Principal point, coordinates of the intersection point of principal axis on CCD plane against the left-top corner of the image. The unit is pixel.

cameraModelType

C#

public virtual CameraModelType cameraModelType()

Optics model camera used.

cameraDeviceType

C#

public virtual CameraDeviceType cameraDeviceType()

Camera device type. Default, back or front camera. On desktop devices, there are only default cameras. On mobile devices, there is a differentiation between back and front cameras.

cameraOrientation

C#

public virtual int cameraOrientation()

Angles rotation required to rotate clockwise and display camera image on device with natural orientation. The range is [0, 360).

For Android phones and some Android tablets, this value is 90 degrees.

For Android eye-wear and some Android tablets, this value is 0 degrees.

For all current iOS devices, this value is 90 degrees.

createWithDefaultIntrinsics

C#

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

Creates CameraParameters with default camera intrinsics. Default intrinsics are calculated by image size, which is not very precise.

tryCreateWithCustomIntrinsics

C#

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

Creates CameraParameters with custom camera intrinsics. Refer to CameraModelType to see the support of different camera models.

Note: Use this interface with caution. Incorrect input data may cause a fail, resulting in a null return.”

getResized

C#

public virtual CameraParameters getResized( Vec2I imageSize)

Get equivalent CameraParameters for a different camera image size.

imageOrientation

C#

public virtual int imageOrientation(int screenRotation)

Calculates the angle required to rotate the camera image clockwise to align it with the screen.

screenRotation is the angle of rotation of displaying screen image against device natural orientation in clockwise in degrees.

For iOS(UIInterfaceOrientationPortrait as natural orientation):

  • UIInterfaceOrientationPortrait: rotation = 0

  • UIInterfaceOrientationLandscapeRight: rotation = 90

  • UIInterfaceOrientationPortraitUpsideDown: rotation = 180

  • UIInterfaceOrientationLandscapeLeft: rotation = 270

For Android:

  • Surface.ROTATION_0 = 0

  • Surface.ROTATION_90 = 90

  • Surface.ROTATION_180 = 180

  • Surface.ROTATION_270 = 270

imageHorizontalFlip

C#

public virtual bool imageHorizontalFlip(bool manualHorizontalFlip)

Calculates whether the image needed to be flipped horizontally. The image is rotated, then flipped in rendering. When cameraDeviceType is front, a flip is automatically applied. Pass manualHorizontalFlip with true to add a manual flip.

projection

C#

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

Calculates the perspective projection matrix needed by virtual object rendering. The projection transforms points from camera coordinate system to clip coordinate system ([-1, 1]^4) (including rotation around z-axis). The form of perspective projection matrix is the same as OpenGL, that matrix multiply column vector of homogeneous coordinates of point on the right, ant not like Direct3D, that matrix multiply row vector of homogeneous coordinates of point on the left. But data arrangement is row-major, not like OpenGL’s column-major. Clip coordinate system and normalized device coordinate system are defined as the same as OpenGL’s default.

imageProjection

C#

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

Calculates the orthogonal projection matrix needed by camera background rendering. The projection transforms points from image quad coordinate system ([-1, 1]^2) to clip coordinate system ([-1, 1]^4) (including rotation around z-axis), with the undefined two dimensions unchanged. The form of orthogonal projection matrix is the same as OpenGL, that matrix multiply column vector of homogeneous coordinates of point on the right, ant not like Direct3D, that matrix multiply row vector of homogeneous coordinates of point on the left. But data arrangement is row-major, not like OpenGL’s column-major. Clip coordinate system and normalized device coordinate system are defined as the same as OpenGL’s default.

screenCoordinatesFromImageCoordinates

C#

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

Transforms points from image coordinate system ([0, 1]^2) to screen coordinate system ([0, 1]^2). Both coordinate system is x-left, y-down, with origin at left-top.

imageCoordinatesFromScreenCoordinates

C#

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

Transforms points from screen coordinate system ([0, 1]^2) to image coordinate system ([0, 1]^2). Both coordinate system is x-left, y-down, with origin at left-top.

equalsTo

C#

public virtual bool equalsTo(CameraParameters other)

Checks if two groups of parameters are equal.