可拆卸的摄像头模块系统,允许OpenMV Cam H7 Plus与不同的感光元件模组连接:
OpenMV4 H7 Plus默认配置的OV5640 感光元件处理2592×1944 (5MP)图像。在QVGA (320×240)及以下的分辨率时,大多数简单的算法可以运行(25~50)FPS。#识别区域
roi1 = [(0, 17, 15, 25), # 左 x y w h
(65,17,15,25),# 右
(30,0,20,15),#上
(0,0,80,60)]#停车
f_x=0
f_a=0
if flag==0:
if x<0:
x=-x
f_x=1
if a<0:
a=-a
f_a=1
if flag==1: #十字
x,a,f_x,f_a=(0,0,0,1)
if flag==2: #上左
x,a,f_x,f_a=(0,0,1,0)
if flag==3: #上右
x,a,f_x,f_a=(0,0,1,1)
if flag==4: #stop
x,a,f_x,f_a=(1,1,1,2)
if (line):
rho_err = abs(line.rho())-img.width()/2
if line.theta()>90:
theta_err = line.theta()-180
else:
theta_err = line.theta()
#直角坐标调整
img.draw_line(line.line(), color = 127)
#画出直线
#print(rho_err,line.magnitude(),rho_err)
if line.magnitude()>8:
#if -40
data = ustruct.pack("
THRESHOLD = (18, 61, 14, 89, -2, 63) # Grayscale threshold for dark things...
import sensor, image, time,ustruct
from pyb import UART,LED
#from pid import PID
#rho_pid = PID(p=0.4, i=0)
#theta_pid = PID(p=0.001, i=0)
import pyb
LED(1).on()
LED(2).on()
LED(3).on()
sensor.reset()
#sensor.set_vflip(True)
#sensor.set_hmirror(True)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQQVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000.
#sensor.set_windowing([0,20,80,40])
sensor.skip_frames(time = 2000) # WARNING: If you use QQVGA it may take seconds
clock = time.clock() # to process a frame sometimes.
uart = UART(3,115200) #定义串口3变量
uart.init(115200, bits=8, parity=None, stop=1) # init with given parameters
#识别区域
roi1 = [(0, 17, 15, 25), # 左 x y w h
(65,17,15,25),# 右
(30,0,20,15),#上
(0,0,80,60)]#停车
def outuart(x,a,flag):
global uart;
f_x=0
f_a=0
if flag==0:
if x<0:
x=-x
f_x=1
if a<0:
a=-a
f_a=1
if flag==1: #十字
x,a,f_x,f_a=(0,0,0,1)
if flag==2: #上左
x,a,f_x,f_a=(0,0,1,0)
if flag==3: #上右
x,a,f_x,f_a=(0,0,1,1)
if flag==4: #stop
x,a,f_x,f_a=(1,1,1,2)
#frame=[0x2C,18,cx%0xff,int(cx/0xff),cy%0xff,int(cy/0xff),0x5B];
#data = bytearray(frame)
data = ustruct.pack("90:
theta_err = line.theta()-180
else:
theta_err = line.theta()
#直角坐标调整
img.draw_line(line.line(), color = 127)
#画出直线
#print(rho_err,line.magnitude(),rho_err)
if line.magnitude()>8:
#if -40