Skip to content

Conversation

@asmorkalov
Copy link
Contributor

@asmorkalov asmorkalov commented Oct 23, 2025

Replaces #27601
Merge with opencv/opencv_extra#1280

Pull Request Readiness Checklist

See details at https://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

@Liiizhen
Copy link

Hi! How can I commit to the new PR? It seems I don't have the permission to push updates to this PR branch.

@asmorkalov
Copy link
Contributor Author

@Liiizhen I sent invitation to you.

@Liiizhen
Copy link

Thanks! As you mentioned in pr 27601, we can generate a PNG file of a specific size by adjusting the parameter. Do you think it's necessary to output svg?

@asmorkalov asmorkalov self-assigned this Oct 30, 2025
@asmorkalov
Copy link
Contributor Author

SVG is vector format and we can ensure all sizes there. PNG may be scaled somehow during printing.

Comment on lines 786 to 789
return (1.f-decpartY)*(1.-decpartX)*float(im_grey.at<uchar>(tl.y,tl.x))+
decpartX*(1-decpartY)*float(im_grey.at<uchar>(tl.y,tl.x+1))+
(1-decpartX)*decpartY*float(im_grey.at<uchar>(tl.y+1,tl.x))+
decpartX*decpartY*float(im_grey.at<uchar>(tl.y+1,tl.x+1));
Copy link
Contributor Author

@asmorkalov asmorkalov Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug build indicates out-of-bound access issue in cv::Mat here:

Thread 1 "opencv_test_obj" hit Catchpoint 1 (exception thrown), 0x00007ffff3cbb35a in __cxxabiv1::__cxa_throw (obj=0x5555561d1ed0, tinfo=0x7ffff50d9400 <typeinfo for cv::Exception>, dest=0x7ffff448d30e <cv::Exception::~Exception()>)
    at ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc:81
warning: 81     ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc: No such file or directory
(gdb) bt
#0  0x00007ffff3cbb35a in __cxxabiv1::__cxa_throw (obj=0x5555561d1ed0, tinfo=0x7ffff50d9400 <typeinfo for cv::Exception>, dest=0x7ffff448d30e <cv::Exception::~Exception()>) at ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc:81
#1  0x00007ffff448fcbb in cv::error (exc=...) at /mnt/Projects/Projects/opencv/modules/core/src/system.cpp:1275
#2  0x00007ffff448fdac in cv::error (_code=-215, _err="(unsigned)i0 < (unsigned)size.p[0]", _func=0x7ffff7d8da0a "at", _file=0x7ffff7d8d6a0 "/mnt/Projects/Projects/opencv/modules/core/include/opencv2/core/mat.inl.hpp", _line=909)
    at /mnt/Projects/Projects/opencv/modules/core/src/system.cpp:1287
#3  0x00007ffff7c829e1 in cv::Mat::at<unsigned char> (this=0x7fffffffcd60, i0=3840, i1=1594) at /mnt/Projects/Projects/opencv/modules/core/include/opencv2/core/mat.inl.hpp:909
#4  0x00007ffff7c986ac in cv::aruco::FractalDetector::FractalDetectorImpl::getSubpixelValue (im_grey=..., p=...) at /mnt/Projects/Projects/opencv/modules/objdetect/src/aruco/fractal_detector.cpp:788
#5  0x00007ffff7c95e68 in cv::aruco::FractalDetector::detect (this=0x7fffffffd040, img=..., markers=std::vector of length 0, capacity 0, p3d=..., p2d=...) at /mnt/Projects/Projects/opencv/modules/objdetect/src/aruco/fractal_detector.cpp:564
#6  0x0000555555640401 in opencv_test::(anonymous namespace)::CV_FractalAruco_can_detect_Test::Body (this=0x5555561b1510) at /mnt/Projects/Projects/opencv/modules/objdetect/test/test_fractal_aruco.cpp:33
#7  0x000055555563fe14 in opencv_test::(anonymous namespace)::CV_FractalAruco_can_detect_Test::TestBody (this=0x5555561b1510) at /mnt/Projects/Projects/opencv/modules/objdetect/test/test_fractal_aruco.cpp:22
#8  0x00005555556c1378 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (object=0x5555561b1510, method=&virtual testing::Test::TestBody(), location=0x5555556f1353 "the test body")
    at /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3919
#9  0x00005555556bae52 in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=0x5555561b1510, method=&virtual testing::Test::TestBody(), location=0x5555556f1353 "the test body")
    at /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3955
#10 0x000055555569edb6 in testing::Test::Run (this=0x5555561b1510) at /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3993
#11 0x000055555569f8a7 in testing::TestInfo::Run (this=0x55555579aa80) at /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:4169
#12 0x00005555556a0058 in testing::TestCase::Run (this=0x55555579ac20) at /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:4287
#13 0x00005555556acae1 in testing::internal::UnitTestImpl::RunAllTests (this=0x5555557a4f30) at /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:6662
#14 0x00005555556c247d in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>
    (object=0x5555557a4f30, method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x5555556ac818 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x5555556f1c10 "auxiliary test code (environments or event listeners)")
    at /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3919
#15 0x00005555556bbeef in testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>
    (object=0x5555557a4f30, method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x5555556ac818 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x5555556f1c10 "auxiliary test code (environments or event listeners)")
    at /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3955
#16 0x00005555556ab068 in testing::UnitTest::Run (this=0x555555760320 <testing::UnitTest::GetInstance()::instance>) at /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:6271
#17 0x00005555556422c9 in RUN_ALL_TESTS () at /mnt/Projects/Projects/opencv/modules/ts/include/opencv2/ts/ts_gtest.h:22240
#18 0x00005555556425a8 in main (argc=1, argv=0x7fffffffd748) at /mnt/Projects/Projects/opencv/modules/objdetect/test/test_main.cpp:18

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Liiizhen Could you take a look on it?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will check it out.

@asmorkalov asmorkalov added the GSoC label Nov 5, 2025
@Liiizhen
Copy link

Liiizhen commented Nov 5, 2025

Why the test shows that these three images can't be found?

[ RUN ] CV_FractalAruco.can_detect/0, where GetParam() = "hand.jpg"
unknown file: Failure
C++ exception with description "OpenCV(4.13.0-dev) /home/ci/opencv/modules/core/include/opencv2/core/mat.inl.hpp:912: error: (-215:Assertion failed) (unsigned)i0 < (unsigned)size.p[0] in function 'at'
" thrown in the test body.
[ FAILED ] CV_FractalAruco.can_detect/0, where GetParam() = "hand.jpg" (457 ms)
[ RUN ] CV_FractalAruco.can_detect/1, where GetParam() = "close.jpg"
unknown file: Failure
C++ exception with description "OpenCV(4.13.0-dev) /home/ci/opencv/modules/core/include/opencv2/core/mat.inl.hpp:912: error: (-215:Assertion failed) (unsigned)i0 < (unsigned)size.p[0] in function 'at'
" thrown in the test body.
[ FAILED ] CV_FractalAruco.can_detect/1, where GetParam() = "close.jpg" (447 ms)
[ RUN ] CV_FractalAruco.can_detect/2, where GetParam() = "confusion.jpg"
unknown file: Failure
C++ exception with description "OpenCV(4.13.0-dev) /home/ci/opencv/modules/core/include/opencv2/core/mat.inl.hpp:912: error: (-215:Assertion failed) (unsigned)i0 < (unsigned)size.p[0] in function 'at'
" thrown in the test body.
[ FAILED ] CV_FractalAruco.can_detect/2, where GetParam() = "confusion.jpg" (530 ms)

@asmorkalov
Copy link
Contributor Author

You need to pull branch with the same name from my fork of opencv_extra. The tests pass now in debug mode on my pc:

Note: Google Test filter = CV_FractalAruco.can_detect*
[==========] Running 5 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 5 tests from CV_FractalAruco
[ RUN      ] CV_FractalAruco.can_detect/0, where GetParam() = "hand.jpg"
[       OK ] CV_FractalAruco.can_detect/0 (235 ms)
[ RUN      ] CV_FractalAruco.can_detect/1, where GetParam() = "close.jpg"
[       OK ] CV_FractalAruco.can_detect/1 (227 ms)
[ RUN      ] CV_FractalAruco.can_detect/2, where GetParam() = "confusion.jpg"
[       OK ] CV_FractalAruco.can_detect/2 (399 ms)
[ RUN      ] CV_FractalAruco.can_detect/3, where GetParam() = "distortion.jpg"
[       OK ] CV_FractalAruco.can_detect/3 (190 ms)
[ RUN      ] CV_FractalAruco.can_detect/4, where GetParam() = "far.jpg"
[       OK ] CV_FractalAruco.can_detect/4 (205 ms)
[----------] 5 tests from CV_FractalAruco (1256 ms total)

[----------] Global test environment tear-down
[==========] 5 tests from 1 test case ran. (1256 ms total)
[  PASSED  ] 5 tests.

@Liiizhen
Copy link

Liiizhen commented Nov 6, 2025

How to fix this:

Run cd /home/ci/opencv_extra
File size: 10779743 bytes = 10527 KiB = 10 MiB
Patch size default limit exceeded: 1024 KiB
Error: Process completed with exit code 1.

@asmorkalov
Copy link
Contributor Author

Let's handle it later. We need to stabilize API and overall behaviour.

@asmorkalov
Copy link
Contributor Author

@Liiizhen Next steps here:

  • Rename FractalMarkerSet into FractalMarkerDictionary and make it public class like it's done for classic Arucos.
  • Extract predefined marker factory as getPredefinedFractalArucoDictionary like it's done in classic Arucos. Reformat pre-defined dictionaries to some documented format, but not just bytes array.
  • Add read/write methods to get the dictionary configuration outsize.
  • Put fractal Aruco dictionary to detector constructor like classic Arucos.

@Liiizhen
Copy link

@asmorkalov Roger that. I will do these by this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants