1

I'm writing a python script to perform camera calibration with OpenCV.

I found that the cv2.findChessboardCorners function may take very long to run on certain images.

I would therefore like to be able to stop the function after a certain period of time has passed, and move on to the next image.

How do I do that?

for fname in images:        
    img = cv2.imread(fname)                            
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    ret, corners = cv2.findChessboardCorners(gray, (20, 17), None)   
Employee
  • 2,434
  • 3
  • 22
  • 42
  • 1
    This answer might have some possible solutions: [break the function after certain time](https://stackoverflow.com/questions/25027122/break-the-function-after-certain-time) – G. Anderson Dec 12 '18 at 23:12
  • 1
    Possibly related, helpful or dupe of [Timeout function if it takes too long to finish \[duplicate\]](https://stackoverflow.com/questions/2281850/timeout-function-if-it-takes-too-long-to-finish) or [Timeout on a function call](https://stackoverflow.com/questions/492519/timeout-on-a-function-call) – davedwards Dec 12 '18 at 23:12

0 Answers0