11/*
2- Read intrinsic parameters from the Zivid camera (OpenCV model).
2+ Read intrinsic parameters from the Zivid camera (OpenCV model) or estimate them from the point cloud .
33
44Note: This example uses experimental SDK features, which may be modified, moved, or deleted in the future without notice.
55*/
@@ -8,6 +8,48 @@ Read intrinsic parameters from the Zivid camera (OpenCV model).
88
99class Program
1010{
11+ static void PrintParameterDelta ( String label , Double fixedValue , Double estimatedValue )
12+ {
13+ var delta = fixedValue - estimatedValue ;
14+ if ( delta != 0 )
15+ {
16+ var deltaInPercentage = ( 100 * delta ) / fixedValue ;
17+ Console . WriteLine ( $ "{ label , 6 : s} : { delta , 6 : f2} ({ deltaInPercentage , 6 : f2} % )") ;
18+ }
19+ }
20+
21+ static void PrintIntrinsicParametersDelta (
22+ Zivid . NET . CameraIntrinsics fixedIntrinsics ,
23+ Zivid . NET . CameraIntrinsics estimatedIntrinsics )
24+ {
25+ PrintParameterDelta ( "CX" , fixedIntrinsics . CameraMatrix . CX , estimatedIntrinsics . CameraMatrix . CX ) ;
26+ PrintParameterDelta ( "CY" , fixedIntrinsics . CameraMatrix . CY , estimatedIntrinsics . CameraMatrix . CY ) ;
27+ PrintParameterDelta ( "FX" , fixedIntrinsics . CameraMatrix . FX , estimatedIntrinsics . CameraMatrix . FX ) ;
28+ PrintParameterDelta ( "FY" , fixedIntrinsics . CameraMatrix . FY , estimatedIntrinsics . CameraMatrix . FY ) ;
29+
30+ PrintParameterDelta ( "K1" , fixedIntrinsics . Distortion . K1 , estimatedIntrinsics . Distortion . K1 ) ;
31+ PrintParameterDelta ( "K2" , fixedIntrinsics . Distortion . K2 , estimatedIntrinsics . Distortion . K2 ) ;
32+ PrintParameterDelta ( "K3" , fixedIntrinsics . Distortion . K3 , estimatedIntrinsics . Distortion . K3 ) ;
33+ PrintParameterDelta ( "P1" , fixedIntrinsics . Distortion . P1 , estimatedIntrinsics . Distortion . P1 ) ;
34+ PrintParameterDelta ( "P2" , fixedIntrinsics . Distortion . P2 , estimatedIntrinsics . Distortion . P2 ) ;
35+ }
36+
37+ static void PrintIntrinsicParameters ( Zivid . NET . CameraIntrinsics intrinsics )
38+ {
39+ Console . WriteLine ( "Separated camera intrinsic parameters:" ) ;
40+
41+ Console . WriteLine ( $ " CX = { intrinsics . CameraMatrix . CX , - 7 : f2} ") ;
42+ Console . WriteLine ( $ " CY = { intrinsics . CameraMatrix . CY , - 7 : f2} ") ;
43+ Console . WriteLine ( $ " FX = { intrinsics . CameraMatrix . FX , - 7 : f2} ") ;
44+ Console . WriteLine ( $ " FY = { intrinsics . CameraMatrix . FY , - 7 : f2} ") ;
45+
46+ Console . WriteLine ( $ " K1 = { intrinsics . Distortion . K1 , - 7 : f4} ") ;
47+ Console . WriteLine ( $ " K2 = { intrinsics . Distortion . K2 , - 7 : f4} ") ;
48+ Console . WriteLine ( $ " K3 = { intrinsics . Distortion . K3 , - 7 : f4} ") ;
49+ Console . WriteLine ( $ " P1 = { intrinsics . Distortion . P1 , - 7 : f4} ") ;
50+ Console . WriteLine ( $ " P2 = { intrinsics . Distortion . P2 , - 7 : f4} ") ;
51+ }
52+
1153 static int Main ( )
1254 {
1355 try
@@ -22,22 +64,24 @@ static int Main()
2264
2365 Console . WriteLine ( intrinsics . ToString ( ) ) ;
2466
25- Console . WriteLine ( "Separated camera intrinsic parameters:" ) ;
26-
27- Console . WriteLine ( " CX = " + intrinsics . CameraMatrix . CX . ToString ( ) ) ;
28- Console . WriteLine ( " CY = " + intrinsics . CameraMatrix . CY . ToString ( ) ) ;
29- Console . WriteLine ( " FX = " + intrinsics . CameraMatrix . FX . ToString ( ) ) ;
30- Console . WriteLine ( " FY = " + intrinsics . CameraMatrix . FY . ToString ( ) ) ;
31-
32- Console . WriteLine ( " K1 = " + intrinsics . Distortion . K1 . ToString ( ) ) ;
33- Console . WriteLine ( " K2 = " + intrinsics . Distortion . K2 . ToString ( ) ) ;
34- Console . WriteLine ( " K3 = " + intrinsics . Distortion . K3 . ToString ( ) ) ;
35- Console . WriteLine ( " P1 = " + intrinsics . Distortion . P1 . ToString ( ) ) ;
36- Console . WriteLine ( " P2 = " + intrinsics . Distortion . P2 . ToString ( ) ) ;
37-
3867 var intrinsicsFile = "Intrinsics.yml" ;
3968 Console . WriteLine ( "Saving camera intrinsics to file: " + intrinsicsFile ) ;
4069 intrinsics . Save ( intrinsicsFile ) ;
70+
71+ PrintIntrinsicParameters ( intrinsics ) ;
72+
73+ Console . WriteLine ( "\n Difference between fixed intrinsics and estimated intrinsics for different apertures and temperatures:" ) ;
74+
75+ foreach ( var aperture in new double [ ] { 11.31 , 5.66 , 2.83 } )
76+ {
77+ var settings = new Zivid . NET . Settings ( ) ;
78+ settings . Acquisitions . Add ( new Zivid . NET . Settings . Acquisition { Aperture = aperture } ) ;
79+ var frame = camera . Capture ( settings ) ;
80+ var estimatedIntrinsics = Zivid . NET . Experimental . Calibration . Calibrator . EstimateIntrinsics ( frame ) ;
81+ var temperature = frame . State . Temperature . Lens ;
82+ Console . WriteLine ( $ "\n Aperture: { aperture , 5 : f2} , Lens Temperature: { temperature , 5 : f2} °C") ;
83+ PrintIntrinsicParametersDelta ( intrinsics , estimatedIntrinsics ) ;
84+ }
4185 }
4286 catch ( Exception ex )
4387 {
0 commit comments