findChessboardCornersSB: speed improvements#12615
Conversation
| @param flags operation flags for future improvements | ||
| @param flags Various operation flags that can be zero or a combination of the following values: | ||
| - **CALIB_CB_NORMALIZE_IMAGE** Normalize the image gamma with equalizeHist before detection. | ||
| - **CALIB_CB_EXAUSTING ** Run an exhausting search to improve detection rate. |
There was a problem hiding this comment.
Maybe change to CALIB_CB_EXHAUSTIVE?
I understand this option like a brute-force approach. In this case, exhaustive search looks more appropriate in my opinion.
This also fixes a typo
modules/calib3d/src/chessboard.cpp
Outdated
| flags ^= CALIB_CB_ACCURACY; | ||
| } | ||
| if(flags) | ||
| CV_Error(Error::StsOutOfRange, "Invalid remaing flags " + std::to_string(flags)); |
There was a problem hiding this comment.
GCC 4.8 (Android builder) has bad support for std::to_string().
Please use this code:
CV_Error(Error::StsOutOfRange, cv::format("Invalid remaing flags %d", (int)flags));
modules/calib3d/src/chessboard.cpp
Outdated
| } | ||
| }); | ||
| // check if a good board was found | ||
| for(auto board : boards) |
|
@D-Alex did you check the chessboard detection rate of findChessboardCorners vs findChessboardCornersSB ? I tested both functions (opencv4.0.0 alpha and not master) and findChessboardCorners seems to outperform findChessboardCornersSB in terms of chessboard detection rate. Check out this video: https://www.youtube.com/watch?v=ImpxJSIbBdk I played the sequence twice. first with findChessboardCorners (red) and then again with findChessboardCorners SB (green) I think about 30% of the chessboard detections are missing. I admit that shirt is not necessarily the best for doing calibrations, but findChessboardCorners had no problems with that. |
|
Thx for reporting problems with the detection rate and I am sure there is room for improvements. Have you tested it against the current version merged yesterday? I am asking because I changed MIN_RESPONSE_RATIO from 0.3F to= 0.1F which was added to speed up detections. However, this filters out points which are less than 30% of the strongest key points. And this is exactly the case in your images. I tested your last image and it seems to work with the current version if CALIB_CB_NORMALIZE_IMAGE is added as flag. Attached is the repsonse map of the detector which looks very healthy. |
|
Thank you for your fast response. As mentioned i have only tested against 4.0.0-alpha. Do you know if it is possible to download master build artifacts for windows from the opencv buildservers? |
We don't provide such builds on public. |
|
findChessboardCornersSB part of the alpha build is not really aware of the flags. This was added yesterday. Therefore, to work around the issue you can do the normalisation by yourself calling equalizeHist before calling findChessboardCornersSB. In addition you can provide 1 as flag to increase the number of tests. However, the alpha version does not take advantage of multiple CPUs for around half of the code base. Also you still have the hard coded 30% threshold which might be ok if you normalise your images. |
|
cv::equalizeHist(mat, mat); before findChessboardCornersSB(...) improved the detection from 0% to about 50% for the sequence of the image of which you made a responsemap for me. So i guess ill have to recompile master with a lower MIN_RESPONSE_RATIO. providing 1 as a flag for findChessboardCornersSB flags parameter crashes my application. Probably some assertion, but i didnt investigate. |
|
Yep - the assertion was also fixed when the flags were implemented. I forgot about it. If you upload your sequence somewhere I can run it with the current version. Otherwise you would have to compile it using the current master. |
|
I compiled master and it still crashes with 1 (CALIB_CB_ADAPTIVE_THRESH) OpenCV(4.0.0-pre) C:\3rdparty\ocv4_master\opencv\modules\calib3d\src\chessboard.cpp:3211: error: (-211:One of arguments' values is out of range) Invalid remaing flags 1 in function 'cv::findChessboardCornersSB' |
|
Like stated in the header (I know it is hard to read when not compiled ;-)) it only supports: CALIB_CB_NORMALIZE_IMAGE = 2 |
|
I have seen the documentation but you mentioned "In addition you can provide 1 as flag to increase the number of tests." before. I also took a look at the code now and there i clearly see that 1 is not supported :-) |
|
i guess you meant 16 instead of 1 |
|
flags = cv::CALIB_CB_NORMALIZE_IMAGE | cv::CALIB_CB_EXHAUSTIVE | cv::CALIB_CB_ACCURACY; With flags as above the detection rate is much better but i still have many "easy" chessboards that aren't detected. If you want, i can provide you some of them. Another question: What did you use to enable parallel_for_? According to the link below a few options are available. Did you just enable openMP? https://docs.opencv.org/trunk/d7/dff/tutorial_how_to_use_OpenCV_parallel_for_.html The first precondition is to have OpenCV built with a parallel framework. In OpenCV 3.2, the following parallel frameworks are available in that order: |
|
Sure - I am happy to have a look why certain checkerboards are not detected. I am using a Mac therefore I would guess option 4. |
|
Alright, i will send you some images during the next week. With findChessboardCorners I used cornerSubPix to refine the corner locations. Am I assuming correctly that cornerSubPix would only degrade the corner locations from your algorithm? |
* master: (286 commits) Merge pull request opencv#12608 from dmatveev:gapi M_PI changed to CV_PI (opencv#12645) dnn: fix printf format warning Merge pull request opencv#12615 from D-Alex:master Fixed several incorrect printf format specifiers core: fix printf warnings by using c++11 format core: enable printf format warnings for cv::format JS: Support enum properties fix a bug in OpenGL samples: update winpack python samples launcher Merge pull request opencv#12310 from cv3d:chunks/enum_interface Merge pull request opencv#12601 from cv3d:fix/js release: OpenCV 4.0.0-alpha (version++) cuda: move CUDA modules to opencv_contrib cmake: update install paths (Linux) Merge pull request opencv#12570 from alalek:drop_usrtype1 Fix failure to request stddev of non-intrinsics ts: update valgrind test filter build: fix Xcode 10 build problems Enable Myriad device for OpenVINO models test ...
findChessboardCornersSB: speed improvements (opencv#12615) * chessboard: fix do not modify const image * chessboard: speed up scale space using parallel_for * chessboard: small improvements * chessboard: speed up board growing using parallel_for * chessboard: add flags for tuning detection * chessboard: fix compiler warnings * chessborad: change flag name to CALIB_CB_EXHAUSTIVE This also fixes a typo * chessboard: fix const ref + remove to_string


findChessboardCornersSB: speed up using parallel_for and add support for flags