No module named “cv2.aruco“

Paste the reference link first

1. The difference between opencv-python, opencv-python-headless, opencv-contrib-python, opencv-contrib-python-headless packages

opencv-python

Needless to say, the official standard version

opencv-python-headless

OpenCV-Python-Headless is a headless version for computer vision applications running on servers. Its usage is similar to OpenCV-Python, but no image will be displayed when it is used. This is convenient for applications running on servers without a GUI, as it saves resources. reference link

opencv-contrib-python

OpenCV Contrib is an extension module of OpenCV. It contains many latest algorithms that may not be officially released yet to be further improved. It can be understood as an extension package of OpenCV. Click on the Github page to view it. This is somewhat similar to the various optional installation extension packages in Matlab. At the same time, after OpenCV 3.0, feature algorithms such as SIFT and SURF are also placed in the Contrib library. Therefore, if you want to use the SIFT operator, you must install the Contrib library. The following uses Python to install the OpenCV Contrib library as an example to introduce the installation process. Note that the Contrib version of OpenCV is a superset of ordinary OpenCV, including all the functions of the normal version of OpenCV, which can be understood as "OpenCV PLUS". reference link

Note: If you have installed OpenCV before, please uninstall it first, otherwise it may not be recognized after the Contrib version is installed. Because the recognition is still the previous version. Use the PIP command to uninstall .

pip uninstall opencv-python

opencv-contrib-python-headless

Similar to opencv-python-headless, it is the interface version of opencv-contrib-python

Who are the above four packages suitable for?

Installing OpenCV in python provides four dependent packages, refer to the link

  1. If only the main module is needed pip install opencv-python
  2. If you need a more complete module pip install opencv-contrib-python
  3. If you have less resources and don't need any GUI features pip install opencv-python-headless
  4. If there are few resources, no GUI functions are required, and the contrib module pip install opencv-contrib-python-headless is included.
    Therefore, generally speaking, you will choose to install opencv-contrib-python and do not install opencv-python and opencv-contrib-python at the same time.
    After the problem about the installation package is solved, the new version of the installation package will continuously report the following errors on the original code, and you can modify it according to the new version.

2. Error reporting and resolution

(1)AttributeError: module ‘cv2.aruco’ has no attribute ‘Dictionary_get’

  • cv2.aruco.Dictionary_get()The function loads a cv2.aruco.DICT_nXn_250 dictionary containing 250 tokens, where each token is an n×n-bit binary pattern.
  • In the latest version, the API of this function is changed tocv2.aruco.getPredefinedDictionary

(2)AttributeError: module ‘cv2.aruco’ has no attribute ‘DetectorParameters_create’

cv2.aruco.DetectorParameters_createThe function of this function is 使用默认值初始化检测器参数changed tocv2.aruco.DetectorParameters

(3)AttributeError: module ‘cv2.aruco’ has no attribute ‘drawAxis’

cv2.aruco.drawAxisThis function will add the coordinate axis to the QR code and change it tocv2.drawFrameAxes

The result of the operation is as follows

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-33WCUd18-1677551113762)(en-resource://database/961:0)]

Guess you like

Origin blog.csdn.net/weixin_41837701/article/details/129256430