Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
findChessboardCorners performance degradation fix for some cases#24558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
asmorkalov commentedNov 20, 2023
@thewoz Thanks a lot for the contribution. The PR introduces existing test regression: |
thewoz commentedNov 20, 2023
sorry where I can found the chess3.png images? |
s-trinh commentedNov 20, 2023
thewoz commentedNov 20, 2023
Hi, in https://github.com/opencv/opencv_extra/tree/4.x/testdata/cv/cameracalibration and the chessboard was found in each of them. |
vpisarev commentedNov 21, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@thewoz, basically, you should clone opencv_extra repository and then set OPENCV_TEST_DATA_PATH environment variable pointing to <opencv_extra_dir>/testdata. After that just run opencv_test_calib3d and opencv_perf_calib3d. |
thewoz commentedNov 21, 2023
Hi, |
AleksandrPanov commentedNov 22, 2023
|
thewoz commentedNov 23, 2023
Hello everyone, |
thewoz commentedNov 24, 2023
sorry I forgot to erase a include file that I use for the debug |
thewoz commentedDec 1, 2023
Hello everyone is there anything else I can do ? |
asmorkalov commentedDec 1, 2023
@vpisarev could you take a look too? |
thewoz commentedDec 14, 2023
is there anything i can do? |
vpisarev commentedDec 19, 2023
@thewoz, thank you! I think, the patch can be merged. |
AleksandrPanov left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
- need to fix extra
\n - what is the performance? reabase to#24605 (comment), this PR improves performance.
- I suggest to use
approxPolyDP()insteadbox_area_covered(check line 1795 in calibinit.cpp)
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| float box_area = box.size.width * box.size.height; | ||
| if(contourArea(c) < (box_area_covered * box_area)) | ||
| { | ||
| continue; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think it's a good idea. We need to understand how much the found contour looks like a square of a chessboard. We could useapproxPolyDP() for this. We could use algorithm from_findMarkerContours() inArucoDetector:
// check is square and is convex vector<Point> approxCurve; approxPolyDP(contours[i], approxCurve, double(contours[i].size()) * accuracyRate, true); if(approxCurve.size() != 4 || !isContourConvex(approxCurve)) continue; // check min distance between corners double minDistSq = max(contoursImg.cols, contoursImg.rows) * max(contoursImg.cols, contoursImg.rows); for(int j = 0; j < 4; j++) { double d = (double)(approxCurve[j].x - approxCurve[(j + 1) % 4].x) * (double)(approxCurve[j].x - approxCurve[(j + 1) % 4].x) + (double)(approxCurve[j].y - approxCurve[(j + 1) % 4].y) * (double)(approxCurve[j].y - approxCurve[(j + 1) % 4].y); minDistSq = min(minDistSq, d); } double minCornerDistancePixels = double(contours[i].size()) * minCornerDistanceRate; if(minDistSq < minCornerDistancePixels * minCornerDistancePixels) continue;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hi@AleksandrPanov I never perform a rebase.
Can you help me? Sorry about that...
for now I fixed the returns and tested with approxPolyDP() and everything seems to be working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
checkout your branch to 4.x, update your 4.x branch fromhttps://github.com/opencv/opencv, checkout your branch tofix-issue-23558, rebase and resolve conflicts:
git checkout 4.xgit pull https://github.com/opencv/opencvgit checkout fix-issue-23558git rebase 4.xgit push -fUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
fix tab arrow issue
Add weights yolov3 in models.ymlopencv#24496### Pull Request Readiness ChecklistSee details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [X] I agree to contribute to the project under Apache 2 License.- [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [X] The PR is proposed to the proper branch- [X] There is a reference to the original bug report and related work- [X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [X] The feature is well documented and sample code can be built with the project CMakeI don't know if this action is necessary, or the previous PR scale for the brach master.Thanks.
Handle huge images in IPP distanceTransformopencv#24535### Pull Request Readiness Checklist* Do not use IPP for huge Mat (reproduced withopencv#23895 (comment) on `DIST_MASK_5`) I have observed two types of errors on the reproducer from the issue: 1. When `temp` is not allocated: ``` Thread 1 "app" received signal SIGSEGV, Segmentation fault. 0x00007ffff65dc755 in icv_l9_ownDistanceTransform_5x5_8u32f_C1R_21B_g9e9 () from /home/dkurtaev/opencv_install/bin/../lib/libopencv_imgproc.so.408 (gdb) bt #0 0x00007ffff65dc755 in icv_l9_ownDistanceTransform_5x5_8u32f_C1R_21B_g9e9 () from /home/dkurtaev/opencv_install/bin/../lib/libopencv_imgproc.so.408opencv#1 0x00007ffff659e8df in icv_l9_ippiDistanceTransform_5x5_8u32f_C1R () from /home/dkurtaev/opencv_install/bin/../lib/libopencv_imgproc.so.408opencv#2 0x00007ffff5c390f0 in cv::distanceTransform (_src=..., _dst=..., _labels=..., distType=2, maskSize=5, labelType=1) at /home/dkurtaev/opencv/modules/imgproc/src/distransform.cpp:854opencv#3 0x00007ffff5c396ef in cv::distanceTransform (_src=..., _dst=..., distanceType=2, maskSize=5, dstType=5) at /home/dkurtaev/opencv/modules/imgproc/src/distransform.cpp:903opencv#4 0x000055555555669e in main (argc=1, argv=0x7fffffffdef8) at /home/dkurtaev/main.cpp:18 ``` 2. When we keep `temp` allocated every time: ``` OpenCV(4.8.0-dev) Error: Assertion failed (udata < (uchar*)ptr && ((uchar*)ptr - udata) <= (ptrdiff_t)(sizeof(void*)+64)) in fastFree, file /home/dkurtaev/opencv/modules/core/src/alloc.cpp, line 191 terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.8.0-dev) /home/dkurtaev/opencv/modules/core/src/alloc.cpp:191: error: (-215:Assertion failed) udata < (uchar*)ptr && ((uchar*)ptr - udata) <= (ptrdiff_t)(sizeof(void*)+64) in function 'fastFree' ```* Try enable IPP for 3x3 (seeopencv#15904)* Reduce memory footprint with IPPSee details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [x] I agree to contribute to the project under Apache 2 License.- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [x] The PR is proposed to the proper branch- [x] There is a reference to the original bug report and related work- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [x] The feature is well documented and sample code can be built with the project CMake
…n and bug fix (opencv#24462)* add hardswish for cann* gemm cann bug fix* fix indentation* cann: add layer norm* cann: add instance norm* add supportBackend* cann: layer norm does not support axis=-1 due to 1d mat issue* disable instance norm for now* fix doc* remove tensor desc initialization for 1D tensor
…e-selection-onnxrt-directmlG-API: Advanced device selection for ONNX DirectML Execution Provideropencv#24060### OverviewExtend `cv::gapi::onnx::ep::DirectML` to accept `adapter name` as `ctor` parameter in order to select execution device by `name`.E.g:```pp.cfgAddExecutionProvider(cv::gapi::onnx::ep::DirectML("Intel Graphics"));```### Pull Request Readiness ChecklistSee details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [ ] I agree to contribute to the project under Apache 2 License.- [ ] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [ ] The PR is proposed to the proper branch- [ ] There is a reference to the original bug report and related work- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [ ] The feature is well documented and sample code can be built with the project CMake
Using cv2 dnn interface to run yolov8 modelopencv#24396This is a sample code for using opencv dnn interface to run ultralytics yolov8 model for object detection.### Pull Request Readiness ChecklistSee details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [X] I agree to contribute to the project under Apache 2 License.- [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [X] The PR is proposed to the proper branch- [] There is a reference to the original bug report and related work- [] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [] The feature is well documented and sample code can be built with the project CMake
…_gemmFast gemm for einsumopencv#24509## This PR adds performance tests for Einsum Layer with FastGemm. See below results of performance test on different inputs### Pull Request Readiness ChecklistSee details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [x] I agree to contribute to the project under Apache 2 License.- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [x] The PR is proposed to the proper branch- [ ] There is a reference to the original bug report and related work- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [x] The feature is well documented and sample code can be built with the project CMake
…on-estimatorBugfix/qrcode version estimatoropencv#24364Fixesopencv#24366### Pull Request Readiness ChecklistSee details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [x] I agree to contribute to the project under Apache 2 License.- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [x] The PR is proposed to the proper branch- [x] There is a reference to the original bug report and related work- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [x] The feature is well documented and sample code can be built with the project CMake
Updated Android samples for modern Android studio. Added OpenCV from Maven support.opencv#24473Updated samples for recent Android studio:- added namespace field that is required in build.gradle files- replaced _switch_ by _if-else_ because it doesn't work with constants from resources- added missed log library dependency in face-detection/jni/CMakeLists.txt- use local.properties to define NDK locationAdded support for OpenCV from Maven. Now you can choose 3 possible sources of OpenCV lib in settings.gradle: SDK path, local Maven repository, public Maven repository. (Creating Maven repository from SDK is added hereopencv#24456 )There are differences in project configs for SDK and Maven versions:- different dependencies in build.gradle- different OpenCV library names in CMakeLists.txt- SDK version requires OpenCV_DIR definitionRequires:-opencv/ci-gha-workflow#124-opencv-infrastructure/opencv-gha-dockerfile#26
thewoz commentedJan 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hello everyone, |
AleksandrPanov commentedJan 10, 2024
@thewoz, I tried to use the approxPolyDP() func too, and it really wasn't working too well. You could try to call this function twice, but it doesn't look like a good solution. Now I think that use |
thewoz commentedJan 10, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hi@AleksandrPanov thank you for your time.. |
AleksandrPanov commentedJan 15, 2024
@thewoz, there are not enough tests in OpenCV for findchessboardcorners() and therefore algorithm changes can cause regressions that we may not catch. We want to expand the test suite, but this is a big task. After that, we will try to improve the code based on your ideas. |
thewoz commentedJan 15, 2024
Hi@AleksandrPanov, |
Uh oh!
There was an error while loading.Please reload this page.
Fixes#23558
In the issue#23558 an empty image was passed to the findChessboardCorners() function with the CALIB_CB_FAST_CHECK flag. The fast check failed and findChessboardCorners() wasted 15minutes finding a checkerboard that was not there in the image.
The reason is that the checkChessboardBinary() function returned true because the checkQuads() function was convinced that among all the contours found by fillQuads() were those of the checkerboard.
The problem was icvGetQuadrangleHypotheses() that incorrectly filtering the contours found. It was passing too many contours to checkQuads(), and by the law of large numbers, checkQuads() was able to find contours that "looked" like a checkerboard between them.
What I did is to shrink the parameters in the icvGetQuadrangleHypotheses() function. I changed the range of the ratio between the sides of the contour found to 0.5 and 1.5. More reasonable values than the previous 0.3 and 3.0. In addition, I raised the minimum side length of the hypothetical square from 10 to 25 pixels.
After the change I tried the function on other checkerboard images and had no problems.
Pull Request Readiness Checklist
See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.