• 免费好用的星瞳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上调用difference后有条纹



    • 6_1709084660272_f045287bb3e91cf365629633aa5d76f.png 5_1709084660271_aba9ea87bf32851469ea19e705c7580.png 4_1709084660271_2388838a0779e1acb6e915f660157da.png 3_1709084660271_44504a7b8e12c09576e28cb1466d5e4.jpg 2_1709084660271_7885dc5ec257ba51d11ee7843cb228d.png 1_1709084660270_7bc9b535aaeee96fc99105bf14e257a.png 0_1709084660268_4e0b44291336bbbe47a1f4eab36c804.png

      import sensor, image, time
      
      sensor.reset()
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_framesize(sensor.QVGA)
      
      
      sensor.skip_frames(time = 2000) # Give the user time to get ready.
      
      i=0
      m=320
      n=240
      temp = sensor.alloc_extra_fb(m, n, sensor.GRAYSCALE)
      img_past = sensor.alloc_extra_fb(m, n, sensor.GRAYSCALE)
      img_now = sensor.alloc_extra_fb(m, n, sensor.GRAYSCALE)
      kernel_edge = [1, 1,  1, \
                1,  -8,  1, \
                 1,  1,  1]
      
      
      img_past=sensor.snapshot()
      clock = time.clock()
      while i < 1000:
          # 获取当前灰度图
          img_now = sensor.snapshot()
      
          #当前灰度图归一化
          #temp.normalize(0, 255)
      #    img_now.replace(temp)
          #差分图的绝对值
          img_now.save("temp3_withoutdifference/img_now"+str(i)+".bmp")
          img_diff2 = img_now.difference(img_past)
          img_diff2.morph(1, kernel_edge)
          img_diff2.save("temp2/diff"+str(i)+".bmp")
      
      
      
          i+=1
          img_past.replace(img_now)
          print(clock.fps())
      


    • 问题在于

      img_now = sensor.snapshot()
      img_diff2 = img_now.difference(img_past)
      

      应该换成

      img = sensor.snapshot()
      img_now.replace(img)
      img.difference(img_past)
      img_diff2.replace(img)
      

      下面的代码是可以运行的

      import sensor, image, time
      
      sensor.reset()
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_framesize(sensor.QVGA)
      
      
      sensor.skip_frames(time = 2000) # Give the user time to get ready.
      
      i=0
      m=320
      n=240
      #temp = sensor.alloc_extra_fb(m, n, sensor.GRAYSCALE)
      img_past = sensor.alloc_extra_fb(m, n, sensor.GRAYSCALE)
      img_now = sensor.alloc_extra_fb(m, n, sensor.GRAYSCALE)
      kernel_edge = [1, 1,  1, \
                1,  -8,  1, \
                 1,  1,  1]
      
      
      img=sensor.snapshot()
      img_past.replace(img)
      
      clock = time.clock()
      while i < 1000:
          # 获取当前灰度图
          img = sensor.snapshot()
      
          #当前灰度图归一化
          #temp.normalize(0, 255)
          img_now.replace(img)
          #差分图的绝对值
      #    img.save("temp3_withoutdifference/img_now"+str(i)+".bmp")
          img.difference(img_past)
          img.morph(1, kernel_edge)
      #    img.save("temp2/diff"+str(i)+".bmp")
      
      
      
          i+=1
          img_past.replace(img_now)
          print(clock.fps())