简体   繁体   中英

Module 'cv2.cv2' has no attribute 'COLOR'

Installed all needed packages but doesn't seem to work.

Traceback (most recent call last):
  File "convert.py", line 5, in <module>
    gray = cv2.cvtColor(slika, cv2.COLOR.BGR2GRAY)
AttributeError: module 'cv2.cv2' has no attribute 'COLOR'
gray = cv2.cvtColor(slika, cv2.COLOR.BGR2GRAY)

This is invalid, it should be COLOR_BGR2GRAY instead, like this:

gray = cv2.cvtColor(slika, cv2.COLOR_BGR2GRAY)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM