From 58a4fb02831f2453686c5d05acce29aa72113162 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Tue, 19 Mar 2019 14:55:44 +0200
Subject: [PATCH] Support variable delay in calibration

---
 cv-node/config/config.json        | 6 +++---
 cv-node/include/ftl/calibrate.hpp | 2 +-
 cv-node/src/calibrate.cpp         | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/cv-node/config/config.json b/cv-node/config/config.json
index f14b58abd..a634c12ff 100644
--- a/cv-node/config/config.json
+++ b/cv-node/config/config.json
@@ -8,8 +8,8 @@
 	"calibration": {
 		"board_size": [9,6],
 		"square_size": 50,
-		"frame_delay": 100,
-		"num_frames": 25,
+		"frame_delay": 1.0,
+		"num_frames": 35,
 		"assume_zero_tangential_distortion": true,
 		"fix_aspect_ratio": true,
 		"fix_principal_point_at_center": true,
@@ -33,7 +33,7 @@
 	"disparity": {
 		"algorithm": "rtcensus",
 		"use_cuda": true,
-		"minimum": 10,
+		"minimum": 0,
 		"maximum": 208,
 		"tau": 0.0,
 		"gamma": 0.0,
diff --git a/cv-node/include/ftl/calibrate.hpp b/cv-node/include/ftl/calibrate.hpp
index 2539864f0..99d690847 100644
--- a/cv-node/include/ftl/calibrate.hpp
+++ b/cv-node/include/ftl/calibrate.hpp
@@ -35,7 +35,7 @@ class Calibrate {
 		float squareSize;            // The size of a square in your defined unit (point, millimeter,etc).
 		int nrFrames;                // The number of frames to use from the input for calibration
 		float aspectRatio;           // The aspect ratio
-		int delay;                   // In case of a video input
+		float delay;                   // In case of a video input
 		bool writePoints;            // Write detected feature points
 		bool writeExtrinsics;        // Write extrinsic parameters
 		bool writeGrid;              // Write refined 3D target grid points
diff --git a/cv-node/src/calibrate.cpp b/cv-node/src/calibrate.cpp
index c4e07f071..403ad8f9e 100644
--- a/cv-node/src/calibrate.cpp
+++ b/cv-node/src/calibrate.cpp
@@ -409,7 +409,7 @@ bool Calibrate::_recalibrate(vector<vector<Point2f>> *imagePoints,
 		found1 = findChessboardCorners( view[0], settings_.boardSize, pointBuf[0], chessBoardFlags);
 		found2 = !local_->isStereo() || findChessboardCorners( view[1], settings_.boardSize, pointBuf[1], chessBoardFlags);
       
-        if (found1 && found2 && local_->getTimestamp()-prevTimestamp > 0.5)                // If done with success,
+        if (found1 && found2 && local_->getTimestamp()-prevTimestamp > settings_.delay)                // If done with success,
         {
 			prevTimestamp = local_->getTimestamp();
               // improve the found corners' coordinate accuracy for chessboard
-- 
GitLab