diff --git a/Calibration/calibration_method.cpp b/Calibration/calibration_method.cpp index a70c49b..252f397 100644 --- a/Calibration/calibration_method.cpp +++ b/Calibration/calibration_method.cpp @@ -82,7 +82,7 @@ namespace GEO1016_A1 { * to evaluate the execution time * e.g. * \code - * { + * { * Timer time; * //execution process * //... @@ -105,7 +105,7 @@ namespace GEO1016_A1 { end = std::chrono::high_resolution_clock::now(); duration = end - start; - std::cout << "Execution Time: " << duration.count()*1000.0 << "ms\n"; + std::cout << "Execution Time: " << duration.count() * 1000.0 << "ms\n"; } }; @@ -119,15 +119,15 @@ namespace GEO1016_A1 { * @return True on success, otherwise false. On success, the camera parameters are returned by * ---------------------------------------------------------------------------------------------------------------*/ bool Calibration::calibration( - const std::vector& points_3d, /// input: An array of 3D points. - const std::vector& points_2d, /// input: An array of 2D image points. - double& fx, double& fy, /// output: the focal length (in our slides, we use 'alpha' and 'beta/sin_theta'), - double& cx, double& cy, /// output: the principal point (in our slides, we use 'u0' and 'v0'), - double& skew, /// output: the skew factor ('-alpha * cot_theta') - Matrix33& R, /// output: the 3x3 rotation matrix encoding camera orientation. - Vector3D& t) /// output:a 3D vector encoding camera translation. + const std::vector& points_3d, /// input: An array of 3D points. + const std::vector& points_2d, /// input: An array of 2D image points. + double& fx, double& fy, /// output: the focal length (in our slides, we use 'alpha' and 'beta/sin_theta'), + double& cx, double& cy, /// output: the principal point (in our slides, we use 'u0' and 'v0'), + double& skew, /// output: the skew factor ('-alpha * cot_theta') + Matrix33& R, /// output: the 3x3 rotation matrix encoding camera orientation. + Vector3D& t) /// output:a 3D vector encoding camera translation. { - + // TODO: the above code just demonstrates some useful data structures and APIs. Please remove all above code in your // final submission. @@ -135,17 +135,17 @@ bool Calibration::calibration( // implementation starts ... std::cout << "\n[Liangliang]:\n" - "\tThe input parameters of this function are:\n" - "\t\t- points_3d: An array of 3D points (input to this function)\n" - "\t\t- points_2d: An array of 2D image points (input to this function)\n" - "\tThis function must return either 'true' on success or 'false' otherwise. On success, the camera\n" - "\tparameters are returned by the following variables:\n" - "\t\t- fx and fy: the focal lengths (in our slides, we use 'alpha' and 'beta')\n" - "\t\t- cx and cy: the principal point (in our slides, we use 'u0' and 'v0')\n" - "\t\t- skew: the skew factor ('-alpha * cot_theta')\n" - "\t\t- R: the 3x3 rotation matrix encoding camera orientation\n" - "\t\t- t: a 3D vector encoding camera location.\n" - "\tIMPORTANT: don't forget to write your recovered parameters to the above variables." << std::endl; + "\tThe input parameters of this function are:\n" + "\t\t- points_3d: An array of 3D points (input to this function)\n" + "\t\t- points_2d: An array of 2D image points (input to this function)\n" + "\tThis function must return either 'true' on success or 'false' otherwise. On success, the camera\n" + "\tparameters are returned by the following variables:\n" + "\t\t- fx and fy: the focal lengths (in our slides, we use 'alpha' and 'beta')\n" + "\t\t- cx and cy: the principal point (in our slides, we use 'u0' and 'v0')\n" + "\t\t- skew: the skew factor ('-alpha * cot_theta')\n" + "\t\t- R: the 3x3 rotation matrix encoding camera orientation\n" + "\t\t- t: a 3D vector encoding camera location.\n" + "\tIMPORTANT: don't forget to write your recovered parameters to the above variables." << std::endl; @@ -157,7 +157,7 @@ bool Calibration::calibration( GEO1016_A1::Timer time; /* - * TODO - 1: + * TODO - 1: * check if input is valid * (1) check (e.g., number of correspondences >= 6, sizes of 2D/3D points must match). * (2) check if points are coplanar @@ -177,7 +177,7 @@ bool Calibration::calibration( if (!is_constructed) { std::cout << "construct P matrix failed, please check(maybe the subscript is out of bounds)" << '\n'; return false; - } + } #ifdef _MATRIX_CHECK_ std::cout << "print P matrix: " << '\n'; @@ -187,18 +187,18 @@ bool Calibration::calibration( /* * TODO - 3: solve for M (3 * 4 matrix, the whole projection matrix, i.e., M = K * [R, t]) using SVD decomposition. - * Optional: + * Optional: * you can check if your M is correct by applying M on the 3D points. If correct, the projected point * should be very close to your input images points. * ---------------------------------------------------------------------------------------------------------------*/ const auto& m = P.rows(); const auto& n = P.cols(); - Matrix U(m, m); - Matrix S(m, n); - Matrix V(n, n); + Matrix U(m, m); + Matrix S(m, n); + Matrix V(n, n); - // Compute the SVD decomposition of P + // Compute the SVD decomposition of P bool is_svd_solved = GEO1016_A1::solve_svd(P, U, S, V); if (!is_svd_solved) { std::cout << "SVD failed, please check " << '\n'; @@ -223,7 +223,7 @@ bool Calibration::calibration( ( V(0, last_col), V(1, last_col), V(2, last_col), V(3, last_col), V(4, last_col), V(5, last_col), V(6, last_col), V(7, last_col), - V(8, last_col), V(9, last_col), V(10,last_col), V(11, last_col) + V(8, last_col), V(9, last_col), V(10, last_col), V(11, last_col) ); @@ -235,7 +235,7 @@ bool Calibration::calibration( std::cout << '\n'; std::cout << "result check: " << '\n'; auto diff = GEO1016_A1::check_matrix(M, points_3d, points_2d); - std::cout << "variance: " << (diff/points_3d.size()) << '\n'; + std::cout << "variance: " << (diff / points_3d.size()) << '\n'; // Intermediate option: check whether M matrix is correct ----------------------------- @@ -245,10 +245,10 @@ bool Calibration::calibration( * if the origin of the world coordinate system is in front of the camera * then the positive sign(+) should be chosen, otherwise the negative sign(-) * should be chosen(in a general case). - * + * * In this assignment, the origin of the world coordinate system(the corner of the chessboard) * is in FRONT of the camera, therefore the positive sign(+) is used. - * + * * ---------------------------------------------------------------------------------------------------------------*/ // see the function: extract_params(M, R, t, fx, fy, cx, cy, skew); @@ -259,7 +259,7 @@ bool Calibration::calibration( /* * extract parameters for TODO - 4 and TODO - 5 - * ---------------------------------------------------------------------------------------------------------------*/ + * ---------------------------------------------------------------------------------------------------------------*/ GEO1016_A1::extract_params(M, R, t, fx, fy, cx, cy, skew); std::cout << "calibration succeed! " << '\n'; @@ -269,7 +269,7 @@ bool Calibration::calibration( /* -------------------------------------------------------------------------------------------------------------- * ------------------------------------------- IMPLEMENTATION ---------------------------------------------------- -* ---------------------------------------------------------------------------------------------------------------*/ +* ---------------------------------------------------------------------------------------------------------------*/ namespace GEO1016_A1 { @@ -379,7 +379,7 @@ namespace GEO1016_A1 { 0, 0, 0, 0, -u * x, -u * y, -u * z, -u }); - + ++k; } @@ -447,7 +447,7 @@ namespace GEO1016_A1 { for (int j = 0; j != 12; ++j) { // loop through each column(12 in total) res += P(i, j) * V(j, last_col); } - std::cout << "P * m - row "< tolerance)res_flag = false; } return res_flag; @@ -597,26 +597,4 @@ namespace GEO1016_A1 { } -} - - - - - - - - - - - - - - - - - - - - - - +} \ No newline at end of file diff --git a/resources/data/A1_6_points.exact.txt b/resources/data/A1_6_points.exact.txt deleted file mode 100644 index fb44a68..0000000 --- a/resources/data/A1_6_points.exact.txt +++ /dev/null @@ -1,6 +0,0 @@ -6 5 0 1136 596 -8 8 0 1223 452 -3 0 7 856 1067 -7 0 4 1145 987 -0 4 8 602 912 -0 6 6 628 737 \ No newline at end of file diff --git a/resources/data/A1_6_points.noisy.png b/resources/data/A1_6_points.noisy.png deleted file mode 100644 index 1a782da..0000000 Binary files a/resources/data/A1_6_points.noisy.png and /dev/null differ diff --git a/resources/data/A1_6_points.noisy.txt b/resources/data/A1_6_points.noisy.txt deleted file mode 100644 index 42c2c89..0000000 --- a/resources/data/A1_6_points.noisy.txt +++ /dev/null @@ -1,6 +0,0 @@ -6 5 0 1138 598 -8 8 0 1223 458 -3 0 7 856 1067 -7 0 4 1145 987 -0 4 8 604 915 -0 6 6 628 737 \ No newline at end of file diff --git a/resources/data/A1_9_points.normal.png b/resources/data/A1_9_points.noisy.png similarity index 100% rename from resources/data/A1_9_points.normal.png rename to resources/data/A1_9_points.noisy.png diff --git a/resources/data/A1_9_points.normal.txt b/resources/data/A1_9_points.noisy.txt similarity index 100% rename from resources/data/A1_9_points.normal.txt rename to resources/data/A1_9_points.noisy.txt