Repository: opencv
Issue: findCirclesGrid( ..., CALIB_CB_ASYMMETRIC_GRID ) asserts
Labels: bug,auto-transferred,priority: normal,category: calib3d,affected: 2.4

Transferred from http://code.opencv.org/issues/2852

```
|| Tonu Samuel on 2013-03-02 07:24
|| Priority: Normal
|| Affected: 2.4.3
|| Category: calibration, 3d
|| Tracker: Bug
|| Difficulty: None
|| PR: 
|| Platform: None / None
```
## findCirclesGrid( ..., CALIB_CB_ASYMMETRIC_GRID ) asserts

```
I am trying to detect asymmetric grid from image. Current code worked well until I tuned
grid size down to 4x3 and and actually show him 4x11 board. I need to wave board few times to make this happen.
All input looks valid, so I believe rest of the code is not important.

<pre>Starting program: xxx -w 4 -h 3 -i camera_data.yml -s 45
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
[New Thread 0x7fffe44f7700 (LWP 2148)]
[New Thread 0x7fffe3cf6700 (LWP 2149)]
OpenCV Error: Assertion failed (h >= 2 && w >= 2) in getCornerSegments, file /tmp/buildd/ros-groovy-opencv2-2.4.3-6quantal-20130125-0325/modules/calib3d/src/circlesgrid.cpp, line 1485
terminate called after throwing an instance of 'cv::Exception'
  what():  /tmp/buildd/ros-groovy-opencv2-2.4.3-6quantal-20130125-0325/modules/calib3d/src/circlesgrid.cpp:1485: error: (-215) h >= 2 && w >= 2 in function getCornerSegments


Program received signal SIGABRT, Aborted.
0x00007ffff61aa425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff61aa425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff61adb8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff67a9e2d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff67a7f26 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff67a7f53 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff67a817e in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff780e141 in cv::error(cv::Exception const&) () from /opt/ros/groovy/lib/libopencv_core.so.2.4
#7  0x00007ffff7ba5916 in CirclesGridFinder::getCornerSegments(std::vector<std::vector<unsigned long, std::allocator<unsigned long> >, std::allocator<std::vector<unsigned long, std::allocator<unsigned long> > > > const&, std::vector<std::vector<CirclesGridFinder::Segment, std::allocator<CirclesGridFinder::Segment> >, std::allocator<std::vector<CirclesGridFinder::Segment, std::allocator<CirclesGridFinder::Segment> > > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&) const () from /opt/ros/groovy/lib/libopencv_calib3d.so.2.4
#8  0x00007ffff7ba5dcd in CirclesGridFinder::getFirstCorner(std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&) const () from /opt/ros/groovy/lib/libopencv_calib3d.so.2.4
#9  0x00007ffff7ba616e in CirclesGridFinder::getAsymmetricHoles(std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >&) const () from /opt/ros/groovy/lib/libopencv_calib3d.so.2.4
#10 0x00007ffff7bc42d8 in cv::findCirclesGrid(cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, int, cv::Ptr<cv::FeatureDetector> const&) ()
   from /opt/ros/groovy/lib/libopencv_calib3d.so.2.4
#11 0x0000000000407fba in main (argc=9, argv=0x7fffffffdc98) at xxx.cpp:176
(gdb) up
#1  0x00007ffff61adb8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) 
#2  0x00007ffff67a9e2d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) 
#3  0x00007ffff67a7f26 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) 
#4  0x00007ffff67a7f53 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) 
#5  0x00007ffff67a817e in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) 
#6  0x00007ffff780e141 in cv::error(cv::Exception const&) () from /opt/ros/groovy/lib/libopencv_core.so.2.4
(gdb) 
#7  0x00007ffff7ba5916 in CirclesGridFinder::getCornerSegments(std::vector<std::vector<unsigned long, std::allocator<unsigned long> >, std::allocator<std::vector<unsigned long, std::allocator<unsigned long> > > > const&, std::vector<std::vector<CirclesGridFinder::Segment, std::allocator<CirclesGridFinder::Segment> >, std::allocator<std::vector<CirclesGridFinder::Segment, std::allocator<CirclesGridFinder::Segment> > > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&) const () from /opt/ros/groovy/lib/libopencv_calib3d.so.2.4
(gdb) 
#8  0x00007ffff7ba5dcd in CirclesGridFinder::getFirstCorner(std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >&) const () from /opt/ros/groovy/lib/libopencv_calib3d.so.2.4
(gdb) 
#9  0x00007ffff7ba616e in CirclesGridFinder::getAsymmetricHoles(std::vector<cv::Point_<float>, std::allocator<cv::Point_<float> > >&) const () from /opt/ros/groovy/lib/libopencv_calib3d.so.2.4
(gdb) 
#10 0x00007ffff7bc42d8 in cv::findCirclesGrid(cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, int, cv::Ptr<cv::FeatureDetector> const&) ()
   from /opt/ros/groovy/lib/libopencv_calib3d.so.2.4
(gdb) 
#11 0x0000000000407fba in main (argc=9, argv=0x7fffffffdc98) at xxx.cpp:176
176         boardFound = findCirclesGrid( frame, boardSize, foundBoardCorners, CALIB_CB_ASYMMETRIC_GRID );
(gdb) p boardSize
$1 = {width = 4, height = 3}
(gdb) p foundBoardCorners
$2 = {<std::_Vector_base<cv::Point_<float>, std::allocator<cv::Point_<float> > >> = {
    _M_impl = {<std::allocator<cv::Point_<float> >> = {<__gnu_cxx::new_allocator<cv::Point_<float> >> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, 
      _M_end_of_storage = 0x0}}, <No data fields>}
(gdb) p frame
$3 = {flags = 1124024336, dims = 2, rows = 480, cols = 640, 
  data = 0x7fffe2fad020 "O_/O_/[LP]NRXZUWYTYUMZVNOSGMQEKQPLRQCJZIP`RTXRTXHfMGeLNhFMgE[c=emGM]SL\\RDiGChFS[SYaY[`\\Z_[WmPNdGF^WC[TA`WDcZ:iL;jMKdYJcXKa_CYWE^SHaVScYScYB^^B^^6_a5^`L^[M_\\/ac0bd<dU>fWF^VG_W<hM:fKCZOF]RE[YF\\Z\\bQZ`OT^"..., refcount = 0x7fffe308e020, 
  datastart = 0x7fffe2fad020 "O_/O_/[LP]NRXZUWYTYUMZVNOSGMQEKQPLRQCJZIP`RTXRTXHfMGeLNhFMgE[c=emGM]SL\\RDiGChFS[SYaY[`\\Z_[WmPNdGF^WC[TA`WDcZ:iL;jMKdYJcXKa_CYWE^SHaVScYScYB^^B^^6_a5^`L^[M_\\/ac0bd<dU>fWF^VG_W<hM:fKCZOF]RE[YF\\Z\\bQZ`OT^"..., dataend = 0x7fffe308e020 "\002", datalimit = 0x7fffe308e020 "\002", allocator = 0x0, size = {p = 0x7fffffffd5c8}, step = {p = 0x7fffffffd610, buf = {1920, 3}}}
(gdb) 
</pre>
```
## History
##### Andrey Pavlenko on 2013-03-06 09:43

```
-   Start date deleted (2013-03-02)
-   Description changed from I am trying to detect asymmetric grid from
    image. Current code worked well un... to I am trying to detect
    asymmetric grid from image. Current code worked well un... More
```
##### Andrey Pavlenko on 2013-03-06 09:44

```
-   Assignee set to Ilya Lysenkov
```
##### Vadim Pisarevsky on 2013-03-08 20:53

```
-   Target version set to Next Hackathon
```
##### Vadim Pisarevsky on 2013-03-08 20:53

```
-   Category set to calibration, 3d
```