4
4
using System ;
5
5
using System . Collections ;
6
6
using System . Collections . Generic ;
7
- using NatCamU . Core ;
7
+ using NatCam ;
8
8
using OpenCVForUnity . CoreModule ;
9
9
using OpenCVForUnity . UnityUtils ;
10
10
@@ -83,27 +83,29 @@ protected override void OnStart ()
83
83
) ;
84
84
// Display preview
85
85
rawImage . texture = texture ;
86
- aspectFitter . aspectRatio = NatCam . Preview . width / ( float ) NatCam . Preview . height ;
86
+ aspectFitter . aspectRatio = cameraSource . width / ( float ) cameraSource . height ;
87
87
Debug . Log ( "NatCam camera source started with resolution: " + cameraSource . width + "x" + cameraSource . height ) ;
88
88
// Log camera properties
89
89
var cameraProps = new Dictionary < string , string > ( ) ;
90
- cameraProps . Add ( "IsFrontFacing" , NatCam . Camera . IsFrontFacing . ToString ( ) ) ;
91
- cameraProps . Add ( "Framerate" , NatCam . Camera . Framerate . ToString ( ) ) ;
92
- cameraProps . Add ( "PreviewResolution" , NatCam . Camera . PreviewResolution . x + "x" + NatCam . Camera . PreviewResolution . y ) ;
93
- cameraProps . Add ( "PhotoResolution" , NatCam . Camera . PhotoResolution . x + "x" + NatCam . Camera . PhotoResolution . y ) ;
94
- cameraProps . Add ( "ExposureLock" , NatCam . Camera . ExposureLock . ToString ( ) ) ;
95
- cameraProps . Add ( "ExposureBias" , NatCam . Camera . ExposureBias . ToString ( ) ) ;
96
- cameraProps . Add ( "MinExposureBias" , NatCam . Camera . MinExposureBias . ToString ( ) ) ;
97
- cameraProps . Add ( "MaxExposureBias" , NatCam . Camera . MaxExposureBias . ToString ( ) ) ;
98
- cameraProps . Add ( "IsFlashSupported" , NatCam . Camera . IsFlashSupported . ToString ( ) ) ;
99
- cameraProps . Add ( "FlashMode" , NatCam . Camera . FlashMode . ToString ( ) ) ;
100
- cameraProps . Add ( "FocusLock" , NatCam . Camera . FocusLock . ToString ( ) ) ;
101
- cameraProps . Add ( "HorizontalFOV" , NatCam . Camera . HorizontalFOV . ToString ( ) ) ;
102
- cameraProps . Add ( "VerticalFOV" , NatCam . Camera . VerticalFOV . ToString ( ) ) ;
103
- cameraProps . Add ( "IsTorchSupported" , NatCam . Camera . IsTorchSupported . ToString ( ) ) ;
104
- cameraProps . Add ( "TorchEnabled" , NatCam . Camera . TorchEnabled . ToString ( ) ) ;
105
- cameraProps . Add ( "MaxZoomRatio" , NatCam . Camera . MaxZoomRatio . ToString ( ) ) ;
106
- cameraProps . Add ( "ZoomRatio" , NatCam . Camera . ZoomRatio . ToString ( ) ) ;
90
+ cameraProps . Add ( "IsFrontFacing" , cameraSource . activeCamera . IsFrontFacing . ToString ( ) ) ;
91
+ cameraProps . Add ( "Framerate" , cameraSource . activeCamera . Framerate . ToString ( ) ) ;
92
+ cameraProps . Add ( "PreviewResolution" , cameraSource . activeCamera . PreviewResolution . x + "x" + cameraSource . activeCamera . PreviewResolution . y ) ;
93
+ cameraProps . Add ( "PhotoResolution" , cameraSource . activeCamera . PhotoResolution . x + "x" + cameraSource . activeCamera . PhotoResolution . y ) ;
94
+ cameraProps . Add ( "ExposureLock" , cameraSource . activeCamera . ExposureLock . ToString ( ) ) ;
95
+ cameraProps . Add ( "ExposureBias" , cameraSource . activeCamera . ExposureBias . ToString ( ) ) ;
96
+ cameraProps . Add ( "MinExposureBias" , cameraSource . activeCamera . MinExposureBias . ToString ( ) ) ;
97
+ cameraProps . Add ( "MaxExposureBias" , cameraSource . activeCamera . MaxExposureBias . ToString ( ) ) ;
98
+ cameraProps . Add ( "IsFlashSupported" , cameraSource . activeCamera . IsFlashSupported . ToString ( ) ) ;
99
+ cameraProps . Add ( "FlashMode" , cameraSource . activeCamera . FlashMode . ToString ( ) ) ;
100
+ cameraProps . Add ( "FocusLock" , cameraSource . activeCamera . FocusLock . ToString ( ) ) ;
101
+ cameraProps . Add ( "HorizontalFOV" , cameraSource . activeCamera . HorizontalFOV . ToString ( ) ) ;
102
+ cameraProps . Add ( "VerticalFOV" , cameraSource . activeCamera . VerticalFOV . ToString ( ) ) ;
103
+ cameraProps . Add ( "IsTorchSupported" , cameraSource . activeCamera . IsTorchSupported . ToString ( ) ) ;
104
+ cameraProps . Add ( "TorchEnabled" , cameraSource . activeCamera . TorchEnabled . ToString ( ) ) ;
105
+ cameraProps . Add ( "MaxZoomRatio" , cameraSource . activeCamera . MaxZoomRatio . ToString ( ) ) ;
106
+ cameraProps . Add ( "ZoomRatio" , cameraSource . activeCamera . ZoomRatio . ToString ( ) ) ;
107
+ cameraProps . Add ( "UniqueID" , cameraSource . activeCamera . UniqueID . ToString ( ) ) ;
108
+ cameraProps . Add ( "WhiteBalanceLock" , cameraSource . activeCamera . WhiteBalanceLock . ToString ( ) ) ;
107
109
Debug . Log ( "# Active Camera Properties #####################" ) ;
108
110
foreach ( string key in cameraProps . Keys )
109
111
Debug . Log ( key + ": " + cameraProps [ key ] ) ;
@@ -115,7 +117,7 @@ protected override void OnStart ()
115
117
fpsMonitor . Add ( "orientation" , Screen . orientation . ToString ( ) ) ;
116
118
117
119
fpsMonitor . boxWidth = 200 ;
118
- fpsMonitor . boxHeight = 680 ;
120
+ fpsMonitor . boxHeight = 760 ;
119
121
fpsMonitor . LocateGUI ( ) ;
120
122
121
123
foreach ( string key in cameraProps . Keys )
@@ -144,7 +146,7 @@ protected override void UpdateTexture ()
144
146
cameraSource . CaptureFrame ( frameMatrix ) ;
145
147
break ;
146
148
case MatCaptureMethod . BlitWithReadPixels :
147
- Utils . textureToTexture2D ( cameraSource . Preview , texture ) ;
149
+ Utils . textureToTexture2D ( cameraSource . preview , texture ) ;
148
150
Utils . copyToMat ( texture . GetRawTextureData ( ) , frameMatrix ) ;
149
151
Core . flip ( frameMatrix , frameMatrix , 0 ) ;
150
152
break ;
@@ -153,7 +155,7 @@ protected override void UpdateTexture ()
153
155
Debug . LogError ( "This device does not support Graphics::CopyTexture" ) ;
154
156
return ;
155
157
}
156
- Graphics . CopyTexture ( NatCam . Preview , texture ) ;
158
+ Graphics . CopyTexture ( cameraSource . preview , texture ) ;
157
159
Utils . copyToMat ( texture . GetRawTextureData ( ) , frameMatrix ) ;
158
160
Core . flip ( frameMatrix , frameMatrix , 0 ) ;
159
161
break ;
0 commit comments