You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "PycharmProjects/OpenCV/retangulo_moving.py", line 27, in
frame = cv2.rectangle(frame, (x1, y1), (x1+bw, y1+bh), (0,0,0), -1)
TypeError: function takes exactly 4 arguments (2 given)
[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (436) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
Steps to reproduce
The error is in the rectangle function. I'm trying to display a moving rectangle in a live video from the WebCam.
When using opencv version 4.0.1 I got the error "an integer is required (got type tuple)". After the update too the 4.3.0 version this new error showed up.
import numpy as np
print(cv2.__version__)
dispW=640
dispH=480
cam=cv2.VideoCapture(0)
cam.set(cv2.CAP_PROP_FPS, 21)
cam.set(cv2.CAP_PROP_FRAME_WIDTH, dispW)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, dispH)
bw=(.15*dispW)
bh=(.15*dispH)
dx=2
dy=2
x1=10
y1=270
while True:
ret, frame=cam.read()
frame = cv2.rectangle(frame, (x1, y1), (x1+bw, y1+bh), (0,0,0), -1)
cv2.moveWindow('WebCam', 0, 0)
cv2.imshow('WebCam', frame2)
x1+=dx
y1+=dy
if x1<=0 or x1+bw>=dispW:
dx=dx*(-1)
if y1<=0 or y1+bh>=dispH:
dy=dy*(-1)
if cv2.waitKey(1)==ord('q'):
break
cam.release()
cv2.destroyAllWindows()
Issue submission checklist
I checked the problem with documentation, FAQ, open issues,
answers.opencv.org, Stack Overflow, etc and have not found solution
I updated to latest OpenCV version and the issue is still there
The text was updated successfully, but these errors were encountered:
augustopozzebon
changed the title
cv2.rectangle TypeError: an integer is required (got type tuple).
cv2.rectangle TypeError: function takes exactly 4 arguments (2 given)
Jul 24, 2020
Detailed description
Traceback (most recent call last):
File "PycharmProjects/OpenCV/retangulo_moving.py", line 27, in
frame = cv2.rectangle(frame, (x1, y1), (x1+bw, y1+bh), (0,0,0), -1)
TypeError: function takes exactly 4 arguments (2 given)
[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (436) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
Steps to reproduce
The error is in the rectangle function. I'm trying to display a moving rectangle in a live video from the WebCam.
When using opencv version 4.0.1 I got the error "an integer is required (got type tuple)". After the update too the 4.3.0 version this new error showed up.
Issue submission checklist
answers.opencv.org, Stack Overflow, etc and have not found solution
The text was updated successfully, but these errors were encountered: