• 免费好用的星瞳AI云服务上线!简单标注,云端训练,支持OpenMV H7和OpenMV H7 Plus。可以替代edge impulse。 https://forum.singtown.com/topic/9519
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 我想要通过别人给我发送信息,更换目标,但是摄像头为什么会卡



    • Blob Detection Example#by:王雨晴 2019年7月16日import sensor, image, time,pyb,mathfrom pyb import UARTfrom pyb import Pinred_threshold_01 = (58, 72, 44, 70, -1, 38)yellow_threshold_01 = (70, 98, -16, 7, 58, 72)#设置红色的阈值,括号里面的数值分别是L A B 的最大值和最小值(minL, maxL, minA,# maxA, minB, maxB),LAB的值在图像左侧三个坐标图中选取。如果是灰度图,则只需#设置(min, max)两个数字即可。# You may need to tweak the above settings for tracking green things...# Select an area in the Framebuffer to copy the color settings.K=800sensor.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.分辨率为120160sensor.skip_frames(10) # Let new settings take affect.sensor.set_auto_whitebal(False)#关闭白平衡。白平衡是默认开启的,在颜色识别中,需要关闭白平衡。clock = time.clock() # Tracks FPS.uart3= UART(3, 9600)uart1= UART(1, 9600)uart1= UART(1, 9600, timeout_char=1000)''' 扩宽roi'''def expand_roi(roi): # set for QQVGA 160120 extra = 5 win_size = (160, 120) (x, y, width, height) = roi new_roi = [x-extra, y-extra, width+2extra, height+2extra] 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)AH = bytearray([0x40])uart1.write(AH)while(True): if uart1.any(): a=uart1.readline().decode().strip() print(a) else: a=0 if a==0: clock.tick() img = sensor.snapshot()#.lens_corr(1.8) # Take a picture and return the image. blobs = img.find_blobs([red_threshold_01], area_threshold=150)#如果返回的边界框小于area_threshold就返回none if blobs: #如果找到了目标颜色 for b in blobs: x = b.cx() y = b.cy() print(x,y) if x>=60 and x<=100: is_circle = False max_circle = None max_radius = -1 new_roi = expand_roi(b.rect()) for c in img.find_circles(threshold = 3500, x_margin = 20, y_margin = 20, r_margin = 10, roi=new_roi): is_circle = True if c.r() > max_radius: max_radius = c.r() max_circle = c if is_circle: # 如果有对应颜色的圆形 标记外框 # Draw a rect around the blob. img.draw_rectangle(new_roi) # rect img.draw_rectangle(b.rect()) # rect #用矩形标记出目标颜色区域 img.draw_rectangle(b[0:4]) img.draw_cross(b[5], b[6]) # cx, cy img.draw_circle(max_circle.x(), max_circle.y(), max_circle.r(), color = (0, 255, 0)) img.draw_circle(max_circle.x(), max_circle.y(), max_circle.r() + 1, color = (0, 255, 0)) Lm = (b[2]+b[3])/2 #b2是色块的长,b3是色块的宽 length =(K/Lm) print(length) str='%d'%(length) print(length) #uart1.write(str) if a==0: clock.tick() img = sensor.snapshot()#.lens_corr(1.8) # Take a picture and return the image. blobs = img.find_blobs([yellow_threshold_01], area_threshold=150)#如果返回的边界框小于area_threshold就返回none if blobs: #如果找到了目标颜色 for b in blobs: x = b.cx() y = b.cy() print(x,y) if x>=60 and x<=100: uart3.write('1') is_circle = False max_circle = None max_radius = -1 new_roi = expand_roi(b.rect()) for c in img.find_circles(threshold = 3500, x_margin = 20, y_margin = 20, r_margin = 10, roi=new_roi): is_circle = True # img.draw_circle(c.x(), c.y(), c.r(), color = (255, 255, 255)) if c.r() > max_radius: max_radius = c.r() max_circle = c if is_circle: img.draw_rectangle(new_roi) # rect img.draw_rectangle(b.rect()) # rect img.draw_rectangle(b[0:4]) img.draw_cross(b[5], b[6]) # cx, cy img.draw_circle(max_circle.x(), max_circle.y(), max_circle.r(), color = (0, 255, 0)) img.draw_circle(max_circle.x(), max_circle.y(), max_circle.r() + 1, color = (0, 255, 0)) Lm = (b[2]+b[3])/2 #b2是色块的长,b3是色块的宽 length =(K/Lm) print(length) str='%d'%(length) print(length)



    • 必看:玩转星瞳论坛
      https://forum.singtown.com/topic/57/必看-玩转星瞳论坛
      了解一下图片上传,代码格式等问题