本文整理汇总了Python中Filter.Filter.work方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.work方法的具体用法?Python Filter.work怎么用?Python Filter.work使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter.Filter
的用法示例。
在下文中一共展示了Filter.work方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Filter
# 需要导入模块: from Filter import Filter [as 别名]
# 或者: from Filter.Filter import work [as 别名]
# allocate variables
_, img = cam.read()
frame = cv2.cv.CreateImage(img.shape[:2], 16, 3)
frameHSV = np.zeros(img.shape, np.uint16)
blue_filt = Filter(img, "alg", "filt", conf_file="blue ball.conf", config_enable=False, filter_type=1)
green_filt = Filter(img, "green_alg", "green_filt", conf_file="green room.conf", config_enable=False, filter_type=1)
red_filt = Filter(img, "red alg", "red filt", conf_file="red glass.conf", config_enable=False, filter_type=1)
prev_sig = 0
while True:
_, frame = cam.read()
frame = cv2.medianBlur(frame, 5)
frameHSV = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
blue_area = blue_filt.work(frameHSV)
green_area = green_filt.work(frameHSV)
red_area = red_filt.work(frameHSV)
detection_signal = 0
if blue_area > 30000:
detection_signal += 1
if green_area > 25000:
detection_signal += 2
if red_area > 5000:
detection_signal += 4
if prev_sig != detection_signal:
print("r : {} g : {} b : {} sig : {}".format(red_area, green_area, blue_area, detection_signal))
ser.write(chr(detection_signal))
prev_sig = detection_signal