我想在python& OpenCv上检测我的耳朵,但它发生了这个错误:
Traceback (most recent call last):
File "C:/Users/asus/PycharmProjects/ImageProcessing/app.py", line 17, in <module>
cv2.rectangle(frame, obj, (15 ,15 ), (0, 0, 255),-5)
TypeError: function takes exactly 2 arguments (1 given)
代码在这里:
import numpy as np
import cv2
camera = cv2.VideoCapture(0)
ear = cv2.imread("ear.png", 0)
w, h = ear.shape[::-1]
while (True):
_, frame = camera.read(0)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
match = cv2.matchTemplate(frame, ear, cv2.TM_CCORR_NORMED)
match = np.where(match >= 0.8)
for obj in zip(match[::-1]):
print(obj)
cv2.rectangle(frame, obj, (15,15), (0, 0, 255),-5)
cv2.imshow("FindMyEars", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
camera.release()
cv2.destroyAllWindows()
我应该更正代码?
答案 0 :(得分:0)
我解决了这个问题
错误:
for obj in zip(match[::-1]):
右:
for obj in zip(match[*::-1]):