openmv什么时候可以使用VGA模式?
-
我在把颜色识别和形状识别结合在一起的时候,发现可能是像素点太少的缘故,当距离较远或者角度不正的时候,会识别失败,所以想把QQVGA换成VGA,但是它会报错如下,有人知道怎么才能使用VGA模式吗?我用的7725v3和stm32H7芯片,所以不用担心处理速度的问题。
import sensor, image, time color_threshold1 = (0, 255, 40, 80, 40, 70) color_threshold2 = (0, 130, 40, 80, 40, 70) sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # use RGB565. sensor.set_framesize(sensor.QQVGA) # use QVGA for quailtiy ,use QQVGA for speed. sensor.skip_frames(10) # Let new settings take affect. sensor.set_auto_whitebal(False) #关闭白平衡。白平衡是默认开启的,在颜色识别中,需要关闭白平衡。 clock = time.clock() # Tracks FPS. #扩宽roi def expand_roi(roi): # set for QQVGA 160*120 extra = 5 win_size = (160, 120) (x, y, width, height) = roi new_roi = [x-extra, y-extra, width+2*extra, height+2*extra] if new_roi[0] < 0: new_roi[0] = 0 if new_roi[1] < 0: new_roi[1] = 0 if new_roi[2] > win_size[0]: new_roi[2] = win_size[0] if new_roi[3] > win_size[1]: new_roi[3] = win_size[1] return tuple(new_roi) while(True): clock.tick() # Track elapsed milliseconds between snapshots(). img = sensor.snapshot() # Take a picture and return the image. # pixels_threshold=100, area_threshold=100 blobs = img.find_blobs([color_threshold1], area_threshold=150) if blobs: #如果找到了目标颜色 print(blobs) for blob in blobs: #迭代找到的目标颜色区域 is_rect = 0 rect_s=0 max_s = -1 new_roi = expand_roi(blob.rect()) for c in img.find_rects(): is_rect = 1 rect_s=c.y()*c.h() # img.draw_rectangle(x,y,w,h [,color[,thickness=1[,fill=False]]]) if rect_s > max_s: max_s = rect_s max_rect = c if is_rect: # 如果有对应颜色的矩形 标记外框 img.draw_rectangle(new_roi) # rect img.draw_rectangle(blob.rect()) # rect #用矩形标记出目标颜色区域 img.draw_cross(blob[5], blob[6]) # cx, cy img.draw_rectangle(max_rect.x(), max_rect.y(), max_rect.w(), max_rect.h(),color = (0, 255, 0)) img.draw_rectangle(max_rect.x()-1, max_rect.y()-1, max_rect.w()+2, max_rect.h()+2,color = (0, 255, 0)) print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while # connected to your computer. The FPS should increase once disconnected. ![0_1563880779720_1.PNG](https://fcdn.singtown.com/55dd819e-826d-4e91-a4ac-083e8576c64b.PNG)
-
VGA模式下是压缩图像,不能进行算法处理。
-
@kidswong999 嗯,多谢解惑呀
-
能不能识别多种颜色然后同时画框
-
@egxs 不同的问题,单独发帖子。