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's 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
imageSizefocalLengthprincipalPointcameraDeviceTypecameraOrientation
Methods
Clone()
public CameraParameters Clone()
Returns
CloneObject()
protected override object CloneObject()
Returns
cameraDeviceType()
Camera device type. Default camera, rear camera, or front camera. Desktop devices are all default camera, mobile devices distinguish between rear camera and front camera.
public virtual CameraDeviceType cameraDeviceType()
Returns
cameraModelType()
Camera model.
public virtual CameraModelType cameraModelType()
Returns
cameraOrientation()
The angle by which the camera image needs to be rotated clockwise to be displayed in the device's natural orientation. Range is [0, 360). For Android phones and some Android tablets, it is 90 degrees. For Android glasses and some Android tablets, it is 0 degrees. For existing iOS devices, it is 90 degrees.
public virtual int cameraOrientation()
Returns
createWithDefaultIntrinsics(Vec2I, CameraDeviceType, int)
Create CameraParameters with default intrinsic parameters. Default intrinsic parameters (focal length, principal point) are automatically calculated based on image size, but are not particularly accurate.
public static CameraParameters createWithDefaultIntrinsics(Vec2I imageSize, CameraDeviceType cameraDeviceType, int cameraOrientation)
Parameters
imageSizecameraDeviceTypecameraOrientation
Returns
equalsTo(CameraParameters)
Determine if two sets of parameters are equal.
public virtual bool equalsTo(CameraParameters other)
Parameters
other
Returns
focalLength()
Focal length. The distance from the camera's equivalent optical center to the CCD plane divided by the unit pixel density in both width and height directions. Unit is pixels.
public virtual Vec2F focalLength()
Returns
getResized(Vec2I)
Obtain the equivalent CameraParameters after changing the camera image size.
public virtual CameraParameters getResized(Vec2I imageSize)
Parameters
imageSize
Returns
imageCoordinatesFromScreenCoordinates(float, int, bool, bool, Vec2F)
Transform from screen coordinate system ([0, 1]^2) to image coordinate system ([0, 1]^2), both with x to the right, y down, origin at top-left corner.
public virtual Vec2F imageCoordinatesFromScreenCoordinates(float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, Vec2F screenCoordinates)
Parameters
viewportAspectRatioscreenRotationcombiningFlipmanualHorizontalFlipscreenCoordinates
Returns
imageHorizontalFlip(bool)
Calculate whether the image needs to be flipped horizontally. During image rendering, rotation is performed first, then flipping. When cameraDeviceType is front camera, flipping is automatically applied; on top of that, manualHorizontalFlip can be passed to add an additional manual flip.
public virtual bool imageHorizontalFlip(bool manualHorizontalFlip)
Parameters
manualHorizontalFlip
Returns
imageOrientation(int)
Calculate the angle by which the image needs to be rotated clockwise relative to the screen to align with the screen. screenRotation is the angle by which the screen image is rotated clockwise 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
Returns
imageProjection(float, int, bool, bool)
Calculate the orthographic projection matrix needed for rendering the camera background image, transforming points from the image rectangle coordinate system ([-1, 1]^2) to the clip coordinate system ([-1, 1]^4) (including rotation around the z-axis), with the undefined two dimensions unchanged. The form of the orthographic projection matrix is the same as in OpenGL, where the matrix is multiplied on the right by the homogeneous coordinate of the point, not like Direct3D where the matrix is multiplied on the left. However, the data arrangement is row-major, opposite to OpenGL's column-major. The definitions of clip coordinate system and normalized device coordinate system are the same as in OpenGL by default.
public virtual Matrix44F imageProjection(float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip)
Parameters
viewportAspectRatioscreenRotationcombiningFlipmanualHorizontalFlip
Returns
principalPoint()
Principal point. The pixel coordinates from the intersection of the camera's principal optical axis on the CCD plane to the top-left corner of the image. Unit is pixels.
public virtual Vec2F principalPoint()
Returns
projection(float, float, float, int, bool, bool)
Calculate the perspective projection matrix needed for rendering virtual objects, transforming points from the camera coordinate system to the clip coordinate system ([-1, 1]^4) (including rotation around the z-axis). The form of the perspective projection matrix is the same as in OpenGL, where the matrix is multiplied on the right by the homogeneous coordinate column vector of the point, not like Direct3D where the matrix is multiplied on the left. However, the data arrangement is row-major, opposite to OpenGL's column-major. The definitions of clip coordinate system and normalized device coordinate system are the same as in OpenGL by default.
public virtual Matrix44F projection(float nearPlane, float farPlane, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip)
Parameters
nearPlanefarPlaneviewportAspectRatioscreenRotationcombiningFlipmanualHorizontalFlip
Returns
screenCoordinatesFromImageCoordinates(float, int, bool, bool, Vec2F)
Transform from image coordinate system ([0, 1]^2) to screen coordinate system ([0, 1]^2), both with x to the right, y down, origin at top-left corner.
public virtual Vec2F screenCoordinatesFromImageCoordinates(float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, Vec2F imageCoordinates)
Parameters
viewportAspectRatioscreenRotationcombiningFlipmanualHorizontalFlipimageCoordinates
Returns
size()
Image size.
public virtual Vec2I size()
Returns
tryCreateWithCustomIntrinsics(Vec2I, List<float>, CameraModelType, CameraDeviceType, int)
Create CameraParameters with custom intrinsic parameters. Requires specifying intrinsic parameters (focal length, principal point, distortion coefficients) and camera model. Camera model support refers to CameraModelType. Note: Use this interface with caution; incorrect input data may cause object creation to fail and return null.
public static Optional<CameraParameters> tryCreateWithCustomIntrinsics(Vec2I imageSize, List<float> cameraParamList, CameraModelType cameraModel, CameraDeviceType cameraDeviceType, int cameraOrientation)
Parameters
imageSizecameraParamListcameraModelcameraDeviceTypecameraOrientation