Sometimes it runs to up to 20 seconds, but it always disconnects on me. If I comment out the save line it runs fine. Code as follows:
# Single Color RGB565 Blob Tracking Example
# This example shows off single color RGB565 tracking using the OpenMV Cam.
import sensor, image, time, os, pyb
from pyb import Pin
pin1 = Pin('P1', Pin.OUT_PP, Pin.PULL_NONE)
threshold_index = 1 # 0 for red, 1 for green, 2 for blue
# 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 = [(30, 100, 15, 127, 15, 127), # generic_red_thresholds
(30, 100, -64, -8, -32, 32), # generic_green_thresholds
(0, 30, 0, 64, -128, 0)] # generic_blue_thresholds
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()
# 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.
img = sensor.snapshot()
blobs = img.find_blobs([thresholds[threshold_index]])
if len(blobs) > 0:
for blob in img.find_blobs([thresholds[threshold_index]], pixels_threshold=100, area_threshold=100, merge=True):
sensor.snapshot().save("test.bmp") # or "example.bmp" (or others)