opencv_contrib: cv2.error: OpenCV(4.1.1) /io/opencv_contrib/modules/text/src/text_detectorCNN.cpp:38: error: (-2:Unspecified error)

System information (version)
  • OpenCV => 4.1.1
  • Operating System / Platform => Ubuntu 18.04 amd64
  • Compiler => g++ 7.4.0
Detailed description

I get an assertion in textDetectorCNN using both C++ and Python. The error is the same (please note all I’ve done is copy-paste example code):

Traceback (most recent call last):
  File "extractor.py", line 11, in <module>
    rects, probs = det.detect(image)
cv2.error: OpenCV(4.1.1) /io/opencv_contrib/modules/text/src/text_detectorCNN.cpp:38: error: (-2:Unspecified error) in function 'void cv::text::TextDetectorCNNImpl::getOutputs(const float*, int, int, std::vector<cv::Rect_<int> >&, std::vector<float>&, cv::Size)'
>  (expected: 'x_min < x_max'), where
>     'x_min' is 0
> must be less than
>     'x_max' is 0

And in C++:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.1.1) opencv_4.1.1/opencv_contrib-4.1.1/modules/text/src/text_detectorCNN.cpp:38: error: (-2:Unspecified error) in function 'void cv::text::TextDetectorCNNImpl::getOutputs(const float*, int, int, std::vector<cv::Rect_<int> >&, std::vector<float>&, cv::Size)'
>  (expected: 'x_min < x_max'), where
>     'x_min' is 0
> must be less than
>     'x_max' is 0

Aborted (core dumped)
Steps to reproduce

in C++ I just tried the example found in text_demo.cpp and with python I tried the following:

import argparse
import cv2

ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required = True, help = "Path to the image")
args = vars(ap.parse_args())

image = cv2.imread(args["image"])
det = cv2.text.TextDetectorCNN_create("../config/textbox.prototxt",
                                      "../config/TextBoxes_icdar13.caffemodel")
rects, probs = det.detect(image)
print(rects, probs)
cv2.imshow("image", image)
cv2.waitKey(0)

Stepping through the debugger is very clear:

Thread 1 "evidence_verifi" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff4057e97 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff4059801 in __GI_abort () at abort.c:79
#2  0x00007ffff46ae957 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff46b4ab6 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff46b4af1 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff46b4d24 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff4d1da86 in cv::error(cv::Exception const&) () at /usr/local/lib/libopencv_core.so.4.1
#7  0x00007ffff4d233d2 in cv::error(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, char const*, int) () at /usr/local/lib/libopencv_core.so.4.1
#8  0x00007ffff4b02bb2 in void cv::detail::check_failed_auto_<float>(float const&, float const&, cv::detail::CheckContext const&) () at /usr/local/lib/libopencv_core.so.4.1
#9  0x00007ffff4b03a22 in  () at /usr/local/lib/libopencv_core.so.4.1
#10 0x00007ffff745a677 in cv::text::TextDetectorCNNImpl::detect(cv::_InputArray const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, std::vector<float, std::allocator<float> >&) () at /usr/local/lib/libopencv_text.so.4.1
#11 0x00005555555572d6 in main ()
(gdb) 

I took a look in the source code and can find the trigger of the assertion. Has anyone run into this before? I’ve even tried with different sizes to see if that would affect it, but to no avail. I’m re-building OpenCV with debug symbols to see if I can step into it.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

Bug fixes are pushed onto lowest applicable maintenable version first. After that bug fixes are merged into latest versions (#2315 is targeted onto 3.4 branch, #2317 is merging onto master/4.x). Current policy: https://github.com/opencv/opencv/wiki/Branches

modules/features2d/include/opencv2/features2d.hpp:499:17: note: initializing argument 5 of ‘void cv::FAST(cv::InputArray, std::vectorcv::KeyPoint&, int, bool, cv::FastFeatureDetector::DetectorType)

There is no line with such content in OpenCV 3.4. Your line is from “master” branch.

git checkout 3.4 or git checkout upstream/3.4 in opencv-3.4 dir may help.

Mentioned patch is built on top of “3.4” branch. So you need OpenCV 3.4 or rebased patch onto master.

In my case it is a PNG form attached below.

1CDFC_XPR16150-0_otsu

Sorry for the confusion - here’s the saved frame

frame