Class CameraParameters
- 命名空間
- easyar
- 組件
- EasyAR.Sense.dll
camera參數,包括圖像大小、焦距、主點、camera類型和camera相對設備自然方向的旋轉角度。
public class CameraParameters : RefBase, IDisposable
- 繼承
-
CameraParameters
- 實作
- 繼承成員
建構函式
CameraParameters(Vec2I, Vec2F, Vec2F, CameraDeviceType, int)
public CameraParameters(Vec2I imageSize, Vec2F focalLength, Vec2F principalPoint, CameraDeviceType cameraDeviceType, int cameraOrientation)
參數
imageSizefocalLengthprincipalPointcameraDeviceTypecameraOrientation
方法
Clone()
public CameraParameters Clone()
CloneObject()
protected override object CloneObject()
cameraDeviceType()
相機設備類型。預設camera、後置camera或前置camera。桌面設備均為預設camera,移動設備區分後置camera和前置camera。
public virtual CameraDeviceType cameraDeviceType()
cameraModelType()
相機模型。
public virtual CameraModelType cameraModelType()
cameraOrientation()
camera圖像在設備的自然方向上顯示時需要順時針旋轉的角度。範圍為[0,360)。 Android手機和部分Android平板為90度。 Android眼鏡和部分Android平板為0度。 現有iOS設備均為90度。
public virtual int cameraOrientation()
createWithDefaultIntrinsics(Vec2I, CameraDeviceType, int)
以預設相機內參創建CameraParameters。預設相機內參(焦距、主點)根據圖像大小自動計算,但並不是特別準確。
public static CameraParameters createWithDefaultIntrinsics(Vec2I imageSize, CameraDeviceType cameraDeviceType, int cameraOrientation)
參數
imageSizecameraDeviceTypecameraOrientation
equalsTo(CameraParameters)
判斷兩組參數是否相等。
public virtual bool equalsTo(CameraParameters other)
參數
other
focalLength()
焦距。相機的等效光心到CCD平面的距離除以寬高兩個方向的單位像素密度。單位為像素。
public virtual Vec2F focalLength()
getResized(Vec2I)
獲取相機圖像大小改變後的等效CameraParameters。
public virtual CameraParameters getResized(Vec2I imageSize)
參數
imageSize
imageCoordinatesFromScreenCoordinates(float, int, bool, bool, Vec2F)
從屏幕坐標系([0,1]^2)變換到圖像坐標系([0,1]^2),兩個坐標系均x朝右、y朝下,原點在左上角。
public virtual Vec2F imageCoordinatesFromScreenCoordinates(float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, Vec2F screenCoordinates)
參數
viewportAspectRatioscreenRotationcombiningFlipmanualHorizontalFlipscreenCoordinates
imageHorizontalFlip(bool)
計算圖像是否需要左右翻轉。圖像渲染時,先進行旋轉,再進行翻轉。當cameraDeviceType為前置鏡頭時,會自動進行翻轉,可在此基礎上,傳入manualHorizontalFlip再疊加一次手動翻轉。
public virtual bool imageHorizontalFlip(bool manualHorizontalFlip)
參數
manualHorizontalFlip
imageOrientation(int)
計算圖像需要相對於屏幕進行順時針旋轉以和屏幕對齊所需要的角度。 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
public virtual int imageOrientation(int screenRotation)
參數
screenRotation
imageProjection(float, int, bool, bool)
計算渲染攝像機背景圖像所需要的正交投影矩陣,將圖像矩形坐標系下([-1,1]^2)的點變換到剪裁坐標系([-1,1]^4)中(包括繞z軸的旋轉),未定義的兩維保持不變。正交投影矩陣的形式和OpenGL相同,為矩陣右邊乘以點的齊次坐標,而非Direct3D的矩陣左邊乘以點的齊次坐標。但數據的排列方式為row-major,與OpenGL的column-major相反。剪裁坐標系和單位化設備坐標系的定義與OpenGL預設相同。
public virtual Matrix44F imageProjection(float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip)
參數
viewportAspectRatioscreenRotationcombiningFlipmanualHorizontalFlip
principalPoint()
主點。相機的主光軸在CCD平面上的交點到圖像左上角的像素坐標。單位為像素。
public virtual Vec2F principalPoint()
projection(float, float, float, int, bool, bool)
計算渲染虛擬物體所需要的透視投影矩陣,將camera坐標系下的點變換到剪裁坐標系([-1,1]^4)中(包括繞z軸的旋轉)。透視投影矩陣的形式和OpenGL相同,為矩陣右邊乘以點的齊次坐標的列向量,而非Direct3D的矩陣左邊乘以點的齊次坐標的列向量。但數據的排列方式為row-major,與OpenGL的column-major相反。剪裁坐標系和單位化設備坐標系的定義與OpenGL預設相同。
public virtual Matrix44F projection(float nearPlane, float farPlane, float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip)
參數
nearPlanefarPlaneviewportAspectRatioscreenRotationcombiningFlipmanualHorizontalFlip
screenCoordinatesFromImageCoordinates(float, int, bool, bool, Vec2F)
從圖像坐標系([0,1]^2)變換到屏幕坐標系([0,1]^2),兩個坐標系均x朝右、y朝下,原點在左上角。
public virtual Vec2F screenCoordinatesFromImageCoordinates(float viewportAspectRatio, int screenRotation, bool combiningFlip, bool manualHorizontalFlip, Vec2F imageCoordinates)
參數
viewportAspectRatioscreenRotationcombiningFlipmanualHorizontalFlipimageCoordinates
size()
圖像大小。
public virtual Vec2I size()
tryCreateWithCustomIntrinsics(Vec2I, List<float>, CameraModelType, CameraDeviceType, int)
使用自訂義相機內參創建CameraParameters。需要指定相機內參(焦距、主點、畸變係數)以及相機模型。相機模型支援參考CameraModelType。 注意:謹慎使用該介面,輸入數據錯誤可能導致創建物件失敗,返回為空。
public static Optional<CameraParameters> tryCreateWithCustomIntrinsics(Vec2I imageSize, List<float> cameraParamList, CameraModelType cameraModel, CameraDeviceType cameraDeviceType, int cameraOrientation)
參數
imageSizecameraParamListcameraModelcameraDeviceTypecameraOrientation