31
31
using namespace cv ;
32
32
33
33
extern " C" {
34
- #include < vnlog-parser.h>
34
+ #include " vnlog-parser.h"
35
35
} // extern "C"
36
36
37
37
struct cmpByFilename {
@@ -44,16 +44,14 @@ struct cmpByFilename {
44
44
};
45
45
46
46
int homography_test () {
47
- Size boardSize = {7 , 7 };
48
- Size imagerSize = {640 , 480 };
47
+ Size boardSize = {18 , 13 };
48
+ Size imagerSize = {1600 , 1200 };
49
49
// std::FILE *fp =
50
50
// std::fopen("/home/matt/github/photon_640_480/corners.vnl", "r");
51
51
// Size boardSize = {10, 10};
52
52
// Size imagerSize = {1600, 896};
53
53
std::FILE *fp =
54
- std::fopen (" /home/matt/Documents/GitHub/photonvision/test-resources/"
55
- " calibrationSquaresImg/piCam/640_480_1/corners.vnl" ,
56
- " r" );
54
+ std::fopen (" /home/matt/mrcal_will_debug/imgs/corners.vnl" , " r" );
57
55
58
56
if (fp == NULL )
59
57
return -1 ;
@@ -106,26 +104,36 @@ int homography_test() {
106
104
observations_board.reserve (total_points);
107
105
frames_rt_toref.reserve (points.size ());
108
106
107
+ std::chrono::steady_clock::time_point begin =
108
+ std::chrono::steady_clock::now ();
109
+
109
110
for (const auto &[key, value] : points) {
110
111
if (value.size ()) {
111
- auto ret = getSeedPose (value.data (), boardSize, imagerSize, 0.0254 , 800 );
112
+ auto ret = getSeedPose (value.data (), boardSize, imagerSize, 0.03 , 1200 );
112
113
113
- if (0 )
114
- std::printf (" Seed pose %s: r %f %f %f t %f %f %f\n " , key.c_str (),
115
- ret.r .x , ret.r .y , ret.r .z , ret.t .x , ret.t .y , ret.t .z );
114
+ if (1 )
115
+ // std::printf("Seed pose %s: r %f %f %f t %f %f %f\n", key.c_str(),
116
+ // ret.r.x, ret.r.y, ret.r.z, ret.t.x, ret.t.y, ret.t.z);
116
117
117
- // Append to the Big List of board corners/levels
118
- observations_board.insert (observations_board.end (), value.begin (),
119
- value.end ());
118
+ // Append to the Big List of board corners/levels
119
+ observations_board.insert (observations_board.end (), value.begin (),
120
+ value.end ());
120
121
// And list of pose seeds
121
122
frames_rt_toref.push_back (ret);
122
123
} else {
123
124
std::printf (" No points for %s\n " , key.c_str ());
124
125
}
125
126
}
126
127
128
+ std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now ();
129
+ std::cout << " Seed took: "
130
+ << std::chrono::duration_cast<std::chrono::milliseconds>(end -
131
+ begin)
132
+ .count ()
133
+ << " [ms]" << std::endl;
134
+
127
135
auto cal_result = mrcal_main (observations_board, frames_rt_toref, boardSize,
128
- 0.0254 , imagerSize);
136
+ 0.030 , imagerSize, 1200 );
129
137
130
138
auto dt = std::chrono::steady_clock::now () - start;
131
139
int dt_ms = dt.count ();
@@ -135,7 +143,7 @@ int homography_test() {
135
143
double max_error =
136
144
*std::max_element (stats.residuals .begin (), stats.residuals .end ());
137
145
138
- if (0 ) {
146
+ if (1 ) {
139
147
std::printf (" \n ===============================\n\n " );
140
148
std::printf (" RMS Reprojection Error: %.2f pixels\n " , stats.rms_error );
141
149
std::printf (" Worst residual (by measurement): %.1f pixels\n " , max_error);
@@ -145,33 +153,37 @@ int homography_test() {
145
153
std::printf (" calobject_warp: [%f, %f]\n " , stats.calobject_warp .x2 ,
146
154
stats.calobject_warp .y2 );
147
155
std::printf (" dt, seeding + solve: %f ms\n " , dt_ms / 1e6 );
148
- std::printf (" Intrinsics [%lu]:\n " , stats.intrinsics .size ());
156
+ std::printf (" Intrinsics [%lu]: " , stats.intrinsics .size ());
149
157
for (auto i : stats.intrinsics )
150
158
std::printf (" %f " , i);
151
159
std::printf (" \n " );
152
160
}
153
161
154
- double fx = 100 , fy = 100 , cx = 50 , cy = 20 ;
155
- cv::Mat1d camMat = (Mat_<double >(3 ,3 ) << fx, 0 , cx, 0 , fy, cy, 0 , 0 , 1 );
156
- cv::Mat1d distCoeffs = (Mat_<double >(1 ,5 ) << 0.17802570252202954 ,-1.461379065131586 ,0.001019661566461145 ,0.0003215220840230439 ,2.7249642067580533 );
162
+ // double fx = 100, fy = 100, cx = 50, cy = 20;
163
+ // cv::Mat1d camMat = (Mat_<double>(3, 3) << fx, 0, cx, 0, fy, cy, 0, 0, 1);
164
+ // cv::Mat1d distCoeffs =
165
+ // (Mat_<double>(1, 5) << 0.17802570252202954, -1.461379065131586,
166
+ // 0.001019661566461145, 0.0003215220840230439, 2.7249642067580533);
157
167
158
- undistort_mrcal (&inputs, &outputs, &camMat, &distCoeffs, CameraLensModel::LENSMODEL_OPENCV5, 0 , 0 , 0 , 0 );
168
+ // undistort_mrcal(&inputs, &outputs, &camMat, &distCoeffs,
169
+ // CameraLensModel::LENSMODEL_OPENCV5, 0, 0, 0, 0);
159
170
160
- cv::Mat2d outputs_opencv = cv::Mat2d::zeros (inputs.size ());
161
- cv::undistortImagePoints (inputs, outputs_opencv, camMat, distCoeffs,
162
- TermCriteria (TermCriteria::MAX_ITER + TermCriteria::EPS, 50 ,
163
- 1e-4 ));
171
+ // cv::Mat2d outputs_opencv = cv::Mat2d::zeros(inputs.size());
172
+ // cv::undistortImagePoints(
173
+ // inputs, outputs_opencv, camMat, distCoeffs ,
174
+ // TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 50, 1e-4));
164
175
165
- std::cout << " cam mat\n " << camMat << std::endl;
166
- std::cout << " dist\n " << distCoeffs << std::endl;
167
- std::cout << " Inputs\n " << inputs << std::endl;
168
- std::cout << " Outputs (mrcal)\n " << outputs << std::endl;
169
- std::cout << " Outputs (opencv)\n " << outputs_opencv << std::endl;
176
+ // std::cout << "cam mat\n" << camMat << std::endl;
177
+ // std::cout << "dist\n" << distCoeffs << std::endl;
178
+ // std::cout << "Inputs\n" << inputs << std::endl;
179
+ // std::cout << "Outputs (mrcal)\n" << outputs << std::endl;
180
+ // std::cout << "Outputs (opencv)\n" << outputs_opencv << std::endl;
181
+
182
+ return 0 ;
170
183
}
171
184
172
185
int main () {
173
186
// for (int i = 0; i < 1e6; i++) {
174
- homography_test ();
187
+ homography_test ();
175
188
// }
176
-
177
189
}
0 commit comments