导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. 12pu
    1
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    12pu

    @12pu

    0
    声望
    1
    楼层
    202
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    12pu 关注

    12pu 发布的帖子

    • 移植了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))
      发布在 OpenMV Cam
      1
      12pu