1
Hello, I am studying opencv to use in a drone and while I was implementing a code of a tutorial that detected objects and drew a circle in the center of it, and for that you should take half the dimensions x+w
and y+h
only that the problem is that when I go to do x+w/2
and y+h/2
appears the following error: integer argument expected, got float
. HELP ME!!
Code:
import cv2
import numpy as np
cap = cv2.cv2.VideoCapture(0)
kernel = np.ones((5,5), np.uint8)
while True:
ret, frame = cap.read()
rangomax = np.array([50,255,50])
rangomin = np.array([0, 51, 0])
mascara = cv2.cv2.inRange(frame, rangomin, rangomax)
opening = cv2.cv2.morphologyEx(mascara, cv2.cv2.MORPH_OPEN, kernel)
x,y,w,h = cv2.cv2.boundingRect(opening)
cv2.cv2.rectangle(frame, (x,y), (x+w, y+h), (0,255,0), 3)
cv2.cv2.circle(frame,(x+w/2, y+h/2), 5,(0,0,255), -1)
cv2.cv2.imshow('video', frame)
k = cv2.cv2.waitKey(1) & 0xFF
if k == 27:
break
cap.release()
Thank you very much :)
– Marcos Paulo S. Rezende