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



    • # 边缘检测例子:
      #
      # 这个程序示范了在图像上使用morph函数来进行边缘检测。
      # 然后在进行阈值和滤波
      
      import sensor, image, time
      import sensor, image, time, pyb
      
      #设置核函数滤波,核内每个数值值域为[-128,127],核需为列表或元组
      kernel_size = 1 # kernel width = (size*2)+1, kernel height = (size*2)+1
      kernel = [-1, -1, -1,\
                -1, +8, -1,\
                -1, -1, -1]
      # 这个一个高通滤波器。见这里有更多的kernel
      # http://www.fmwconcepts.com/imagemagick/digital_image_filtering.pdf
      thresholds = [(100, 255)] # grayscale thresholds设置阈值
      
      sensor.reset() # 初始化 sensor.
      sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.RGB565
      sensor.set_framesize(sensor.QQVGA) # or sensor.QVGA (or others)
      sensor.skip_frames(10) # 让新的设置生效
      clock = time.clock() # 追踪FPS
      
      # 在OV7725 sensor上, 边缘检测可以通过设置sharpness/edge寄存器来增强。
      # 注意:这个会edge detection can be enhanced
      # significantly by setting the sharpness/edge registers.
      # Note: This will be implemented as a function later.
      if (sensor.get_id() == sensor.OV7725):
          sensor.__write_reg(0xAC, 0xDF)
          sensor.__write_reg(0x8F, 0xFF)
      
      while(True):
          clock.tick() # Track elapsed milliseconds between snapshots().
          img = sensor.snapshot() # Take a picture and return the image.
      
          img.morph(kernel_size, kernel)
          #morph(size, kernel, mul=Auto, add=0),morph变换,mul根据图像对比度
          #进行调整,mul使图像每个像素乘mul;add根据明暗度调整,使得每个像素值加上add值。
          #如果不设置则不对morph变换后的图像进行处理。
          img.binary(thresholds)
          #利用binary函数对图像进行分割
      
          # Erode pixels with less than 2 neighbors using a 3x3 image kernel
          img.erode(1, threshold = 2)
          #侵蚀函数erode(size, threshold=Auto),去除边缘相邻处多余的点。threshold
          #用来设置去除相邻点的个数,threshold数值越大,被侵蚀掉的边缘点越多,边缘旁边
          #白色杂点少;数值越小,被侵蚀掉的边缘点越少,边缘旁边的白色杂点越多。
      
          print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
          # connected to your computer. The FPS should increase once disconnected.
          time.sleep(2000)
          print('好')
      
      

      现在是两秒输出帧数和好,但是我想在60秒时单独输出好,其余时间可以只输出帧数,请问应该如何改变,谢谢!



    • 在死循环里判断现在的时间,如果当前时间大于60秒就print。

      https://docs.singtown.com/micropython/zh/latest/openmvcam/openmvcam/quickref.html#id2

      虽然不太清楚你这么做的意义。。。