AttributeError: module 'cv2.cv2' has no attribute 'ximgproc'(问题已解决,亲测有效!)

AttributeError: module ‘cv2.cv2’ has no attribute ‘ximgproc’(问题已解决,亲测有效!)

遇到该问题时,网友多是建议补个包,即
pip3 install opencv-contrib-python
我在补完之后又出现下面这样的错误:
OpenCV(3.4.3) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\sift.cpp:1207: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function ‘cv::xfeatures2d::SIFT::create’
貌似是该算法被申请了专利还是咋的,将opencv版本退到3.4.2即可解决,卸载之前的包,然后
pip3 install opencv-python == 3.4.2.16
pip3 install opencv-contrib-python == 3.4.2.16

AttributeError: module ‘cv2.cv2’ has no attribute ‘estimateRigidTransform’

The code below is a Python tutorial for Selective Search using OpenCV 3.3. Note the bug alert for OpenCV 3.2 mentioned after the code block. Please read through the comments to understand the code.
卸载opencv重新装3.3或者3.4

NameError:name ‘xrange’ is not defined

原因是我的python版本为python 3.4,而xrange( )函数时在python 2.x中的一个函数,在Python 3中,range()的实现方式与xrange()函数相同,所以就不存在专用的xrange( ),因此,当遇到这种问题时,有两种方法可以解决这个问题。

  1. 第一种:若你想在python 3中运行程序,将xrange( )函数全部换为range( )即可
  2. 第二种:将出现此问题的程序放在python 2.x版本的环境中运行即可

你可能感兴趣的:(opencv环境)