OpenCV for Unity 2.6.4
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.10.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.UnityUtils.ARUtils Class Reference

AR utilities. More...

Static Public Member Functions

static float CalculateDistance (float frustumSize, float fov)
 Calculate distance. https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html.
 
static float CalculateFOVAngle (float frustumSize, float distance)
 Calculate FOV angle. https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html.
 
static float CalculateFrustumSize (float distance, float fov)
 Calculate frustum size. https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html.
 
static Matrix4x4 CalculateProjectionMatrixFromCameraMatrixValues (float fx, float fy, float cx, float cy, float width, float height, float near, float far)
 Calculate projection matrix from camera matrix values. (OpenCV coordinate system to OpenGL coordinate system)
 
static Matrix4x4 CameraMatrixValuesFromCalculateProjectionMatrix (Matrix4x4 projectionMatrix, float width, float height, float fovV)
 Calculate camera matrix values from projection matrix. (OpenGL coordinate system to OpenCV coordinate system)
 
static void ComposeMatrix (Vector3 localPosition, Quaternion localRotation, Vector3 localScale, out Matrix4x4 matrix)
 Compose TRS matrix from position, rotation and scale.
 
static PoseData ConvertMatrixToPoseData (ref Matrix4x4 matrix)
 Convertes transform matrix to PoseData.
 
static Matrix4x4 ConvertPoseDataToMatrix (ref PoseData poseData, bool toLeftHandCoordinateSystem=false)
 Convertes PoseData to transform matrix.
 
static Quaternion ConvertRvecToRot (IList< double > rvec)
 Convertes rvec value to rotation transform.
 
static PoseData ConvertRvecTvecToPoseData (IList< double > rvec, IList< double > tvec)
 Convertes rvec and tvec value to PoseData.
 
static Vector3 ConvertTvecToPos (IList< double > tvec)
 Convertes tvec value to position transform.
 
static Dictionary< int, PoseDataCreatePoseDataDict (IList< int > ids, IList< double > rvecs, IList< double > tvecs)
 Creates pose data dictionary.
 
static void DecomposeMatrix (ref Matrix4x4 matrix, out Vector3 localPosition, out Quaternion localRotation, out Vector3 localScale)
 Extract position, rotation and scale from TRS matrix.
 
static Quaternion ExtractRotationFromMatrix (ref Matrix4x4 matrix)
 Extract rotation quaternion from transform matrix.
 
static Vector3 ExtractScaleFromMatrix (ref Matrix4x4 matrix)
 Extract scale from transform matrix.
 
static Vector3 ExtractTranslationFromMatrix (ref Matrix4x4 matrix)
 Extract translation from transform matrix.
 
static void LowpassPoseData (ref PoseData oldPose, ref PoseData newPose, float posThreshold, float rotThreshold)
 Performs a lowpass check on the position and rotation in newPose, comparing them to oldPose.
 
static void LowpassPoseDataDict (Dictionary< int, PoseData > oldDict, Dictionary< int, PoseData > newDict, float posThreshold, float rotThreshold)
 Performs a lowpass check on the position and rotation of each marker in newDict, comparing them to those in oldDict.
 
static void SetTransformFromMatrix (Transform transform, ref Matrix4x4 matrix)
 Set transform component from TRS matrix.
 

Detailed Description

AR utilities.

Member Function Documentation

◆ CalculateDistance()

static float OpenCVForUnity.UnityUtils.ARUtils.CalculateDistance ( float frustumSize,
float fov )
static

Calculate distance. https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html.

Parameters
frustumHeightOne side size of a frustum.
fovField of view. (horizontal or vertical direction)
Returns
Distance.

◆ CalculateFOVAngle()

static float OpenCVForUnity.UnityUtils.ARUtils.CalculateFOVAngle ( float frustumSize,
float distance )
static

Calculate FOV angle. https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html.

Parameters
frustumHeightOne side size of a frustum.
distanceDistance.
Returns
FOV angle.

◆ CalculateFrustumSize()

static float OpenCVForUnity.UnityUtils.ARUtils.CalculateFrustumSize ( float distance,
float fov )
static

Calculate frustum size. https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html.

Parameters
distanceDistance.
fovField of view. (horizontal or vertical direction)
Returns
Frustum height.

◆ CalculateProjectionMatrixFromCameraMatrixValues()

static Matrix4x4 OpenCVForUnity.UnityUtils.ARUtils.CalculateProjectionMatrixFromCameraMatrixValues ( float fx,
float fy,
float cx,
float cy,
float width,
float height,
float near,
float far )
static

Calculate projection matrix from camera matrix values. (OpenCV coordinate system to OpenGL coordinate system)

Parameters
fxFocal length x.
fyFocal length y.
cxImage center point x.(principal point x)
cyImage center point y.(principal point y)
widthImage width.
heightImage height.
nearThe near clipping plane distance.
farThe far clipping plane distance.
Returns
Projection matrix.

◆ CameraMatrixValuesFromCalculateProjectionMatrix()

static Matrix4x4 OpenCVForUnity.UnityUtils.ARUtils.CameraMatrixValuesFromCalculateProjectionMatrix ( Matrix4x4 projectionMatrix,
float width,
float height,
float fovV )
static

Calculate camera matrix values from projection matrix. (OpenGL coordinate system to OpenCV coordinate system)

Parameters
projectionMatrixProjection matrix.
widthImage width.
heightImage height.
fovVVertical field of view.
Returns
Camera matrix values. (fx = matrx.m00, fy = matrx.m11, cx = matrx.m02, cy = matrx.m12)

◆ ComposeMatrix()

static void OpenCVForUnity.UnityUtils.ARUtils.ComposeMatrix ( Vector3 localPosition,
Quaternion localRotation,
Vector3 localScale,
out Matrix4x4 matrix )
static

Compose TRS matrix from position, rotation and scale.

Parameters
localPositionPosition.
localRotationRotation.
localScaleScale.
matrixTransform matrix.

◆ ConvertMatrixToPoseData()

static PoseData OpenCVForUnity.UnityUtils.ARUtils.ConvertMatrixToPoseData ( ref Matrix4x4 matrix)
static

Convertes transform matrix to PoseData.

Parameters
matrixTransform matrix.
Returns
PoseData.

◆ ConvertPoseDataToMatrix()

static Matrix4x4 OpenCVForUnity.UnityUtils.ARUtils.ConvertPoseDataToMatrix ( ref PoseData poseData,
bool toLeftHandCoordinateSystem = false )
static

Convertes PoseData to transform matrix.

Parameters
posedataPoseData.
toLeftHandCoordinateSystemDetermines if convert the transformation matrix to the left-hand coordinate system.
Returns
Transform matrix.

◆ ConvertRvecToRot()

static Quaternion OpenCVForUnity.UnityUtils.ARUtils.ConvertRvecToRot ( IList< double > rvec)
static

Convertes rvec value to rotation transform.

Parameters
tvecRvec.
Returns
Rotation.

◆ ConvertRvecTvecToPoseData()

static PoseData OpenCVForUnity.UnityUtils.ARUtils.ConvertRvecTvecToPoseData ( IList< double > rvec,
IList< double > tvec )
static

Convertes rvec and tvec value to PoseData.

Parameters
tvecRvec.
tvecTvec.
Returns
PoseData.

◆ ConvertTvecToPos()

static Vector3 OpenCVForUnity.UnityUtils.ARUtils.ConvertTvecToPos ( IList< double > tvec)
static

Convertes tvec value to position transform.

Parameters
tvecTvec.
Returns
Position.

◆ CreatePoseDataDict()

static Dictionary< int, PoseData > OpenCVForUnity.UnityUtils.ARUtils.CreatePoseDataDict ( IList< int > ids,
IList< double > rvecs,
IList< double > tvecs )
static

Creates pose data dictionary.

Parameters
idsids.
rvecsRvecs.
tvecsTvecs.
Returns
PoseData dictionary.

◆ DecomposeMatrix()

static void OpenCVForUnity.UnityUtils.ARUtils.DecomposeMatrix ( ref Matrix4x4 matrix,
out Vector3 localPosition,
out Quaternion localRotation,
out Vector3 localScale )
static

Extract position, rotation and scale from TRS matrix.

Parameters
matrixTransform matrix. This parameter is passed by reference to improve performance; no changes will be made to it.
localPositionPosition.
localRotationRotation.
localScaleScale.

◆ ExtractRotationFromMatrix()

static Quaternion OpenCVForUnity.UnityUtils.ARUtils.ExtractRotationFromMatrix ( ref Matrix4x4 matrix)
static

Extract rotation quaternion from transform matrix.

Parameters
matrixTransform matrix. This parameter is passed by reference to improve performance; no changes will be made to it.
Returns
Quaternion representation of rotation transform.

◆ ExtractScaleFromMatrix()

static Vector3 OpenCVForUnity.UnityUtils.ARUtils.ExtractScaleFromMatrix ( ref Matrix4x4 matrix)
static

Extract scale from transform matrix.

Parameters
matrixTransform matrix. This parameter is passed by reference to improve performance; no changes will be made to it.
Returns
Scale vector.

◆ ExtractTranslationFromMatrix()

static Vector3 OpenCVForUnity.UnityUtils.ARUtils.ExtractTranslationFromMatrix ( ref Matrix4x4 matrix)
static

Extract translation from transform matrix.

Parameters
matrixTransform matrix. This parameter is passed by reference to improve performance; no changes will be made to it.
Returns
Translation offset.

◆ LowpassPoseData()

static void OpenCVForUnity.UnityUtils.ARUtils.LowpassPoseData ( ref PoseData oldPose,
ref PoseData newPose,
float posThreshold,
float rotThreshold )
static

Performs a lowpass check on the position and rotation in newPose, comparing them to oldPose.

Parameters
oldPoseOld PoseData.
newPoseNew PoseData.
posThresholdPositon threshold.
rotThresholdRotation threshold.

◆ LowpassPoseDataDict()

static void OpenCVForUnity.UnityUtils.ARUtils.LowpassPoseDataDict ( Dictionary< int, PoseData > oldDict,
Dictionary< int, PoseData > newDict,
float posThreshold,
float rotThreshold )
static

Performs a lowpass check on the position and rotation of each marker in newDict, comparing them to those in oldDict.

Parameters
oldDictOld dictionary.
newDictNew dictionary.
posThresholdPositon threshold.
rotThresholdRotation threshold.

◆ SetTransformFromMatrix()

static void OpenCVForUnity.UnityUtils.ARUtils.SetTransformFromMatrix ( Transform transform,
ref Matrix4x4 matrix )
static

Set transform component from TRS matrix.

Parameters
transformTransform component.
matrixTransform matrix. This parameter is passed by reference to improve performance; no changes will be made to it.

The documentation for this class was generated from the following file: