
如图所示,上面的部分为视野里有捕捉对象返回的数据,下面的部分为视野里没有捕捉对象返回的数据
如何设置才能使没有捕捉对象也能返回一个值(比如说返回0)
请提供你的代码。请注意不要贴代码图片
# Single Color RGB565 Blob Tracking Example
#
# This example shows off single color RGB565 tracking using the OpenMV Cam.
import sensor, image, time, math, lcd
from pyb import UART
# Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
# The below thresholds track in general red/green/blue things. You may wish to tune them...
thresholds = (0, 100, -128, -7, -9, 127), # generic_red_thresholds
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA) # 320*240
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must be turned off for color tracking
sensor.set_auto_whitebal(False) # must be turned off for color tracking
clock = time.clock()
lcd.init()
uart = UART(3, 9600, timeout_char=1000) # i使用给定波特率初始化
uart.init(9600, bits=8, parity=None, stop=0, timeout_char=1000) # 使用给定参数初始化
# Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are
# returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the
# camera resolution. "merge=True" merges all overlapping blobs in the image.
while(True):
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs([thresholds[0]], pixels_threshold=3000, area_threshold=3000, merge=True):
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())
a = 76800
b = blob.pixels()
c = b/a
d = int(255-255*c)
img.draw_string(100,150,'b='+str(b),color=(0,0,0))
img.draw_string(100,170,'c='+str(c),color=(0,0,0))
lcd.display(img)
uart.writechar(d) # write 1 character 写入一个字符
#time.sleep(500)
print(a, b, c, d)
print(clock.fps())
数据=0
色块们 = img.find_blobs()
for 色块 in 色块们:
数据=blob.pixels()
print(数据)@kidswong999 不好意思 再请问一下 这个“色块”用什么代码指代呢?直接就是image.blob?

调试过程中出现了该问题 请问是调用有问题吗? 该如何解决呢?
问题:find_blobs里面没有阈值参数。
解决办法:填入阈值参数
@kidswong999
已解决 十分感谢:folded_hands: :folded_hands_light_skin_tone: :folded_hands_medium-light_skin_tone: