logo

颜色过去以后会出现好几遍这个颜色,能不能只出现一次

2019-02-22 19:04
0
Super灬螃蟹

颜色过去以后会出现好几遍这个颜色,能不能只出现一次

import sensor, image,time,pyb,utime
import sensor, image, time,utime
from pyb import UART
uart = UART(3, 57600)
output_str=0
yanse=0
flag=1
while 1:
  if uart.any():
	 flag=uart.readline().decode()
	 flag=int(flag)
	 print(flag)
  if flag==1:
		 thresholds = [(60, 18, 37, 75, -35, 76),(58, 24, -11, 17, -61, -16),(60, 30, -17, -58, -43, 31)]
		 sensor.reset()
		 sensor.set_pixformat(sensor.RGB565)
		 sensor.set_framesize(sensor.QVGA)
		 sensor.skip_frames(time = 2000)
		 sensor.set_auto_gain(False)
		 sensor.set_auto_whitebal(False)
		 while flag :
			img = sensor.snapshot()
			blobs=img.find_blobs(thresholds, pixels_threshold=5000, area_threshold=400)
			for blob in blobs:
			  img.draw_rectangle(blob.rect())
			  img.draw_cross(blob.cx(), blob.cy())
			  yanse="%s" % (blob.code())
			  print( yanse)
			  if  yanse:
				 uart.write(yanse)
				 yanse=0
0
Super灬螃蟹

现在是会出现好几个1好几个2好几个4但是我只想要一个124,就是这个红色会识别很多次绿色会识别很多次,蓝色会识别很多次

2019-02-22 19:12
I
网红小智智 星瞳科技

https://forum.singtown.com/topic/1735/%E5%A6%82%E4%BD%95%E8%AF%86%E5%88%AB%E4%B8%89%E7%A7%8D%E9%A2%9C%E8%89%B2-%E8%80%8C%E4%B8%94%E8%83%BD%E5%A4%9F%E5%88%86%E5%88%AB%E8%AE%B0%E4%B8%8B%E5%9D%90%E6%A0%87

你应该分别调用find_blobs