我是新来的opencv。我看过很多关于颜色检测的教程。我的相机在旋转,我希望它在检测到蓝色时停止旋转。如何检查是否有蓝色物体进入我的镜框?我希望它在框架的中心。基本上我想要一个反馈,也许是一个标志位,当检测到蓝色时。我正在使用opencv2和python。请帮忙import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while(1):
# Take each frame
_, frame = cap.read()
# Convert BGR to HSV
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
# define range of blue color in HSV
lower_blue = np.array([110,50,50])
upper_blue = np.array([130,255,255])
# Threshold the HSV image to get only blue colors
mask = cv2.inRange(hsv, lower_green, upper_green)
# Bitwise-AND mask and original image
res = cv2.bitwise_and(frame,frame, mask= mask)
我做了这么多。现在我该检查什么??如果res是零矩阵??即,如果检测到蓝色对象,则获取确认。