• OpenMV VSCode 扩展发布了,在插件市场直接搜索OpenMV就可以安装
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 识别矩形时识别对象不稳定,经常框到图像边缘



    • 0_1618933214432_4d96d8c0-564b-433c-bd49-bb437a413ae3-image.png
      0_1618933244832_86d29a55-aca7-408f-b12d-26ed1ece49fb-image.png

      # Untitled - By: Misaki - 周六 12月 19 2020
      
      import sensor, image, time
      
      sensor.reset()
      sensor.set_pixformat(sensor.GRAYSCALE)
      #sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      
      clock = time.clock()
      def find_max(rects):
          max_size=0
          max_rect=rects
          for rect in rects:
              if rect[2]*rect[3] > max_size:
                  max_rect=rects
                  max_size = rect[2]*rect[3]
          return max_rect
      def find_max_rects(img):
          rects=img.find_rects(threshold=12000)
          for max_rect in find_max(rects):
              img.draw_rectangle(max_rect.rect(), color = (255, 255, 255))
              #img.draw_edges(max_rect.corners(), color = (255, 255, 255))
      
              return max_rect
          else:
              return 0
      while(True):
          clock.tick()
          img = sensor.snapshot().gaussian(1).find_edges(image.EDGE_CANNY,threshold=(50, 90))
          print(find_max_rects(img))
          '''for c in img.find_circles(threshold = 2500, x_margin =10, y_margin = 10, r_margin = 10,r_min = 50, r_max = 200, r_step = 2):
              img.draw_circle(c.x(), c.y(), c.r(), color = (255, 255, 255))
              print(c)
          for l in img.find_line_segments(merge_distance = 0, max_theta_diff = 0):
              img.draw_line(l.line(), color = (255, 0, 0))
              print(l)'''
      
          print(clock.fps())
      
      


    • 你这个是img.find_circles啊,也不是矩形啊。