Skip to content
Snippets Groups Projects
Commit 4f23e877 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

serialize calibration data with msgpack

parent 2f2dcc95
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
......@@ -297,25 +297,24 @@ void ExtrinsicCalibration::run() {
future_ = ftl::pool.push([this](int id) {
try {
state_.calib.run();
LOG(INFO) << "Before:"; // DEBUG INFO
for (int c1 = 0; c1 < cameraCount(); c1++) {
for (int c2 = c1; c2 < cameraCount(); c2++) {
auto t1 = state_.calib.calibration(c1).extrinsic.tvec;
auto t2 = state_.calib.calibration(c2).extrinsic.tvec;
for (int c = 0; c < cameraCount(); c += 2) {
auto t1 = state_.calib.calibration(c).extrinsic.tvec;
auto t2 = state_.calib.calibration(c + 1).extrinsic.tvec;
LOG(INFO) << "baseline (" << c1 << ", " << c2 << "): "
LOG(INFO) << "baseline (" << c << ", " << c + 1 << "): "
<< cv::norm(t1, t2);
}}
}
state_.calib.run();
LOG(INFO) << "After:"; // DEBUG INFO
for (int c1 = 0; c1 < cameraCount(); c1++) {
for (int c2 = c1; c2 < cameraCount(); c2++) {
auto t1 = state_.calib.calibrationOptimized(c1).extrinsic.tvec;
auto t2 = state_.calib.calibrationOptimized(c2).extrinsic.tvec;
for (int c = 0; c < cameraCount(); c += 2) {
auto t1 = state_.calib.calibrationOptimized(c).extrinsic.tvec;
auto t2 = state_.calib.calibrationOptimized(c + 1).extrinsic.tvec;
LOG(INFO) << "baseline (" << c1 << ", " << c2 << "): "
LOG(INFO) << "baseline (" << c << ", " << c + 1 << "): "
<< cv::norm(t1, t2);
}}
}
// Rectification maps for visualization; stereo cameras assumed
// if non-stereo cameras added visualization/grouping (by index)
......
......@@ -5,6 +5,8 @@
#include <ftl/calibration/optimize.hpp>
#include <opencv2/core.hpp>
#include <ftl/utility/msgpack.hpp>
#include <set>
namespace ftl {
......@@ -34,6 +36,8 @@ public:
std::vector<cv::Point3_<T>>> triangulated;
bool has(unsigned int c) const { return (cameras & (uint64_t(1) << c)); }
MSGPACK_DEFINE(cameras, object, points, triangulated);
};
CalibrationPoints() : count_(0), visibility_(64), current_{0, ~(unsigned int)(0), {}, {}} {};
......@@ -99,6 +103,9 @@ private:
Points current_;
std::vector<Points> points_;
std::vector<std::vector<cv::Point3_<T>>> objects_;
public:
MSGPACK_DEFINE(count_, visibility_, points_, objects_);
};
/**
......
......@@ -5,6 +5,8 @@
#include <vector>
#include <string>
#include <ftl/utility/msgpack.hpp>
namespace ftl {
namespace calibration {
......@@ -89,6 +91,9 @@ class Visibility {
std::vector<std::vector<int>> graph_;
// masked values (mask_[i][j]) are not used
std::vector<std::vector<bool>> mask_;
public:
MSGPACK_DEFINE(n_cameras_, n_max_, graph_, mask_);
};
}
......
#include <loguru.hpp>
#include <ftl/exception.hpp>
#include <ftl/calibration/optimize.hpp>
#include <ftl/calibration/extrinsic.hpp>
......@@ -416,8 +415,11 @@ void ExtrinsicCalibration::calculatePairPoses() {
auto object = points().getObject(0);
cv::Mat R, t;
std::vector<cv::Point3d> points3d;
calibratePair(K1, distCoeffs1, K2, distCoeffs2, pts[0], pts[1], object,
R, t, points3d, true);
auto rms = calibratePair(K1, distCoeffs1, K2, distCoeffs2,
pts[0], pts[1], object, R, t, points3d, true);
// debug info
LOG(INFO) << "RMSE (cameras " << c1 << " & " << c2 << "): " << rms;
points().setTriangulatedPoints(c1, c2, points3d);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment