比如百度搜索北京时间,用摄像头对着时间。时间是在不停的变化,能打印出变化的位置坐标。
bmhg
@bmhg
bmhg 发布的帖子
-
之前串口没有问题,今天串口上传数据乱码。会不会是硬件问题
Single Color RGB565 Blob Tracking Example
This example shows off single color RGB565 tracking using the OpenMV Cam.
import sensor, image, time, math
from pyb import UART
threshold_index = 0 # 0 for red, 1 for green, 2 for blue QVGA320
thresholds = [(100, 100, 0, 3, 3, 0), # generic_red_thresholds
(255,255), # generic_green_thresholds 30,255
(0, 30, 0, 64, -128, 0)] # generic_blue_thresholds RGB565 GRAYSCALEsensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE) #sensor.GRAYSCALE
sensor.set_framesize(sensor.VGA) #sensor.VGA
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()
uart = UART(3,57600)
mx=0
my=0
while(True):
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs([thresholds[1]], pixels_threshold=10, area_threshold=10, merge=True):if blob.cx() > 100 : img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) #str(blob.cx())+','+str(blob.cy()) uart.write('{'+str(blob.cx())+','+str(blob.cy())+'}') print('{'+str(blob.cx())+','+str(blob.cy())+'}') #uart.write(str(blob.cx())+','+str(blob.cy())+';')