From daa4c00638520d5c638caf352175b0ffe1b33482 Mon Sep 17 00:00:00 2001 From: Florian Tschopp Date: Tue, 13 Nov 2018 12:40:39 +0100 Subject: [PATCH 1/9] switch to PIL library for Image --- .../kalibr/python/kalibr_camera_calibration/MulticamGraph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/MulticamGraph.py b/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/MulticamGraph.py index fdfd0d95f..541fba828 100644 --- a/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/MulticamGraph.py +++ b/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/MulticamGraph.py @@ -9,7 +9,7 @@ import itertools import sys import pylab as pl -import Image +from PIL import Image import time # make numpy print prettier From 0a58b384a30d15f26f123123c0cfcce52f5fb81d Mon Sep 17 00:00:00 2001 From: Florian Tschopp Date: Tue, 13 Nov 2018 12:41:02 +0100 Subject: [PATCH 2/9] deactivate threading for cv image displays --- aslam_cv/aslam_cameras/src/GridDetector.cpp | 1 - .../aslam_cameras_april/src/GridCalibrationTargetAprilgrid.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/aslam_cv/aslam_cameras/src/GridDetector.cpp b/aslam_cv/aslam_cameras/src/GridDetector.cpp index 93c2b237e..7fc354bcd 100644 --- a/aslam_cv/aslam_cameras/src/GridDetector.cpp +++ b/aslam_cv/aslam_cameras/src/GridDetector.cpp @@ -33,7 +33,6 @@ void GridDetector::initializeDetector() { if (_options.plotCornerReprojection) { cv::namedWindow("Corner reprojection"); - cvStartWindowThread(); } } diff --git a/aslam_cv/aslam_cameras_april/src/GridCalibrationTargetAprilgrid.cpp b/aslam_cv/aslam_cameras_april/src/GridCalibrationTargetAprilgrid.cpp index 277ee2199..2f4117a6c 100644 --- a/aslam_cv/aslam_cameras_april/src/GridCalibrationTargetAprilgrid.cpp +++ b/aslam_cv/aslam_cameras_april/src/GridCalibrationTargetAprilgrid.cpp @@ -58,7 +58,6 @@ void GridCalibrationTargetAprilgrid::initialize() if (_options.showExtractionVideo) { cv::namedWindow("Aprilgrid: Tag detection"); cv::namedWindow("Aprilgrid: Tag corners"); - cvStartWindowThread(); } //create the tag detector From d8fc0e29971e45c44854324ed78c8173b2ad8776 Mon Sep 17 00:00:00 2001 From: Hannes Sommer Date: Sun, 17 Feb 2019 14:02:43 +0100 Subject: [PATCH 3/9] Update MulticamGraph.py Preserve some backward compatibility with older python versions. --- .../kalibr/python/kalibr_camera_calibration/MulticamGraph.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/MulticamGraph.py b/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/MulticamGraph.py index 541fba828..d70e665ff 100644 --- a/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/MulticamGraph.py +++ b/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/MulticamGraph.py @@ -9,7 +9,10 @@ import itertools import sys import pylab as pl -from PIL import Image +try: + from PIL import Image # Modern +except ImportError: + import Image # Old import (backward compatibility) import time # make numpy print prettier From ee2b09d5cc00bf5c21dec6e30902593e0574cad0 Mon Sep 17 00:00:00 2001 From: Florian Tschopp Date: Mon, 22 Jul 2019 18:09:26 +0200 Subject: [PATCH 4/9] fix opencv windows --- aslam_cv/aslam_cameras/src/GridDetector.cpp | 2 +- .../src/GridCalibrationTargetAprilgrid.cpp | 4 ++-- .../python/kalibr_camera_calibration/CameraCalibrator.py | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/aslam_cv/aslam_cameras/src/GridDetector.cpp b/aslam_cv/aslam_cameras/src/GridDetector.cpp index 7fc354bcd..91b716c04 100644 --- a/aslam_cv/aslam_cameras/src/GridDetector.cpp +++ b/aslam_cv/aslam_cameras/src/GridDetector.cpp @@ -32,7 +32,7 @@ GridDetector::GridDetector(boost::shared_ptr geometry, void GridDetector::initializeDetector() { if (_options.plotCornerReprojection) { - cv::namedWindow("Corner reprojection"); + cv::namedWindow("Corner reprojection", cv::WINDOW_NORMAL); } } diff --git a/aslam_cv/aslam_cameras_april/src/GridCalibrationTargetAprilgrid.cpp b/aslam_cv/aslam_cameras_april/src/GridCalibrationTargetAprilgrid.cpp index 2f4117a6c..44420e621 100644 --- a/aslam_cv/aslam_cameras_april/src/GridCalibrationTargetAprilgrid.cpp +++ b/aslam_cv/aslam_cameras_april/src/GridCalibrationTargetAprilgrid.cpp @@ -56,8 +56,8 @@ GridCalibrationTargetAprilgrid::GridCalibrationTargetAprilgrid() : void GridCalibrationTargetAprilgrid::initialize() { if (_options.showExtractionVideo) { - cv::namedWindow("Aprilgrid: Tag detection"); - cv::namedWindow("Aprilgrid: Tag corners"); + cv::namedWindow("Aprilgrid: Tag detection", cv::WINDOW_NORMAL); + cv::namedWindow("Aprilgrid: Tag corners", cv::WINDOW_NORMAL); } //create the tag detector diff --git a/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/CameraCalibrator.py b/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/CameraCalibrator.py index a191d2913..cba2c186c 100644 --- a/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/CameraCalibrator.py +++ b/aslam_offline_calibration/kalibr/python/kalibr_camera_calibration/CameraCalibrator.py @@ -598,8 +598,11 @@ def printParameters(cself, dest=sys.stdout): corners, reprojs, rerrs = getReprojectionErrors(cself, cidx) if len(rerrs)>0: me, se = getReprojectionErrorStatistics(rerrs) - print >> dest, "\t reprojection error: [%f, %f] +- [%f, %f]" % (me[0], me[1], se[0], se[1]) - print >> dest + try: + print >> dest, "\t reprojection error: [%f, %f] +- [%f, %f]" % (me[0], me[1], se[0], se[1]) + except: + print >> dest, "\t Failed printing the reprojection error." + print >> dest #print baselines for bidx, baseline in enumerate(cself.baselines): From 732e551e9c95557785420342ede95d2a7f6a3bc3 Mon Sep 17 00:00:00 2001 From: Florian Tschopp Date: Tue, 1 Oct 2019 17:11:35 +0200 Subject: [PATCH 5/9] add option to manually input forcal length --- .../cameras/implementation/PinholeProjection.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp index 03600184b..181c6f068 100644 --- a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp +++ b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp @@ -1,5 +1,6 @@ #include #include +#include namespace aslam { @@ -777,9 +778,15 @@ bool PinholeProjection::initializeIntrinsics(const std::vector> input_guess; + std::cout << "Initialize focal length to " << input_guess << "\n"; + f_guesses.push_back(static_cast(input_guess)); + } double f0 = PinholeHelpers::medianOfVectorElements(f_guesses); //set the estimate From a5186202b7bf1db7d9e0828ef24dff2bba43340d Mon Sep 17 00:00:00 2001 From: Florian Tschopp Date: Wed, 2 Oct 2019 11:20:46 +0200 Subject: [PATCH 6/9] remove debug option --- .../include/aslam/cameras/implementation/PinholeProjection.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp index 181c6f068..74119dc29 100644 --- a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp +++ b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp @@ -779,7 +779,6 @@ bool PinholeProjection::initializeIntrinsics(const std::vector Date: Tue, 22 Oct 2019 17:12:50 +0200 Subject: [PATCH 7/9] PR review @lbern --- .../aslam/cameras/implementation/PinholeProjection.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp index 74119dc29..dfedbc33f 100644 --- a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp +++ b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp @@ -783,8 +783,10 @@ bool PinholeProjection::initializeIntrinsics(const std::vector> input_guess; - std::cout << "Initialize focal length to " << input_guess << "\n"; - f_guesses.push_back(static_cast(input_guess)); + SM_ASSERT_GT(std::runtime_error, input_guess, 0.0f, + "Focal length needs to be positive."); + std::cout << "Initializing focal length to " << input_guess << "\n"; + f_guesses.push_back(static_cast(input_guess)); } double f0 = PinholeHelpers::medianOfVectorElements(f_guesses); From 7a296768776dbcff29ad514d467bfc9f26c68d66 Mon Sep 17 00:00:00 2001 From: Florian Tschopp Date: Tue, 22 Oct 2019 17:44:36 +0200 Subject: [PATCH 8/9] switch to double in the first place --- .../aslam/cameras/implementation/PinholeProjection.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp index dfedbc33f..bd62e01c3 100644 --- a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp +++ b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp @@ -780,13 +780,13 @@ bool PinholeProjection::initializeIntrinsics(const std::vector> input_guess; - SM_ASSERT_GT(std::runtime_error, input_guess, 0.0f, + SM_ASSERT_GT(std::runtime_error, input_guess, 0.0, "Focal length needs to be positive."); std::cout << "Initializing focal length to " << input_guess << "\n"; - f_guesses.push_back(static_cast(input_guess)); + f_guesses.push_back(input_guess); } double f0 = PinholeHelpers::medianOfVectorElements(f_guesses); From aac34c2abdc0bacc5ab12900e3d6ca9372e314ed Mon Sep 17 00:00:00 2001 From: Florian Tschopp Date: Mon, 3 Feb 2020 12:45:30 +0100 Subject: [PATCH 9/9] Revert "Merge pull request #304 from ethz-asl/feature/input_focal_length_guess" This reverts commit 2999e186ece1799cb6fd994f3cf23c6ef53e5d6f, reversing changes made to ee2b09d5cc00bf5c21dec6e30902593e0574cad0. --- .../cameras/implementation/PinholeProjection.hpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp index bd62e01c3..03600184b 100644 --- a/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp +++ b/aslam_cv/aslam_cameras/include/aslam/cameras/implementation/PinholeProjection.hpp @@ -1,6 +1,5 @@ #include #include -#include namespace aslam { @@ -778,16 +777,9 @@ bool PinholeProjection::initializeIntrinsics(const std::vector> input_guess; - SM_ASSERT_GT(std::runtime_error, input_guess, 0.0, - "Focal length needs to be positive."); - std::cout << "Initializing focal length to " << input_guess << "\n"; - f_guesses.push_back(input_guess); - } + //get the median of the guesses + if(f_guesses.empty()) + return false; double f0 = PinholeHelpers::medianOfVectorElements(f_guesses); //set the estimate