opencv检测是否出现红色小球
import cv2
import numpy as np
cap=cv2.VideoCapture(0)
while True:
ret,frame=cap.read()
frame=cv2.flip(frame,1)
dst = cv2.pyrMeanShiftFiltering(frame, 10, 100)
hsv=cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
lower_hsv=np.array([156,43,46])
upper_hsv=np.array([180,255,255])
img_r=cv2.inRange(hsv,lower_hsv,upper_hsv)
circles = cv2.HoughCircles(img_r, cv2.HOUGH_GRADIENT, 1, 20, param1=50, param2=30, minRadius=10, maxRadius=9000)
if circles is not None:
print("yes")
cv2.imshow("cv", img_r)
c=cv2.waitKey(50)
if c==27:
break
cv2.destroyAllWindows()