|
楼主 |
发表于 2021-11-9 09:28:46
|
显示全部楼层
谢谢解答 我这样去判断行吗
- mask=cv2.inRange(hsv_dilate,(lowerbH,lowerbS,lowerbV),(upperbH,upperbS,upperbV))
- masked = cv2.bitwise_and(image, image, mask=mask)
- redMask=cv2.inRange(hsv_dilate,(col_red[0],col_red[1],col_red[2]),(col_red[3],col_red[4],col_red[5]))
- redMasked = cv2.bitwise_and(image, image, mask=redMask)
- # 在图像某处绘制一个指示,因为只考虑20行宽的图像,所以使用numpy切片将以外的空间区域清空
- h, w, d = image.shape
- search_top = h-20
- search_bot = h
- mask[0:search_top, 0:w] = 0
- mask[search_bot:h, 0:w] = 0
- redMask[0:search_top, 0:w] = 0
- redMask[search_bot:h, 0:w] = 0
- # 计算mask图像的重心,即几何中心
- M = cv2.moments(mask)
- redM=cv2.moments(mask)
- if redM['m00'] > 0:
- #执行暂停
复制代码 |
|