Update Test.py
This commit is contained in:
27
Test.py
27
Test.py
@@ -102,19 +102,20 @@ for frame in camera.capture_continuous(raw_capture, format="bgr", use_video_port
|
||||
|
||||
# Draw the bounding box
|
||||
cnt = contours[max_index]
|
||||
x,y,w,h = cv2.boundingRect(cnt)
|
||||
cv2.rectangle(image,(x,y),(x+w,y+h),(0,255,0),3)
|
||||
|
||||
# Draw circle in the center of the bounding box
|
||||
x2 = x + int(w/2)
|
||||
y2 = y + int(h/2)
|
||||
cv2.circle(image,(x2,y2),4,(0,255,0),-1)
|
||||
|
||||
# Print the centroid coordinates (we'll use the center of the
|
||||
# bounding box) on the image
|
||||
text = "x: " + str(x2) + ", y: " + str(y2)
|
||||
cv2.putText(image, text, (x2 - 10, y2 - 10),
|
||||
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
|
||||
print(cnt)
|
||||
# x,y,w,h = cv2.boundingRect(cnt)
|
||||
# cv2.rectangle(image,(x,y),(x+w,y+h),(0,255,0),3)
|
||||
#
|
||||
# # Draw circle in the center of the bounding box
|
||||
# x2 = x + int(w/2)
|
||||
# y2 = y + int(h/2)
|
||||
# cv2.circle(image,(x2,y2),4,(0,255,0),-1)
|
||||
#
|
||||
# # Print the centroid coordinates (we'll use the center of the
|
||||
# # bounding box) on the image
|
||||
# text = "x: " + str(x2) + ", y: " + str(y2)
|
||||
# cv2.putText(image, text, (x2 - 10, y2 - 10),
|
||||
# cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
|
||||
|
||||
# Display the resulting frame
|
||||
cv2.imshow("Frame",image)
|
||||
|
||||
Reference in New Issue
Block a user