资源简介
2020电赛G题openmv程序
能实现形状识别,颜色识别,边长测量。
球体识别通过颜色识别实现。
代码亲测可用。
代码片段和文件信息
enable_lens_corr = True
import sensor image timepybmath
from pyb import UART
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
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
tri_thresholdr = (0 100 32 84 -8 56)
tri_thresholdg = (0 100 -58 5 10 43)
tri_thresholdb = (0 100 -9 31 -74 -25)
basketball= (0 100 32 84 -8 56)
#basketball =(0 100 12 45 -5 48)
volleyball= (0 100 -37 12 23 106)#(15 80 -58 -10 -35 51) (0 99 -8 24 21 62)
soccer=(0 14 -10 11 -10 13)
thresholds = (0 100 -128 127 -128 127)
clock = time.clock()
K=1#the value should be measured
flag=0
flag_ob=0
flag_ball=1
q= b‘0\r\n‘
pan_error = 0
tilt_error = 0
R=0
uart = UART(3 115200)
def find_max(blobs):
max_size=0
for blob in blobs:
if blob.pixels()>=250 and blob.pixels()<=7000:
if blob.pixels() > max_size:
max_blob=blob
max_size = blob.pixels()
return max_blob
while(True):
clock.tick()
if uart.any():
q = uart.readline()#.decode().strip()
print(“+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++“q)
img = sensor.snapshot()#.lens_corr(1.8)#.binary([thresholds] invert=False zero=True)
img.remove_shadows(img)#去阴影
blobs_t = img.find_blobs([thresholds])
blobs_tr = img.find_blobs([tri_thresholdr])
#print(“######“blobs_t)
if blobs_tr:
blobs_t=find_max(blobs_tr)
flag_ob=1
#print(“)))))))))“blobs_t)
blobs_tg = img.find_blobs([tri_thresholdg])
if blobs_tg:
blobs_t=find_max(blobs_tg)
flag_ob=2
#print(“__________“blobs_t)
blobs_tb = img.find_blobs([tri_thresholdb])
if blobs_tb:
blobs_t=find_max(blobs_tb)
flag_ob=3
#print(“+++++++++++++++++++“blobs_tb)
#if len(blobs) == 1:
# Draw a rect around the
#print(“%%%%%%%%“blobs_t)
#if (blobs_t and flag_ob!=0):
#if (0):
#b=find_max(blobs_t)
#for b in blobs_t:
#if b:
if q==b‘0\r\n‘ :
if (blobs_t and flag_ob!=0):
b=blobs_t
img.draw_rectangle((b[0]-10b[1]-10b[2]+20b[3]+20))
#img.draw_rectangle((b[0]b[1]b[2]b[3]))
#print(b.pixels()“SSSSSSSSSSSSSSSS“)
#________________________________________________________________________
blobs_r = img.find_rects(roi =(b[0]-10b[1]-10b[2]+20b[3]+20)threshold = 25000)
#print(“1AAAAA“flag)
if(blobs_r):
flag=1
#r=find_max(blobs_r)
相关资源
- openmv一次性识别红黄蓝三种颜色
- 工程训练大赛openmv二维码、色环、色
- OpenMV交通灯识别例程
- openmv颜色识别代码
- openmv 识别3个颜色 工程训练大赛
- OpenMV4四代原理图与PCB.zip
- 小车基于openmv摄像头的红灯识别
- openmv定点代码
- Openmv主控物料分拣小车拣乒乓球小车
- Openmv主控物料分拣小车拣乒乓球小车
- 官方OpenMV4.zip
- openmv智能小车寻线代码
- OpenMV形状识别And颜色识别.py
- 颜色识别+串口通信——华北五省ope
- openmv识别红绿蓝物块颜色,并输出物
- 工训物流小车颜色及二维码识别
- OPENMV用作光流模组程序
- 电赛电磁炮python程序(sensor)
- openmv识别红色,串口通信,可用于信
- 基于OpenMV与STM32的寻球小车.rar
- openmv目标检测代码
-
xm
l_cascade.py opencv_traincascade.exe ope - OpenMV视觉识别 舵机云台颜色跟踪
- openmv识别物块颜色,并输出物块距离
- openmv识别特定颜色且打印坐标到串口
评论
共有 条评论