我刚刚尝试了信标追踪和红色物块识别,距离近都能识别的到,但远了就不行啦,,,
F
fimw
@fimw
0
声望
6
楼层
1111
资料浏览
0
粉丝
0
关注
fimw 发布的帖子
-
RE: 做了一个检测圆的程序,但一直显示有错误,说ROI无效,这是要怎么解决呢?
其实还有代码的,这是主函数,sensor初始化在主函数里,我在主函数里,还是一样的错误
import sensor, image, time, math, struct import json from pyb import LED,Timer from struct import pack, unpack import Message,LineFollowing,DotFollowing,find_circle #初始化镜头 sensor.reset() sensor.set_pixformat(sensor.RGB565)#设置相机模块的像素模式 sensor.set_framesize(sensor.QQVGA)#设置相机分辨率160*120 sensor.skip_frames(time=3000)#时钟 sensor.set_auto_whitebal(False)#若想追踪颜色则关闭白平衡 clock = time.clock()#初始化时钟 #主循环 while(True): clock.tick()#时钟初始化 #接收串口数据 Message.UartReadBuffer() if Message.Ctr.WorkMode==1:#点检测 DotFollowing.DotCheck() elif (Message.Ctr.WorkMode==2):#线检测 LineFollowing.LineCheck() elif (Message.Ctr.WorkMode==3):#圆检测 find_circle.CircleCheck() elif(Message.Ctr.WorkMode==4):#Led检测 #用户数据发送 #Message.UartSendData(Message.UserDataPack(127,127,32767,32767,65536,65536,65536,65536,65536,65536)) #计算程序运行频率 if Message.Ctr.IsDebug == 1: fps=int(clock.fps()) Message.Ctr.T_ms = (int)(1000/fps) print('fps',fps,'T_ms',Message.Ctr.T_ms) #************************************ (C) COPYRIGHT 2019 ANO ***********************************#
-
RE: 做了一个检测圆的程序,但一直显示有错误,说ROI无效,这是要怎么解决呢?
就这个错误
Traceback (most recent call last):
File "", line 25, in
OSError: Invalid ROI dimensions!
MicroPython v1.9.4-4553-gb4eccdfe3 on 2019-05-02; OPENMV4 with STM32H743
Type "help()" for more information. -
做了一个检测圆的程序,但一直显示有错误,说ROI无效,这是要怎么解决呢?
from pyb import LED,Timer import sensor, image, time, math, struct import Message class yuan(object): flag = 0 r = 0 x = 0 y = 0 yuan=yuan() circles=[] def find_max_circle(circles): max_r=0 for c in circles: if c.r()>max_r: max_circle=c max_r=c.r() return max_circle while(True): #def CircleCheck(): img = sensor.snapshot().lens_corr(1.8) circles.clear() all_circles=img.find_circles(x_stride=1,y_stride=1,threshold = 2000, x_margin = 10, y_margin = 10, r_margin = 10, r_min = 2, r_max = 100) for c in all_circles: if c.r()<22: circles.append(c) if circles: max_circle = find_max_circle(circles) img.draw_circle(max_circle.x(),max_circle.y(),max_circle.r()) img.draw_cross(max_circle.x(), max_circle.y()) yuan.x = max_circle.x()-80 yuan.y = max_circle.y()-60 yuan.flag = 1 LED(3).toggle() LED(2).toggle() else: yuan.flag = 0 LED(2).off() LED(3).off() Message.UartSendData(Message.DotDataPack(yuan.flag,yuan.x,yuan.y,max_circle.x(), max_circle.y()))