简体   繁体   English

AttributeError:模块'cv2.cv2'没有属性'rectange'

[英]AttributeError: module 'cv2.cv2' has no attribute 'rectange'

I am using the following code on python 3.7 我在python 3.7上使用以下代码

import cv2
import numpy as np

face_cascade = cv2.CascadeClassifier('D:\\ET\\haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('D:\\ET\\haarcascade_eye.xml')

cap = cv2.VideoCapture(0)

while True:
    ret, img = cap.read()
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    faces = face_cascade.detectMultiScale(gray, 1.3, 5)

    for (x,y,w,h) in faces:
        cv2.rectange(img,(x,y),(x+w,y+h),(255,0,0),2)
        roi_gray = gray[y:y+h, x:x+w]
        roi_color = img[y:y+h, x:x+w]
        eyes = eye_cascade.detectMultiScale(roi_gray)
        for (ex,ey,ew,eh) in eyes:
            cv2.rectangle(roi_color,(ex,ey), (ex+ew,ey+eh),(0,255,0),2)

    cv2.imshow('img',img)
    k = cv2.waitKey(30) & 0xFF
    if k == 27:
        break

cap.release()
cv2.destroyAllWindows()

the following is installed: 安装了以下内容:

opencv-contrib-python-3.4.4.19

The error is telling you that cv2 doesn't have anything called rectange , but it does have something called rectangle . 该错误是告诉你,CV2没有什么所谓的rectange ,但它确实有一些所谓rectangle You misspelled it: 您拼写错误:

cv2.rectange(img,(x,y),(x+w,y+h),(255,0,0),2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError: 模块 'cv2.cv2' 没有属性 'release' - AttributeError: module 'cv2.cv2' has no attribute 'release' 模块 'cv2.cv2' 没有属性 'sift' - module 'cv2.cv2' has no attribute 'sift' 模块“cv2.cv2”没有属性“PutText” - module 'cv2.cv2' has no attribute 'PutText' 模块“cv2.cv2”没有属性“xfeatures2d”,模块“cv2.cv2”没有属性“SIFT” - module 'cv2.cv2' has no attribute 'xfeatures2d' and module 'cv2.cv2' has no attribute 'SIFT' 接收错误:AttributeError:尝试调用openCV方法时,模块'cv2.cv2'没有属性'CompareHist' - Receiving error: AttributeError: module 'cv2.cv2' has no attribute 'CompareHist' when trying to call a openCV method AttributeError: 模块 'cv2.cv2' 没有属性 'CAP_PROP_ORIENTATION_META' - AttributeError: module 'cv2.cv2' has no attribute 'CAP_PROP_ORIENTATION_META' OpenCV AttributeError 模块“cv2.cv2”没有属性“TrackerBoosting_create” - OpenCV AttributeError module 'cv2.cv2' has no attribute 'TrackerBoosting_create' 如何修复错误“模块'cv2.cv2'没有属性setMouseCallBack?” - How to fix the error "module 'cv2.cv2' has no attribute setMouseCallBack?" 模块“cv2.cv2”没有属性“dnn_superres” - module 'cv2.cv2' has no attribute 'dnn_superres' 模块“cv2.cv2”没有属性“xfeatures2d”(Opencv 3.4.2.17) - module 'cv2.cv2' has no attribute 'xfeatures2d'(Opencv 3.4.2.17)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM