diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | bin/camera/Logitech HD Webcam C525.yml | 22 | ||||
-rw-r--r-- | bin/camera/PS3Eye Camera.yml | 22 | ||||
-rw-r--r-- | opentrack/opencv-calibration.hpp | 26 |
4 files changed, 72 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c38b4d2..8a14b81f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -542,6 +542,8 @@ if(WIN32) install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) endif() +install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/camera" DESTINATION .) + if(APPLE) install(CODE " execute_process(COMMAND /bin/sh \"${CMAKE_SOURCE_DIR}/install-fail-tool\" \"${CMAKE_INSTALL_PREFIX}\") diff --git a/bin/camera/Logitech HD Webcam C525.yml b/bin/camera/Logitech HD Webcam C525.yml new file mode 100644 index 00000000..ac1bc981 --- /dev/null +++ b/bin/camera/Logitech HD Webcam C525.yml @@ -0,0 +1,22 @@ +%YAML:1.0 +calibration_time: "07/13/15 17:32:58" +image_width: 640 +image_height: 480 +board_width: 24 +board_height: 15 +square_size: 1. +flags: 0 +camera_matrix: !!opencv-matrix + rows: 3 + cols: 3 + dt: d + data: [ 7.1195238148354849e+002, 0., 3.4210284784635138e+002, 0., + 7.1302752784110055e+002, 2.2837679451205264e+002, 0., 0., 1. ] +distortion_coefficients: !!opencv-matrix + rows: 5 + cols: 1 + dt: d + data: [ -1.5165615866415242e-003, 3.6806867018034255e-002, + -6.6432394998828278e-004, 1.7782694073348656e-003, + -4.9225052904494471e-001 ] +avg_reprojection_error: 2.5310746466741296e+000 diff --git a/bin/camera/PS3Eye Camera.yml b/bin/camera/PS3Eye Camera.yml new file mode 100644 index 00000000..6859d0fb --- /dev/null +++ b/bin/camera/PS3Eye Camera.yml @@ -0,0 +1,22 @@ +%YAML:1.0 +calibration_time: "07/13/15 17:45:33" +image_width: 640 +image_height: 480 +board_width: 24 +board_height: 15 +square_size: 1. +flags: 0 +camera_matrix: !!opencv-matrix + rows: 3 + cols: 3 + dt: d + data: [ 7.5119574967224673e+002, 0., 3.2806930334341007e+002, 0., + 7.5112907969240291e+002, 2.2681331450818737e+002, 0., 0., 1. ] +distortion_coefficients: !!opencv-matrix + rows: 5 + cols: 1 + dt: d + data: [ -2.2741190107950382e-001, 9.4372681451250684e-001, + -4.0955586655475494e-003, -2.6778551080439902e-003, + -1.7969804313130640e+000 ] +avg_reprojection_error: 1.9233386799903629e+000 diff --git a/opentrack/opencv-calibration.hpp b/opentrack/opencv-calibration.hpp new file mode 100644 index 00000000..6dee9908 --- /dev/null +++ b/opentrack/opencv-calibration.hpp @@ -0,0 +1,26 @@ +#pragma once +#include <QCoreApplication> +#include <QString> +#include <QByteArray> +#include <string> +#include <opencv2/core.hpp> + +template<typename = void> +bool get_camera_calibration(const QString& camera_name, cv::Mat& intrinsics, cv::Mat& distortion, int w, int h) +{ + QString pathname_ = QCoreApplication::applicationDirPath() + "/camera/" + camera_name + ".yml"; + std::string pathname = pathname_.toStdString(); + cv::FileStorage fs(pathname, cv::FileStorage::READ); + if (!fs.isOpened()) + return false; + cv::Mat intrinsics_, distortion_; + fs["camera_matrix"] >> intrinsics_; + fs["distortion_coefficients"] >> distortion_; + intrinsics_.at<double>(0, 0) *= w / 640.; + intrinsics_.at<double>(2, 0) *= w / 640.; + intrinsics_.at<double>(1, 1) *= h / 480.; + intrinsics_.at<double>(2, 1) *= h / 480.; + intrinsics = intrinsics_; + distortion = distortion_; + return true; +} |