我运行opencv 3.2.0,ubuntu 14.04和最新的opencv_contrib。
我跑检查: https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/textdetection.py
但它显示错误:
$ python textdetection.py scenetext_word01.jpg
textdetection.py
A demo script of the Extremal Region Filter algorithm described in:
Neumann L., Matas J.: Real-Time Scene Text Localization and Recognition, CVPR 2012
Extracting Class Specific Extremal Regions from 9 channels ...
(...) this may take a while (...)
OpenCV Error: Bad argument (Default classifier file not found!) in ERClassifierNM1, file /home/vietnam/opencv_and_contri/opencv_contrib/modules/text/src/erfilter.cpp, line 1022
Traceback (most recent call last):
File "textdetection.py", line 38, in <module>
erc1 = cv2.text.loadClassifierNM1(pathname+'/trained_classifierNM1.xml')
cv2.error: /home/vietnam/opencv_and_contri/opencv_contrib/modules/text/src/erfilter.cpp:1022: error: (-5) Default classifier file not found! in function ERClassifierNM1
如何解决这个问题?
答案 0 :(得分:1)
尝试在cv2.text.loadClassifierNM1()和cv2.text.loadClassifierNM2()的参数中使用相对路径 所以现在代码的一部分看起来像这样:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
Also
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
我不确定为什么会这样(它确实适用于我),但是在看了VS2015中针对类似问题发布的解决方案之后我尝试了这个:https://github.com/cesardelgadof/OpenCVBinaries/issues/1
希望这有帮助。
答案 1 :(得分:0)
尝试使用绝对路径,例如&#34; /usr/lib/opencv-3.2.0/opencv_contrib-3.2.0/modules/text/samples/trained_classifierNM1.xml" 在我的案例中适用于Ubuntu 16.04,C ++ < / p>