【问题标题】:How to resolve the Python error "Required argument 'x' not found"如何解决 Python 错误“未找到必需的参数‘x’”
【发布时间】:2018-03-01 13:09:01
【问题描述】:

我是初学者,在使用 Python OpenCV 时遇到错误。

我的代码:

import cv2
import numpy as np
front_cascade = cv2.CascadeClassifier('../haarcascade_frontalface_default.xml')

img = cv2.imread('mimika-1024x572.jpg')


faces = front_cascade.detectMultiScale(
    scaleFactor=1.1,
    minNeighbors=5,
    minsize=(30,30)
)
#for (x, y, w, h) in faces:
#    cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 155), 3)

print (faces)

cv2.imshow('frame', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

还有错误:

Traceback (most recent call last):
  File "C:/cv/test2.py", line 12, in <module>
    minsize=(30,30)
TypeError: Required argument 'image' (pos 1) not found

我该如何解决这个错误?

【问题讨论】:

  • 你认为这个错误意味着什么?
  • 在此处发帖时请不要使用 txtspk。你不需要“请帮助我”恳求,但要不惜一切代价尽量避免“plz”。完整的单词输入起来并不麻烦。

标签: python opencv


【解决方案1】:

detectMultiScale 需要图像作为第一个参数,但您忘记传递它。

试试:

faces = front_cascade.detectMultiScale(
    img,  # don't forget this!
    scaleFactor=1.1,
    minNeighbors=5,
    minsize=(30,30)
)

【讨论】:

    猜你喜欢
    • 2020-04-24
    • 1970-01-01
    • 2015-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-27
    • 1970-01-01
    相关资源
    最近更新 更多