gyroflow icon indicating copy to clipboard operation
gyroflow copied to clipboard

Camera calibration takes forever

Open fdev31 opened this issue 2 years ago • 1 comments

During camera calibration there are two issues:

  1. when the checker can't be found, it can take ages (minutes) after pressing the button
  2. there is no clear feedback when the checker wasn't found but the processing is over: if consecutive failures happens, there is no change on the screen (the current error message isn't cleared out when "Add current frame" is pressed)

I patched my local copy to mitigate 1 by using "fast check" mode, the normalization part can probably be dropped, it was just an experiment:

diff --git a/calibrate_video.py b/calibrate_video.py
index 4c35153..0d3bafc 100644
--- a/calibrate_video.py
+++ b/calibrate_video.py
@@ -163,11 +163,12 @@ class FisheyeCalibrator:
         gray = cv2.cvtColor(self.stretch_image(img),cv2.COLOR_BGR2GRAY)
 
         # Find the chess board corners
-        ret, corners = cv2.findChessboardCorners(gray, self.chessboard_size, None)
+        ret, corners = cv2.findChessboardCorners(gray, self.chessboard_size, flags=cv2.CALIB_CB_FAST_CHECK + cv2.CALIB_CB_NORMALIZE_IMAGE)
 
         if not ret:
             return (False, "Failed to detect chessboard", None)
 
+        ret, corners = cv2.findChessboardCorners(gray, self.chessboard_size, flags=cv2.CALIB_CB_NORMALIZE_IMAGE)
 
         # If found, add object points, image points (after refining them)
         self.num_images += 1

Some big red cross or question mark over the image could indicate it failed... but I didn't browse the code enough (and don't know Qt...) to figure it out.

fdev31 avatar Nov 28 '21 12:11 fdev31

Thanks for the feedback!

ElvinC avatar Dec 13 '21 22:12 ElvinC