python - OpenCV 错误 : Bad argument in ERClassifierNM1

标签 python c++ opencv detection

我运行 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

如何解决?

最佳答案

尝试在 cv2.text.loadClassifierNM1() 和 cv2.text.loadClassifierNM2() 的参数中使用相对路径 所以现在这部分代码看起来像这样:

erc1 = cv2.text.loadClassifierNM1('./trained_classifierNM1.xml')
er1 = cv2.text.createERFilterNM1(erc1,16,0.00015,0.13,0.2,True,0.1)

erc2 = cv2.text.loadClassifierNM2('./trained_classifierNM2.xml')
er2 = cv2.text.createERFilterNM2(erc2,0.5) 

我不确定为什么这有效(它对我有用),但我在查看针对 VS2015 中类似问题发布的解决方案后尝试了此方法:https://github.com/cesardelgadof/OpenCVBinaries/issues/1

希望这对您有所帮助。

关于python - OpenCV 错误 : Bad argument in ERClassifierNM1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44641704/

相关文章:

python - 如何获得ipython并行处理的中间结果?

python - Tensorflow 2.0 无法识别张量形状

python通过cgi反向代理生成

c++ - 尝试传递一个 constexpr lambda 并使用它来显式指定返回类型

java - 使用javacv创建图像

Python,根据输入字符串的格式和内容运行函数

c++ - 不明白为什么我会收到异常 : Access violation reading location 0x00000000

c++ - 模板函数采用任何仿函数并返回仿函数返回的类型

image-processing - 有没有人在 OpenCV 中使用 MSER 来检测区域?

python - 如何使用 Python OpenCV 从图像中提取多个对象?