本文整理匯總了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