我想MV确认到黄色就P1有电,绿色就P2有电,红色就P3……。
例程讲解10-Color-Tracking->multi_color_blob_tracking多颜色跟踪
# 多颜色跟踪示例
#
# 这个例子显示了使用OpenMV的多色跟踪。
import sensor, image, time
# 颜色跟踪阈值(L Min, L Max, A Min, A Max, B Min, B Max)
# 下面的阈值跟踪一般红色/绿色的东西。你不妨调整他们...
thresholds = [(30, 100, 15, 127, 15, 127), # generic_red_thresholds
(30, 100, -64, -8, -32, 32), # generic_green_thresholds
(0, 15, 0, 40, -80, -20)] # generic_blue_thresholds
# 不要超过16个颜色阈值
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
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()
# 只有比“pixel_threshold”多的像素和多于“area_threshold”的区域才被
# 下面的“find_blobs”返回。 如果更改相机分辨率,
# 请更改“pixels_threshold”和“area_threshold”。 “merge = True”合并图像中所有重叠的色块。
while(True):
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs(thresholds, pixels_threshold=200, area_threshold=200):
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())
print(clock.fps())
这并不是一个提问,你有什么问题?
我想MV模块检查出有我想要的颜色,模块的P1口有l0信号
<https://forum.singtown.com/topic/191/openmv%E6%80%8E%E4%B9%88%E6%89%8D%E8%83%BD%E8%AE%A9%E4%BB%96%E8%AF%86%E5%88%AB%E5%88%B0%E4%B8%80%E4%B8%AA%E8%89%B2%E5%9D%97%E5%90%8E%E5%BC%95%E8%84%9A%E8%BE%93%E5%87%BA%E4%B8%80%E4%B8%AA%E9%AB%98%E7%94%B5%E5%B9%B3>
可能是这样?
if(blobs):
p1.value(1)
else:
p1.value(0)