在识别矩形的例程中,我一个大正方形的平面摆在中间,都不识别,周围的小矩形反而能识别
Z
z4l1
@z4l1
0
声望
34
楼层
1383
资料浏览
0
粉丝
0
关注
z4l1 发布的帖子
-
不能同时输出色块与APriltag的坐标
import sensor, image, time, math,pyb import json from pyb import Pin, Timer,UART,LED green_led = LED(1) blue_led = LED(2) #rgb_gain_db=(-6.02073, -2.231719, -3.454361) sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # use RGB565. sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed. sensor.skip_frames(time=2000) # Let new settings take affect. sensor.set_auto_gain(False) #sensor.set_auto_whitebal(False,rgb_gain_db) sensor.set_auto_whitebal(False) clock = time.clock() #red_threshold=(33, 78, 6, 52, -9, 62) #red_threshold=(33, 94, -84, -30, 9, 72) red_threshold=(100, 71, 127, -39, 89, -27) #白色 uart = pyb.UART(3,500000,timeout_char=1000)#串口初始化 #pyb.delay(10) # 注意!与find_qrcodes不同,find_apriltags 不需要软件矫正畸变就可以工作。 # 注意,输出的姿态的单位是弧度,可以转换成角度,但是位置的单位是和你的大小有关,需要等比例换算 # f_x 是x的像素为单位的焦距。对于标准的OpenMV,应该等于2.8/3.984*656,这个值是用毫米为单位的焦距除以x方向的感光元件的长度,乘以x方向的感光元件的像素(OV7725) # f_y 是y的像素为单位的焦距。对于标准的OpenMV,应该等于2.8/2.952*488,这个值是用毫米为单位的焦距除以y方向的感光元件的长度,乘以y方向的感光元件的像素(OV7725) # c_x 是图像的x中心位置 # c_y 是图像的y中心位置 f_x = (2.8 / 3.984) * 160 # 默认值 f_y = (2.8 / 2.952) * 120 # 默认值 c_x = 160 * 0.5 # 默认值(image.w * 0.5) c_y = 120 * 0.5 # 默认值(image.h * 0.5) def degrees(radians): return (180 * radians) / math.pi def find_max(blobs): max_size=0 for blob in blobs: if blob[2]*blob[3] > max_size: max_blob=blob max_size = blob[2]*blob[3] return max_blob def high(x): x=x>>8 return x def low(x): x=x&0xff return x while(True): clock.tick() # Track elapsed milliseconds between snapshots(). img = sensor.snapshot() # Take a pv/.icture and return the image. blobs = img.find_blobs([red_threshold],pixels_threshold=200, area_threshold=3000) if blobs: blue_led.on() max_blob = find_max(blobs) red_x= int(max_blob[5]-img.width()/2) red_y= int(img.height()/2-max_blob[6]) img.draw_rectangle(max_blob[0:4]) img.draw_cross(max_blob[5], max_blob[6]) else: red_x = red_y =0 for tag in img.find_apriltags(fx=f_x, fy=f_y, cx=c_x, cy=c_y): # 默认为TAG36H11 img.draw_rectangle(tag.rect(), color = (255, 0, 0)) img.draw_cross(tag.cx(), tag.cy(), color = (0, 255, 0)) print_args = (tag.x_translation(), tag.y_translation(), tag.z_translation(), \ degrees(tag.x_rotation()), degrees(tag.y_rotation()), degrees(tag.z_rotation())) TX = int(tag.x_translation()*10) TY = int(tag.y_translation()*10) CZ = int(degrees(tag.z_rotation())) # 位置的单位是未知的,旋转的单位是角度 if(img.find_apriltags()): Tx = TX Ty = TY Cz = CZ else: Tx = Ty =CZ =0 uart.writechar(high(red_x)) uart.writechar(low(red_x)) uart.writechar(high(red_y)) uart.writechar(low(red_y)) uart.writechar(high(Tx)) uart.writechar(low(Tx)) uart.writechar(high(Ty)) uart.writechar(low(Ty)) uart.writechar(high(CZ)) uart.writechar(low(CZ)) uart.writechar(0x55) uart.writechar(0xAA) print("red_x",red_x,"red_y",red_y,"Tx",Tx,"Ty",Ty,"CZ",CZ)
-
RE: 我的openmv3程序在不接USB情况下无法启动,只能在IDE里点开始运行才能运行,这个怎么解决?
我已经处理好了,在IDE工具一栏,重置OpenMV Cam就行了
-
RE: 我的openmv3程序在不接USB情况下无法启动,只能在IDE里点开始运行才能运行,这个怎么解决?
同问,之前用的好好的,好像是下载新的程序后就不能脱机运行了,重新下载原来的程序也不行了
-
openMV 关于find_displacement的问题,不可迭代是怎么回事?
import sensor, image, time sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.GRAYSCALE sensor.set_framesize(sensor.B64X64) # or B40x30 or B64x64 clock = time.clock() # Tracks FPS. old = sensor.snapshot() #先获取一张图片 while(True): clock.tick() # Track elapsed milliseconds between snapshots(). img = sensor.snapshot() # Take a picture and return the image. [delta_x, delta_y, response] = old.find_displacement(img) #delta_x delta_y分别表示 x y 方向上,这一帧图像相比上帧图像移动的像素数目。 old = img.copy() print("%0.1f X\t%0.1f Y\t%0.2f QoR\t%0.2f FPS" % \ (delta_x, delta_y, response, clock.fps()))