导航

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

    l3wz

    @l3wz

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

    l3wz 关注

    l3wz 发布的帖子

    • 使用openmv4H7,用到了copy这个函数,显示错误(图示)是因为处理能力不够吗,如果是的话怎么解决?
      import sensor, image, time
      
      # 初始化摄像头
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(time = 2000)
      thread=(50,255,-128,127,-128,127)
      sensor.set_auto_whitebal(False)
      sensor.set_contrast(5)
      # 创建两个图像缓冲区last_frame是背景
      current_frame = sensor.snapshot()
      #last_frame = current_frame.copy()
      last_update_time = 0
      person=0
      while(True):
          x=0
          y=0
          ry=0
          rx=0
          i=0
      
          # 获取当前帧并计算差分图像
          current_frame = sensor.snapshot()
      
          if time.time() - last_update_time > 0.5 :
              #sensor.snapshot().save("bg.bmp")
              last_frame = current_frame.copy()
              last_update_time = time.time()
      
      
      
          diff_frame = current_frame.difference(last_frame)
      
          # 对差分图像进行阈值分割和形态学操作
          threshold = (50, 255)
          binary_frame = diff_frame.to_grayscale()
          binary_frame.binary([threshold])
          binary_frame.erode(1)
          binary_frame.dilate(4)
          # 检测阈值
          ROI = (0, 0, binary_frame.width(), binary_frame.height())
          statistics=binary_frame.get_statistics(roi=ROI)
          gray_count=statistics.mean()
          #print("目标区域:", gray_count)
          if gray_count>50:
             person=1
             last_update_time = time.time()
          if gray_count<50:
             person=0
          # 进行连通性分析并绘制矩形框
          blobs = binary_frame.find_blobs([thread],area_threshold=2, pixels_threshold=2,merge=False)
          for blob in blobs:
              if blob.pixels() > 1000:
                  current_frame.draw_rectangle(blob.rect())
                  i=i+1
                  x=x+blob.cx()
                  y=y+blob.cy()
      
          if i>0:
              x=x/i
              y=y/i
          rx=x/binary_frame.width()
          ry=y/binary_frame.height()
          print("色块数:", i,"x:",x,"y:",y)
          print("x的相对位置",rx,"y的相对位置",ry)
          time.sleep(0.1)
      
      ```![0_1705200390750_微信图片_20240114104601.png](https://fcdn.singtown.com/12edd7d6-e462-4d79-87c4-71e39a88fad8.png)
      发布在 OpenMV Cam
      L
      l3wz
    • 如何对多个灰度图像求平均获得一副新的灰度图像?

      想要对多幅图像求平均获得一个背景图像,谢谢大佬

      发布在 OpenMV Cam
      L
      l3wz
    • 帧间差分法实现运动物体检测,在彩色图转换灰度图出现错误
      # Untitled - By: Administrator - 周四 5月 11 2023
      
      import sensor, image, time
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      
      clock = time.clock()
      
      lastfram=None
      
      
      while(True):
          clock.tick()
      
      
      
      
          img = sensor.snapshot()
      
          img = image.rgb_to_grayscale(img)
      
          img=img.binary(50)
      
          if lastfram is None:
            lastfram = img.copy()
            continue
      
          diff=image.difference(lastfram,img)
      
          blobs=diff.find_blobs()
      
          count=len(blobs)
      
          lastfram=img.copy()
      
          print(clock.fps())
      

      0_1683882430565_2bcb6dba-bbbd-44e8-bb23-f04142a9b289-图片.png 求问整个程序有什么错误

      发布在 OpenMV Cam
      L
      l3wz