|
1 |
| -using System; |
2 |
| -using OpenCVForUnity.CoreModule; |
3 |
| - |
4 |
| -namespace HoloLensWithOpenCVForUnityExample |
5 |
| -{ |
6 |
| - [System.Serializable] |
7 |
| - public struct CameraParameters |
8 |
| - { |
9 |
| - public string calibration_date; |
10 |
| - public int frames_count; |
11 |
| - public int image_width; |
12 |
| - public int image_height; |
13 |
| - public int calibration_flags; |
14 |
| - public double[] camera_matrix; |
15 |
| - public double[] distortion_coefficients; |
16 |
| - public double avg_reprojection_error; |
17 |
| - |
18 |
| - public CameraParameters(int frames_count, int image_width, int image_height, int calibration_flags, double[] camera_matrix, double[] distortion_coefficients, double avg_reprojection_error) |
19 |
| - { |
20 |
| - this.calibration_date = DateTime.Now.ToString(); |
21 |
| - this.frames_count = frames_count; |
22 |
| - this.image_width = image_width; |
23 |
| - this.image_height = image_height; |
24 |
| - this.calibration_flags = calibration_flags; |
25 |
| - this.camera_matrix = camera_matrix; |
26 |
| - this.distortion_coefficients = distortion_coefficients; |
27 |
| - this.avg_reprojection_error = avg_reprojection_error; |
28 |
| - } |
29 |
| - |
30 |
| - public CameraParameters(int frames_count, int image_width, int image_height, int calibration_flags, Mat camera_matrix, Mat distortion_coefficients, double avg_reprojection_error) |
31 |
| - { |
32 |
| - double[] camera_matrixArr = new double[camera_matrix.total()]; |
33 |
| - camera_matrix.get(0, 0, camera_matrixArr); |
34 |
| - |
35 |
| - double[] distortion_coefficientsArr = new double[distortion_coefficients.total()]; |
36 |
| - distortion_coefficients.get(0, 0, distortion_coefficientsArr); |
37 |
| - |
38 |
| - this.calibration_date = DateTime.Now.ToString(); |
39 |
| - this.frames_count = frames_count; |
40 |
| - this.image_width = image_width; |
41 |
| - this.image_height = image_height; |
42 |
| - this.calibration_flags = calibration_flags; |
43 |
| - this.camera_matrix = camera_matrixArr; |
44 |
| - this.distortion_coefficients = distortion_coefficientsArr; |
45 |
| - this.avg_reprojection_error = avg_reprojection_error; |
46 |
| - } |
47 |
| - |
48 |
| - public Mat GetCameraMatrix() |
49 |
| - { |
50 |
| - Mat m = new Mat(3, 3, CvType.CV_64FC1); |
51 |
| - m.put(0, 0, camera_matrix); |
52 |
| - return m; |
53 |
| - } |
54 |
| - |
55 |
| - public Mat GetDistortionCoefficients() |
56 |
| - { |
57 |
| - Mat m = new Mat(distortion_coefficients.Length, 1, CvType.CV_64FC1); |
58 |
| - m.put(0, 0, distortion_coefficients); |
59 |
| - return m; |
60 |
| - } |
61 |
| - } |
62 |
| -} |
| 1 | +using System; |
| 2 | +using OpenCVForUnity.CoreModule; |
| 3 | + |
| 4 | +namespace HoloLensWithOpenCVForUnityExample |
| 5 | +{ |
| 6 | + [System.Serializable] |
| 7 | + public struct CameraParameters |
| 8 | + { |
| 9 | + public string calibration_date; |
| 10 | + public int frames_count; |
| 11 | + public int image_width; |
| 12 | + public int image_height; |
| 13 | + public int calibration_flags; |
| 14 | + public double[] camera_matrix; |
| 15 | + public double[] distortion_coefficients; |
| 16 | + public double avg_reprojection_error; |
| 17 | + |
| 18 | + public CameraParameters(int frames_count, int image_width, int image_height, int calibration_flags, double[] camera_matrix, double[] distortion_coefficients, double avg_reprojection_error) |
| 19 | + { |
| 20 | + this.calibration_date = DateTime.Now.ToString(); |
| 21 | + this.frames_count = frames_count; |
| 22 | + this.image_width = image_width; |
| 23 | + this.image_height = image_height; |
| 24 | + this.calibration_flags = calibration_flags; |
| 25 | + this.camera_matrix = camera_matrix; |
| 26 | + this.distortion_coefficients = distortion_coefficients; |
| 27 | + this.avg_reprojection_error = avg_reprojection_error; |
| 28 | + } |
| 29 | + |
| 30 | + public CameraParameters(int frames_count, int image_width, int image_height, int calibration_flags, Mat camera_matrix, Mat distortion_coefficients, double avg_reprojection_error) |
| 31 | + { |
| 32 | + double[] camera_matrixArr = new double[camera_matrix.total()]; |
| 33 | + camera_matrix.get(0, 0, camera_matrixArr); |
| 34 | + |
| 35 | + double[] distortion_coefficientsArr = new double[distortion_coefficients.total()]; |
| 36 | + distortion_coefficients.get(0, 0, distortion_coefficientsArr); |
| 37 | + |
| 38 | + this.calibration_date = DateTime.Now.ToString(); |
| 39 | + this.frames_count = frames_count; |
| 40 | + this.image_width = image_width; |
| 41 | + this.image_height = image_height; |
| 42 | + this.calibration_flags = calibration_flags; |
| 43 | + this.camera_matrix = camera_matrixArr; |
| 44 | + this.distortion_coefficients = distortion_coefficientsArr; |
| 45 | + this.avg_reprojection_error = avg_reprojection_error; |
| 46 | + } |
| 47 | + |
| 48 | + public Mat GetCameraMatrix() |
| 49 | + { |
| 50 | + Mat m = new Mat(3, 3, CvType.CV_64FC1); |
| 51 | + m.put(0, 0, camera_matrix); |
| 52 | + return m; |
| 53 | + } |
| 54 | + |
| 55 | + public Mat GetDistortionCoefficients() |
| 56 | + { |
| 57 | + Mat m = new Mat(distortion_coefficients.Length, 1, CvType.CV_64FC1); |
| 58 | + m.put(0, 0, distortion_coefficients); |
| 59 | + return m; |
| 60 | + } |
| 61 | + } |
| 62 | +} |
0 commit comments