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



    • import sensor, time, image
      from pyb import Timer
      
      sensor.reset()
      sensor.set_contrast(3)
      sensor.set_gainceiling(16)
      sensor.set_framesize(sensor.VGA)
      sensor.set_windowing((220, 190, 200, 100))
      sensor.set_pixformat(sensor.GRAYSCALE)
      
      num=0
      flag=0
      
      
      eyes_cascade = image.HaarCascade("eye", stages=24)
      clock = time.clock()
      
      while (True):
          clock.tick()
          img = sensor.snapshot()
          eyes = img.find_features(eyes_cascade, threshold=0.5, scale_factor=1.5)
      
          for e in eyes:
              iris = img.find_eye(e)
              img.draw_rectangle(e)
              img.draw_cross(iris[0], iris[1])
      
              a=str(img.draw_cross(iris[0], iris[1]).copy())#数据处理
              flag=int(a[5])
      
              def ad(timer):#定义函数
                  global num
                  num=num+1
      
              tim = Timer(2, freq=6)#定时器2,频率为6
              if flag==2:
                  tim.callback(ad)#调用函数
                  print(num)
      

      0_16208081I.png



    • 缺失了11,13和27,想把这个缺失的个数3个有没有什么好办法写出来



    • 这个代码我没有运行出结果,你这个a是个啥



    • 而且在最里面定义函数和绑定,有啥用?😅



    • @kidswong999 a是把img.draw_cross(iris[0], iris[1])里的数据提取出来 用来检测瞳孔识别 这个代码对着眼睛 然后你眨眼 打印数据就会丢失 丢失的个数就是眨眼次数



    • 很奇怪,建议你换一个思路。

      if iris 就是判断是否有眼睛。



    • 你这个思路我们最开始就是这个 但是根本运行不到else那里去0_1621075822570_O()(_))Q2_3ZHK98OQ6MT`7.png

      # 瞳孔识别例程
      #
      # 这个例子展示了如何找到图像中的眼睛后的瞳孔(瞳孔检测)。 该脚本使用
      # find_eyes函数来确定应该包含瞳孔的roi的中心点。 它通过基本上找到瞳孔
      # 中心的眼睛最黑暗的区域的中心。
      #
      # 注意:此脚本首先不会检测到脸部,请将其与长焦镜头一起使用。
      
      import sensor, time, image
      
      #重置传感器
      sensor.reset()
      
      #传感器设置
      sensor.set_contrast(3)
      sensor.set_gainceiling(16)
      
      # 将分辨率设置为VGA。
      sensor.set_framesize(sensor.VGA)
      
      #拉近镜头,使眼睛的更多细节展现在摄像头中。
      # 裁剪图像到200x100,这提供了更多的细节和更少的数据处理
      sensor.set_windowing((220, 190, 200, 100))
      
      sensor.set_pixformat(sensor.GRAYSCALE)
      
      # 加载眼睛的haar算子
      # 默认情况下,这将使用所有阶段,较低的阶段更快但不太准确。
      eyes_cascade = image.HaarCascade("eye", stages=24)
      print(eyes_cascade)
      
      # FPS clock
      clock = time.clock()
      
      while (True):
          clock.tick()
          # Capture snapshot
          img = sensor.snapshot()
          # Find eyes !
          # Note: Lower scale factor scales-down the image more and detects smaller objects.
          # 注意:较低的比例因子会进一步缩小图像,并检测较小的物体。
          # Higher threshold results in a higher detection rate, with more false positives.
          # 阈值越高,检测率越高,假阳性也越多。
          eyes = img.find_features(eyes_cascade, threshold=0.5, scale=1.5)
          # 先利用find_features函数识别人眼。image.find_features(cascade, threshold=0.5, scale=1.5),thresholds越大,
          # 匹配速度越快,错误率也会上升。scale可以缩放被匹配特征的大小。
      
          # 在识别到的人眼中寻找瞳孔。
          for e in eyes:
              iris = img.find_eye(e)
              #image.find_eye((x, y, w, h)),find_eye的参数是一个矩形区域,左上顶点为
              #(x,y),宽w,高h,注意(x,y,w,h)是一个元组,不要漏掉括号()。上行代码中
              #的e即代表识别到的眼睛的矩形区域。
              #find_eye的原理是找到区域中颜色最深处的中心。
              img.draw_rectangle(e)
              img.draw_cross(iris[0], iris[1])
              if iris:
                  print(2)
              else:
                  print(1)
      


    • 当然不会运行到,因为你在是for循环里面判断的。



    • 那您有什么好办法吗 我试了好多好多种



    • @kidswong999 那您有什么好办法吗 我试了好多好多种



    • 首先,我不知道你具体要做什么。



    • @kidswong999 就是想在每隔一分钟可以把人眼的眨眼次数给搞出来



    • @guzr 大佬 我这个有办法嘛