Class CameraParameters
- Namespace
- easyar
- Assembly
- EasyAR.Sense.dll
Camera parameters, including image size, focal length, principal point, camera type, and 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 cameras, while mobile devices distinguish between rear and front cameras.
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 when displayed in the device's natural orientation. Range is [0, 360). Android phones and some Android tablets are 90 degrees. Android glasses and some Android tablets are 0 degrees. All existing iOS devices are 90 degrees.
public virtual int cameraOrientation()
Returns
createWithDefaultIntrinsics(Vec2I, CameraDeviceType, int)
Create CameraParameters with default camera intrinsic parameters. Default camera intrinsic parameters (focal length, principal point) are automatically calculated based on the 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 the width and height directions. Unit is pixels.
public virtual Vec2F focalLength()
Returns
getResized(Vec2I)
Get the equivalent CameraParameters after the camera image size changes.
public virtual CameraParameters getResized(Vec2I imageSize)
Parameters
imageSize
Returns
imageCoordinatesFromScreenCoordinates(float, int, bool, bool, Vec2F)
Transform from the screen coordinate system ([0, 1]^2) to the image coordinate system ([0, 1]^2). Both coordinate systems have x to the right, y downward, with the origin at the 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. When rendering the image, rotation is performed first, then flipping. If cameraDeviceType is the front camera, flipping is automatically performed. On this basis, manualHorizontalFlip can be passed to add an additional manual flip.
public virtual bool imageHorizontalFlip(bool manualHorizontalFlip)
Parameters
manualHorizontalFlip
Returns
imageOrientation(int)
Calculate the angle required for the image 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, there are * UIInterfaceOrientationPortrait: screenRotation = 0 * UIInterfaceOrientationLandscapeRight: screenRotation = 90 * UIInterfaceOrientationPortraitUpsideDown: screenRotation = 180 * UIInterfaceOrientationLandscapeLeft: screenRotation = 270 For Android, there are * 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 required 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). Undefined dimensions remain unchanged. The orthographic projection matrix has the same form as OpenGL, where the matrix is multiplied on the right by the homogeneous coordinates of the point, unlike Direct3D where the matrix is multiplied on the left by the homogeneous coordinates of the point. However, the data arrangement is row-major, opposite to OpenGL's column-major. The definitions of the clip coordinate system and normalized device coordinate system are the same as OpenGL's 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 required 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 perspective projection matrix has the same form as OpenGL, where the matrix is multiplied on the right by the column vector of the homogeneous coordinates of the point, unlike Direct3D where the matrix is multiplied on the left by the column vector of the homogeneous coordinates of the point. However, the data arrangement is row-major, opposite to OpenGL's column-major. The definitions of the clip coordinate system and normalized device coordinate system are the same as OpenGL's 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 the image coordinate system ([0, 1]^2) to the screen coordinate system ([0, 1]^2). Both coordinate systems have x to the right, y downward, with the origin at the 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 camera intrinsic parameters. Need to specify camera intrinsic parameters (focal length, principal point, distortion coefficients) and camera model. The camera model supports reference to CameraModelType. Note: Use this interface with caution. Incorrect input data may cause the 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