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



    • 0_1728914560929_f6cebfb15476f8a44b4babb7c8d96dd.png 0_1728914568016_c60bd35222b8d5296522bd04918c421.jpg

      import sensor, image, time

      Initialize the camera

      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(time=2000)
      width = sensor.width()
      height = sensor.height()

      Calculate the coordinates of the center ROI

      Threshold for rectangular shape

      threshold = ((42, 96, -31, 12, -20, 20))

      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

      while True:
      clock = time.clock()
      clock.tick()

      # Capture a snapshot from the camera
      img = sensor.snapshot()
      img.lens_corr(strength=1.8, zoom=1.0)
      
      # Find blobs that match the rectangular shape
      blobs = img.find_blobs([threshold], pixels_threshold=200, area_threshold=300, merge=True)
      max_blob=find_max(blobs)
      if max_blob:
          for r in img.find_rects(threshold = 10000):
              img.draw_rectangle(r.rect(), color = (255, 0, 0))
          # Get the four corners' coordinates of the detected shape
              x, y, w, h = r.rect()
              x1, y1 = x, y
              x2, y2 = x + w, y
              x3, y3 = x, y + h
              x4, y4 = x + w, y + h
      
          # Draw the four corners as crosses
              img.draw_cross(x1, y1, color=(255, 0, 0))
              img.draw_cross(x2, y2, color=(255, 0, 0))
              img.draw_cross(x3, y3, color=(255, 0, 0))
              img.draw_cross(x4, y4, color=(255, 0, 0))
      
          # Print the coordinates
              print("Corner 1: ({}, {})".format(x1, y1))
              print("Corner 2: ({}, {})".format(x2, y2))
              print("Corner 3: ({}, {})".format(x3, y3))
              print("Corner 4: ({}, {})".format(x4, y4))


    • 放弃吧,不要用OpenMV2 M4了。已经停产好多年啦。