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



    • sensor.reset()
      sensor.set_pixformat(sensor.RGB565) # 灰度更快(160x120 max on OpenMV-M7)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_whitebal(False)
      clock = time.clock()
      class Rec(object):
          flag = 0
          x = 0
          y = 0
      
      def Find_Max(rects):
          max_size=1
          if rects:
              max_rect = 0
              for rect in rects:
                rect_size =rect.w()*rect.h()
                if ((rect_size > max_size) & (rect_size > 100)) :#& (blob.density()<1.2*math.pi/4) & (blob.density()>0.8*math.pi/4)
                  if ( math.fabs( rect.w() / rect.h() - 1 ) < 2.0 ) :
                       max_rect=rect
                       max_size = rect.w()*rect.h()
              return max_rect
      
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          for r in img.find_rects(threshold = 12000):
            img.draw_rectangle(r.rect(),color = (255, 0, 0))
            for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
            max_rect = Find_Max(p)
            img.draw_cross(max_rect.x() + max_rect.w()//2, max_rect.y() + max_rect.h()//2)
            x1 = max_rect.x() + max_rect.w()//2
            y1 = max_rect.y() + max_rect.h()//2
            fps=int(clock.fps())
            Message.Ctr.T_ms = (int)(1000/fps)
            img.draw_cross(x1, y1)
            Rec.flag = 1
            Rec.x = x1-80
            Rec.y = y1-60
               #print(r)
            print(' x= ',Rec.x,'y= ',Rec.y,'fps',fps,'T_ms',Message.Ctr.T_ms)
            LED(3).toggle()
            print("flag= ",Rec.flag)
            Message.UartSendData(Message.DotDataPack(1,Rec.flag,Rec.x,Rec.y,Message.Ctr.T_ms))
      

      0_1625386478073_11231231.png



    • 第31行,max_rect = Find_Max(p)改为max_rect = Find_Max(r)