11using HoloLensCameraStream ;
2- using HoloLensWithOpenCVForUnity . UnityUtils . Helper ;
2+ using HoloLensWithOpenCVForUnity . UnityIntegration . Helper . Source2Mat ;
33using OpenCVForUnity . Calib3dModule ;
44using OpenCVForUnity . CoreModule ;
55using OpenCVForUnity . ImgprocModule ;
66using OpenCVForUnity . ObjdetectModule ;
7- using OpenCVForUnity . UnityUtils ;
8- using OpenCVForUnity . UnityUtils . Helper ;
7+ using OpenCVForUnity . UnityIntegration ;
8+ using OpenCVForUnity . UnityIntegration . Helper . Optimization ;
9+ using OpenCVForUnity . UnityIntegration . Helper . Source2Mat ;
910using System ;
1011using System . Collections . Generic ;
1112using System . IO ;
1415using UnityEngine ;
1516using UnityEngine . SceneManagement ;
1617using UnityEngine . UI ;
18+ using static OpenCVForUnity . UnityIntegration . OpenCVARUtils ;
1719
1820namespace HoloLensWithOpenCVForUnityExample
1921{
@@ -255,9 +257,9 @@ protected void Start()
255257 imageOptimizationHelper = gameObject . GetComponent < ImageOptimizationHelper > ( ) ;
256258 webCamTextureToMatHelper = gameObject . GetComponent < HLCameraStream2MatHelper > ( ) ;
257259#if WINDOWS_UWP && ! DISABLE_HOLOLENSCAMSTREAM_API
258- webCamTextureToMatHelper . frameMatAcquired += OnFrameMatAcquired ;
260+ webCamTextureToMatHelper . FrameMatAcquired += OnFrameMatAcquired ;
259261#endif
260- webCamTextureToMatHelper . outputColorFormat = Source2MatHelperColorFormat . GRAY ;
262+ webCamTextureToMatHelper . OutputColorFormat = Source2MatHelperColorFormat . GRAY ;
261263 webCamTextureToMatHelper . Initialize ( ) ;
262264 }
263265
@@ -276,7 +278,7 @@ public void OnWebCamTextureToMatHelperInitialized()
276278 if ( enableDownScale )
277279 {
278280 downScaleMat = imageOptimizationHelper . GetDownScaleMat ( grayMat ) ;
279- DOWNSCALE_RATIO = imageOptimizationHelper . downscaleRatio ;
281+ DOWNSCALE_RATIO = imageOptimizationHelper . DownscaleRatio ;
280282 }
281283 else
282284 {
@@ -296,7 +298,7 @@ public void OnWebCamTextureToMatHelperInitialized()
296298 //Debug.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
297299
298300
299- DebugUtils . AddDebugStr ( webCamTextureToMatHelper . outputColorFormat . ToString ( ) + " " + webCamTextureToMatHelper . GetWidth ( ) + " x " + webCamTextureToMatHelper . GetHeight ( ) + " : " + webCamTextureToMatHelper . GetFPS ( ) ) ;
301+ DebugUtils . AddDebugStr ( webCamTextureToMatHelper . OutputColorFormat . ToString ( ) + " " + webCamTextureToMatHelper . GetWidth ( ) + " x " + webCamTextureToMatHelper . GetHeight ( ) + " : " + webCamTextureToMatHelper . GetFPS ( ) ) ;
300302 if ( enableDownScale )
301303 DebugUtils . AddDebugStr ( "enableDownScale = true: " + DOWNSCALE_RATIO + " / " + width + " x " + height ) ;
302304
@@ -431,13 +433,13 @@ public void OnWebCamTextureToMatHelperInitialized()
431433
432434
433435 // If the WebCam is front facing, flip the Mat horizontally. Required for successful detection of AR markers.
434- if ( webCamTextureToMatHelper . IsFrontFacing ( ) && ! webCamTextureToMatHelper . flipHorizontal )
436+ if ( webCamTextureToMatHelper . IsFrontFacing ( ) && ! webCamTextureToMatHelper . FlipHorizontal )
435437 {
436- webCamTextureToMatHelper . flipHorizontal = true ;
438+ webCamTextureToMatHelper . FlipHorizontal = true ;
437439 }
438- else if ( ! webCamTextureToMatHelper . IsFrontFacing ( ) && webCamTextureToMatHelper . flipHorizontal )
440+ else if ( ! webCamTextureToMatHelper . IsFrontFacing ( ) && webCamTextureToMatHelper . FlipHorizontal )
439441 {
440- webCamTextureToMatHelper . flipHorizontal = false ;
442+ webCamTextureToMatHelper . FlipHorizontal = false ;
441443 }
442444
443445 rgbMat4preview = new Mat ( ) ;
@@ -528,7 +530,7 @@ public void OnFrameMatAcquired(Mat grayMat, Matrix4x4 projectionMatrix, Matrix4x
528530 if ( enableDownScale )
529531 {
530532 downScaleMat = imageOptimizationHelper . GetDownScaleMat ( grayMat ) ;
531- DOWNSCALE_RATIO = imageOptimizationHelper . downscaleRatio ;
533+ DOWNSCALE_RATIO = imageOptimizationHelper . DownscaleRatio ;
532534 }
533535 else
534536 {
@@ -591,10 +593,10 @@ public void OnFrameMatAcquired(Mat grayMat, Matrix4x4 projectionMatrix, Matrix4x
591593 double [ ] tvecArr = new double [ 3 ] ;
592594 tvec . get ( 0 , 0 , tvecArr ) ;
593595 tvecArr [ 2 ] /= DOWNSCALE_RATIO ;
594- PoseData poseData = ARUtils . ConvertRvecTvecToPoseData ( rvecArr , tvecArr ) ;
596+ PoseData poseData = OpenCVARUtils . ConvertRvecTvecToPoseData ( rvecArr , tvecArr ) ;
595597
596598 // Create transform matrix.
597- transformationM = Matrix4x4 . TRS ( poseData . pos , poseData . rot , Vector3 . one ) ;
599+ transformationM = Matrix4x4 . TRS ( poseData . Pos , poseData . Rot , Vector3 . one ) ;
598600
599601 lock ( sync )
600602 {
@@ -653,7 +655,7 @@ public void OnFrameMatAcquired(Mat grayMat, Matrix4x4 projectionMatrix, Matrix4x
653655
654656 if ( displayCameraPreview && rgbMat4preview != null )
655657 {
656- Utils . matToTexture2D ( rgbMat4preview , texture ) ;
658+ OpenCVMatUtils . MatToTexture2D ( rgbMat4preview , texture ) ;
657659 rgbMat4preview . Dispose ( ) ;
658660 }
659661
@@ -674,7 +676,7 @@ public void OnFrameMatAcquired(Mat grayMat, Matrix4x4 projectionMatrix, Matrix4x
674676 }
675677 else
676678 {
677- ARUtils . SetTransformFromMatrix ( arGameObject . transform , ref ARM ) ;
679+ OpenCVARUtils . SetTransformFromMatrix ( arGameObject . transform , ref ARM ) ;
678680 }
679681 }
680682 }
@@ -731,7 +733,7 @@ void Update()
731733 if ( enableDownScale )
732734 {
733735 downScaleMat = imageOptimizationHelper . GetDownScaleMat ( grayMat ) ;
734- DOWNSCALE_RATIO = imageOptimizationHelper . downscaleRatio ;
736+ DOWNSCALE_RATIO = imageOptimizationHelper . DownscaleRatio ;
735737 }
736738 else
737739 {
@@ -826,10 +828,10 @@ private void DetectARUcoMarker()
826828 double [ ] tvecArr = new double [ 3 ] ;
827829 tvec . get ( 0 , 0 , tvecArr ) ;
828830 tvecArr [ 2 ] /= DOWNSCALE_RATIO ;
829- PoseData poseData = ARUtils . ConvertRvecTvecToPoseData ( rvecArr , tvecArr ) ;
831+ PoseData poseData = OpenCVARUtils . ConvertRvecTvecToPoseData ( rvecArr , tvecArr ) ;
830832
831833 // Create transform matrix.
832- transformationM = Matrix4x4 . TRS ( poseData . pos , poseData . rot , Vector3 . one ) ;
834+ transformationM = Matrix4x4 . TRS ( poseData . Pos , poseData . Rot , Vector3 . one ) ;
833835
834836 // Right-handed coordinates system (OpenCV) to left-handed one (Unity)
835837 // https://stackoverflow.com/questions/30234945/change-handedness-of-a-row-major-4x4-transformation-matrix
@@ -874,7 +876,7 @@ private void OnDetectionDone()
874876 }
875877 }
876878
877- Utils . matToTexture2D ( rgbMat4preview , texture ) ;
879+ OpenCVMatUtils . MatToTexture2D ( rgbMat4preview , texture ) ;
878880 }
879881
880882 if ( arCamera != null && applyEstimationPose )
@@ -892,7 +894,7 @@ private void OnDetectionDone()
892894 }
893895 else
894896 {
895- ARUtils . SetTransformFromMatrix ( arGameObject . transform , ref ARM ) ;
897+ OpenCVARUtils . SetTransformFromMatrix ( arGameObject . transform , ref ARM ) ;
896898 }
897899 }
898900 }
@@ -955,7 +957,7 @@ void LateUpdate()
955957 void OnDestroy ( )
956958 {
957959#if WINDOWS_UWP && ! DISABLE_HOLOLENSCAMSTREAM_API
958- webCamTextureToMatHelper . frameMatAcquired -= OnFrameMatAcquired ;
960+ webCamTextureToMatHelper . FrameMatAcquired -= OnFrameMatAcquired ;
959961#endif
960962 webCamTextureToMatHelper . Dispose ( ) ;
961963 imageOptimizationHelper . Dispose ( ) ;
@@ -998,7 +1000,7 @@ public void OnStopButtonClick()
9981000 /// </summary>
9991001 public void OnChangeCameraButtonClick ( )
10001002 {
1001- webCamTextureToMatHelper . requestedIsFrontFacing = ! webCamTextureToMatHelper . requestedIsFrontFacing ;
1003+ webCamTextureToMatHelper . RequestedIsFrontFacing = ! webCamTextureToMatHelper . RequestedIsFrontFacing ;
10021004 }
10031005
10041006 /// <summary>
0 commit comments