-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ArUco, ChArUco, diamonds, add read dictionary/params, add calibra…
…tion photos, add tests, add aruco_samples_utility.hpp
- Loading branch information
1 parent
5cc328d
commit c3e1180
Showing
42 changed files
with
740 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,31 @@ | ||
set(the_description "ArUco Marker Detection") | ||
ocv_define_module(aruco opencv_core opencv_imgproc opencv_calib3d WRAP python java) | ||
ocv_include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
ocv_add_testdata(samples/ contrib/aruco | ||
FILES_MATCHING PATTERN "*yml" | ||
) | ||
|
||
ocv_add_testdata(tutorials/aruco_detection/images/ contrib/aruco | ||
FILES_MATCHING PATTERN "singlemarkersoriginal.jpg" | ||
) | ||
|
||
ocv_add_testdata(tutorials/aruco_board_detection/images/ contrib/aruco | ||
FILES_MATCHING PATTERN "gboriginal.png" | ||
) | ||
|
||
ocv_add_testdata(tutorials/charuco_detection/images/ contrib/aruco | ||
FILES_MATCHING PATTERN "choriginal.jpg" | ||
) | ||
|
||
ocv_add_testdata(tutorials/charuco_detection/images/ contrib/aruco | ||
FILES_MATCHING PATTERN "chocclusion_original.jpg" | ||
) | ||
|
||
ocv_add_testdata(tutorials/charuco_diamond_detection/images/ contrib/aruco | ||
FILES_MATCHING PATTERN "diamondmarkers.png" | ||
) | ||
|
||
ocv_add_testdata(tutorials/aruco_calibration/images/ contrib/aruco | ||
FILES_MATCHING REGEX "img_[0-9]+.jpg" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <opencv2/highgui.hpp> | ||
#include <opencv2/aruco.hpp> | ||
#include <opencv2/calib3d.hpp> | ||
#include <ctime> | ||
|
||
namespace { | ||
inline static bool readCameraParameters(std::string filename, cv::Mat &camMatrix, cv::Mat &distCoeffs) { | ||
cv::FileStorage fs(filename, cv::FileStorage::READ); | ||
if (!fs.isOpened()) | ||
return false; | ||
fs["camera_matrix"] >> camMatrix; | ||
fs["distortion_coefficients"] >> distCoeffs; | ||
return true; | ||
} | ||
|
||
inline static bool saveCameraParams(const std::string &filename, cv::Size imageSize, float aspectRatio, int flags, | ||
const cv::Mat &cameraMatrix, const cv::Mat &distCoeffs, double totalAvgErr) { | ||
cv::FileStorage fs(filename, cv::FileStorage::WRITE); | ||
if (!fs.isOpened()) | ||
return false; | ||
|
||
time_t tt; | ||
time(&tt); | ||
struct tm *t2 = localtime(&tt); | ||
char buf[1024]; | ||
strftime(buf, sizeof(buf) - 1, "%c", t2); | ||
|
||
fs << "calibration_time" << buf; | ||
fs << "image_width" << imageSize.width; | ||
fs << "image_height" << imageSize.height; | ||
|
||
if (flags & cv::CALIB_FIX_ASPECT_RATIO) fs << "aspectRatio" << aspectRatio; | ||
|
||
if (flags != 0) { | ||
sprintf(buf, "flags: %s%s%s%s", | ||
flags & cv::CALIB_USE_INTRINSIC_GUESS ? "+use_intrinsic_guess" : "", | ||
flags & cv::CALIB_FIX_ASPECT_RATIO ? "+fix_aspectRatio" : "", | ||
flags & cv::CALIB_FIX_PRINCIPAL_POINT ? "+fix_principal_point" : "", | ||
flags & cv::CALIB_ZERO_TANGENT_DIST ? "+zero_tangent_dist" : ""); | ||
} | ||
fs << "flags" << flags; | ||
fs << "camera_matrix" << cameraMatrix; | ||
fs << "distortion_coefficients" << distCoeffs; | ||
fs << "avg_reprojection_error" << totalAvgErr; | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.