diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-20 14:29:02 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-20 14:29:02 +0200 |
commit | 56dd856405ebf26f8243880035fed2dd688b14a6 (patch) | |
tree | 9098f67afb93e7d95f7043a2c909d2f39a1e9c10 | |
parent | 0c1b4510b3f7a744cc4cad94e0d4dde45925269d (diff) |
for now remove calibration support
PT tracker returns garbage when calibrating, Z is zero. Maybe can be
reverted and fixed later.
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | bin/camera/Logitech HD Webcam C525.yml | 22 | ||||
-rw-r--r-- | bin/camera/ManyCam Video Source-56.yml | 22 | ||||
-rw-r--r-- | bin/camera/ManyCam Video Source-75.yml | 22 | ||||
-rw-r--r-- | bin/camera/PS3Eye Camera-56.yml | 22 | ||||
-rw-r--r-- | bin/camera/PS3Eye Camera-75.yml | 22 | ||||
-rw-r--r-- | ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 16 | ||||
-rw-r--r-- | ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 28 | ||||
-rw-r--r-- | ftnoir_tracker_pt/ftnoir_tracker_pt.h | 1 | ||||
-rw-r--r-- | ftnoir_tracker_pt/point_tracker.cpp | 9 | ||||
-rw-r--r-- | opentrack/opencv-calibration.hpp | 44 |
11 files changed, 7 insertions, 203 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f0685ee..16f779d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -546,8 +546,6 @@ 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}/macosx/make-app-bundle.sh\" diff --git a/bin/camera/Logitech HD Webcam C525.yml b/bin/camera/Logitech HD Webcam C525.yml deleted file mode 100644 index ac1bc981..00000000 --- a/bin/camera/Logitech HD Webcam C525.yml +++ /dev/null @@ -1,22 +0,0 @@ -%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/ManyCam Video Source-56.yml b/bin/camera/ManyCam Video Source-56.yml deleted file mode 100644 index 6859d0fb..00000000 --- a/bin/camera/ManyCam Video Source-56.yml +++ /dev/null @@ -1,22 +0,0 @@ -%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/bin/camera/ManyCam Video Source-75.yml b/bin/camera/ManyCam Video Source-75.yml deleted file mode 100644 index bf8fe0d3..00000000 --- a/bin/camera/ManyCam Video Source-75.yml +++ /dev/null @@ -1,22 +0,0 @@ -%YAML:1.0 -calibration_time: "07/20/15 04:51:53" -image_width: 640 -image_height: 480 -board_width: 5 -board_height: 5 -square_size: 1. -flags: 0 -camera_matrix: !!opencv-matrix - rows: 3 - cols: 3 - dt: d - data: [ 7.1311062261797588e+002, 0., 2.8104464540018199e+002, 0., - 7.0668490426304095e+002, 2.7903331411454337e+002, 0., 0., 1. ] -distortion_coefficients: !!opencv-matrix - rows: 5 - cols: 1 - dt: d - data: [ -2.2697038330479780e-001, 9.3383028790481815e-001, - 1.0716120533882623e-002, -9.0372250512977884e-003, - -1.7702927181212214e+000 ] -avg_reprojection_error: 1.7556161579210681e+000 diff --git a/bin/camera/PS3Eye Camera-56.yml b/bin/camera/PS3Eye Camera-56.yml deleted file mode 100644 index 6859d0fb..00000000 --- a/bin/camera/PS3Eye Camera-56.yml +++ /dev/null @@ -1,22 +0,0 @@ -%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/bin/camera/PS3Eye Camera-75.yml b/bin/camera/PS3Eye Camera-75.yml deleted file mode 100644 index bf8fe0d3..00000000 --- a/bin/camera/PS3Eye Camera-75.yml +++ /dev/null @@ -1,22 +0,0 @@ -%YAML:1.0 -calibration_time: "07/20/15 04:51:53" -image_width: 640 -image_height: 480 -board_width: 5 -board_height: 5 -square_size: 1. -flags: 0 -camera_matrix: !!opencv-matrix - rows: 3 - cols: 3 - dt: d - data: [ 7.1311062261797588e+002, 0., 2.8104464540018199e+002, 0., - 7.0668490426304095e+002, 2.7903331411454337e+002, 0., 0., 1. ] -distortion_coefficients: !!opencv-matrix - rows: 5 - cols: 1 - dt: d - data: [ -2.2697038330479780e-001, 9.3383028790481815e-001, - 1.0716120533882623e-002, -9.0372250512977884e-003, - -1.7702927181212214e+000 ] -avg_reprojection_error: 1.7556161579210681e+000 diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 8acddc28..2e488486 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -17,7 +17,6 @@ #include <opencv2/highgui/highgui.hpp> #include <opencv2/videoio.hpp> #include "opentrack/camera-names.hpp" -#include "opentrack/opencv-calibration.hpp" #include "opentrack/sleep.hpp" typedef struct { @@ -162,17 +161,10 @@ void Tracker::run() if (last_fov != s.fov) { last_fov = s.fov; - if (!get_camera_calibration(s.camera_name, intrinsics, dist_coeffs, grayscale.cols, grayscale.rows, s.fov)) - { - intrinsics.at<float> (0, 0) = focal_length_w; - intrinsics.at<float> (1, 1) = focal_length_h; - intrinsics.at<float> (0, 2) = grayscale.cols/2; - intrinsics.at<float> (1, 2) = grayscale.rows/2; - } - else - { - qDebug() << "got calibration"; - } + intrinsics.at<float> (0, 0) = focal_length_w; + intrinsics.at<float> (1, 1) = focal_length_h; + intrinsics.at<float> (0, 2) = grayscale.cols/2; + intrinsics.at<float> (1, 2) = grayscale.rows/2; } std::vector< aruco::Marker > markers; diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 48a62c2c..d166ad01 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -12,7 +12,6 @@ #include <QFile> #include <QCoreApplication> #include "opentrack/camera-names.hpp" -#include "opentrack/opencv-calibration.hpp" using namespace std; using namespace cv; @@ -55,8 +54,6 @@ void Tracker_PT::reset_command(Command command) float Tracker_PT::get_focal_length() { QMutexLocker l(&camera_mtx); - if (!intrinsics.empty()) - return intrinsics.at<float>(0, 0); CamInfo info = camera.get_info(); const int w = info.res_x, h = info.res_y; static constexpr double pi = 3.1415926f; @@ -99,16 +96,7 @@ void Tracker_PT::run() if (success) { - if (!intrinsics.empty()) - { - std::vector<cv::Vec2f> points_; - cv::undistortPoints(points, points_, intrinsics, dist_coeffs); - point_tracker.track(points_, PointModel(s), get_focal_length(), s.dynamic_pose, s.init_phase_timeout); - } - else - { - point_tracker.track(points, PointModel(s), get_focal_length(), s.dynamic_pose, s.init_phase_timeout); - } + point_tracker.track(points, PointModel(s), get_focal_length(), s.dynamic_pose, s.init_phase_timeout); } { @@ -159,20 +147,6 @@ void Tracker_PT::apply_settings() camera.set_res(s.cam_res_x, s.cam_res_y); camera.set_fps(s.cam_fps); camera.start(); - cv::Mat intrinsics_ = cv::Mat::eye(3, 3, CV_32FC1); - cv::Mat dist_coeffs_ = cv::Mat::zeros(5, 1, CV_32FC1); - intrinsics = cv::Mat(); - dist_coeffs = cv::Mat(); - auto info = camera.get_info(); - if (info.res_x == 0 || info.res_y == 0) - return; - if (get_camera_calibration(s.camera_name, intrinsics_, dist_coeffs_, info.res_x, info.res_y, s.fov)) - { - intrinsics = intrinsics_.clone(); - dist_coeffs = dist_coeffs_.clone(); - qDebug() << s.camera_name << "calibrated"; - } - qDebug()<<"Tracker::apply ends"; } diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h index 97aa54aa..b303a913 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h @@ -72,7 +72,6 @@ private: Timer time; volatile bool ever_success; - cv::Mat intrinsics, dist_coeffs; static constexpr double rad2deg = 180.0/3.14159265; static constexpr double deg2rad = 3.14159265/180.0; diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp index f141fe36..b4283d37 100644 --- a/ftnoir_tracker_pt/point_tracker.cpp +++ b/ftnoir_tracker_pt/point_tracker.cpp @@ -259,14 +259,9 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order_, float X_CM.t[1] = order[0][1] * Z0/focal_length; X_CM.t[2] = Z0; - return i; + //qDebug() << "iter:" << i; - //Rodrigues(X_CM.R, r); - //qDebug()<<"iter: "<<i; - //qDebug()<<"t: "<<X_CM.t[0]<<' '<<X_CM.t[1]<<' '<<X_CM.t[2]; - //Vec3f r; - // - //qDebug()<<"r: "<<r[0]<<' '<<r[1]<<' '<<r[2]<<'\n'; + return i; } cv::Vec2f PointTracker::project(const cv::Vec3f& v_M, float f) diff --git a/opentrack/opencv-calibration.hpp b/opentrack/opencv-calibration.hpp deleted file mode 100644 index 99e6d4c7..00000000 --- a/opentrack/opencv-calibration.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2015, Stanislaw Halik <sthalik@misaki.pl> - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#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, int fov) -{ - const QString pathnames[] = { - QCoreApplication::applicationDirPath() + "/camera/" + camera_name + "-" + QString::number(fov) + ".yml", - QCoreApplication::applicationDirPath() + "/camera/" + camera_name + ".yml", - }; - for (auto& pathname : pathnames) - { - cv::FileStorage fs(pathname.toStdString(), cv::FileStorage::READ); - if (!fs.isOpened()) - continue; - cv::Mat intrinsics_, distortion_; - fs["camera_matrix"] >> intrinsics_; - fs["distortion_coefficients"] >> distortion_; - int w_, h_; - fs["image_width"] >> w_; - fs["image_height"] >> h_; - double w__ = w_, h__ = h_; - intrinsics_.at<float>(0, 0) *= w / w__; - intrinsics_.at<float>(2, 0) *= w / w__; - intrinsics_.at<float>(1, 1) *= h / h__; - intrinsics_.at<float>(2, 1) *= h / h__; - intrinsics = intrinsics_; - distortion = distortion_; - return true; - } - return false; -} |