gpt4 book ai didi

python-2.7 - 所需参数 'rejectLevels'(pos 2)未找到 OpenCV Raspberry Pi

转载 作者:太空宇宙 更新时间:2023-11-03 21:56:59 25 4
gpt4 key购买 nike

我有一个小脚本,我将图像从树莓派上的 picamera 传递到流到 OpenCV。一旦 OpenCV 有了图像,它应该使用 haar 级联方法寻找人脸。如果我分离出人脸检测,代码将运行良好,读取图像并按预期上传到远程服务器。当我进行人脸检测时,出现以下错误:

标志 = cv2.cv.CV_HAAR_SCALE_IMAGE

TypeError:未找到必需的参数“rejectLevels”(pos 2)

这是代码:

current_time = time.time()
endtime = current_time + 30

stream = io.BytesIO()

CAMERA_WIDTH = 640
CAMERA_HEIGHT = 480

cascPath = sys.argv[1]
faceCascade = cv2.CascadeClassifier(cascPath)

while current_time <= endtime:
timeStamp = time.strftime('%d-%m-%Y-%H-%M-%S', time.localtime(current_time))

with picamera.PiCamera() as cam:
cam.rotation = 270
cam.resolution = (CAMERA_WIDTH, CAMERA_HEIGHT)
cam.capture(stream, format='bmp')

data = np.fromstring(stream.getvalue(), dtype=np.uint8)
img = cv2.imdecode(data, 1)
stream.seek(0)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbours=5,
minSize=(30,30),
flags = cv2.cv.CV_HAAR_SCALE_IMAGE
)

print("Found {0} faces!".format(len(faces)))

我不确定错误到底告诉我什么,一些建议会很好!

最佳答案

您的参数有错别字,请将 minNeighbours 更改为 minNeighbors

关于python-2.7 - 所需参数 'rejectLevels'(pos 2)未找到 OpenCV Raspberry Pi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28820220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com