# Single Color Grayscale Blob Tracking Example
#
# This example shows off single color grayscale tracking using the OpenMV Cam.
import sensor, image, time, math
# Color Tracking Thresholds (Grayscale Min, Grayscale Max)
# The below grayscale threshold is set to only find extremely bright white areas.
thresholds = (0, 104)#(0, 38, 10, 70, -111, 127)
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.XGA)
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()
import time
from pyb import UART
from modbus import ModbusRTU
uart = UART(3,9600, parity=None, stop=2, timeout=2, timeout_char=4)
modbus = ModbusRTU(uart,2, register_num=9999)
# 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):
if modbus.any():
modbus.handle(debug=True)
else:
time.sleep_ms(100)
modbus.REGISTER[0] = 1000
modbus.REGISTER[1] += 1
modbus.REGISTER[3] += 3
#print(modbus.REGISTER[10:15])
# image processing in there
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs([thresholds], pixels_threshold=100, area_threshold=5000, merge=True):
# These values depend on the blob not being circular - otherwise they will be shaky.
if blob.elongation() > 0.5:
img.draw_edges(blob.min_corners(), color=0)
img.draw_line(blob.major_axis_line(), color=0)
img.draw_line(blob.minor_axis_line(), color=0)
# These values are stable all the time.
img.draw_rectangle(blob.rect(), color=127)
img.draw_cross(blob.cx(), blob.cy(), color=127)
# Note - the blob rotation is unique to 0-180 only.
img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=40, color=127)
print(clock.fps())
win7+ide3.0.3+openmv4 h7 plus.
how to fix that ?