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



    • return_pin = Pin('P0', Pin.PULL_UP, Pin.OUT_PP)
      def return_start():
          wave_trig_pin.value(1)
          utime.sleep_us(15)
          return_pin.value(0)
      callback = lambda e: print("intr")
      extint = ExtInt(Pin('P0'), ExtInt.IRQ_RISING, Pin.PULL_NONE, callback)
      #SUB = "s1"
      NUM_SUBJECTS = 2 #图像库中不同人数,一共6人
      NUM_SUBJECTS_IMGS = 20 #每人有20张样本图片
      
      img = None
      pmin = 999999
      num=0
      def min(pmin, a, s):
          global num
          if a<pmin:
              pmin=a
              num=s
          return pmin
      def callback(line):
          if(return_pin .value()):
              print("4")
          else:
              extint.disable()
      while(1):
          def callback(line):
              if(return_pin .value()):
                  print("4")
              else:
                  extint.disable()
          img = sensor.snapshot()
          d0 = img.find_lbp((0, 0, img.width(), img.height()))
          img = sensor.snapshot()
          if uart.any():
              t=uart.readline().decode().strip()
              print(t)
          for s in range(1, NUM_SUBJECTS+1):
              dist = 0
              for i in range(2, NUM_SUBJECTS_IMGS+1):
                  img = image.Image("singtown/s%d/%d.pgm"%(s, i))
                  d1 = img.find_lbp((0, 0, img.width(), img.height()))
                  dist += image.match_descriptor(d0, d1)#计算d0 d1即样本图像与被检测人脸的特征差异度。
              pmin = min(pmin, dist/NUM_SUBJECTS_IMGS, s)#特征差异度越小,被检测人脸与此样本更相似更匹配。
              print(num) # num为当前最匹配的人的编号。
              uart.write(str(num)+'\r\n') #发送串口数据
      
      

      我想靠按键实现外部中断 运行程序没有报错 但是按键没有反应 跳不出来循环



    • 首先代码不全,我没办法运行。

      你按键加上拉电阻或者下拉电阻了吗?



    • import sensor, time, image, pyb
      from pyb import UART
      from pyb import Pin
      from pyb import ExtInt

      sensor.reset() # Initialize the camera sensor.
      sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.GRAYSCALE
      sensor.set_framesize(sensor.B128X128) # or sensor.QQVGA (or others)
      sensor.set_windowing((92,112))
      sensor.skip_frames(10) # Let new settings take affect.
      sensor.skip_frames(time = 2000) #等待5s
      uart = UART(3, 115200)#串口波特率
      uart.init(115200,bits=8,parity=None,stop=1)

      key_pin=Pin('P7',pyb.Pin.OUT_OD,pyb.Pin.PULL_UP)

      #SUB = "s1"
      NUM_SUBJECTS = 2 #图像库中不同人数,一共6人
      NUM_SUBJECTS_IMGS = 20 #每人有20张样本图片

      img = None
      pmin = 999999
      num=0
      def min(pmin, a, s):
      global num
      if a<pmin:
      pmin=a
      num=s
      return pmin
      #外部中断配置
      def callback(line):
      if(key_pin.value()):
      print('5')
      else:
      print('6')
      #extint = pyb.ExtInt(key_pin, pyb.ExtInt.IRQ_RISING_FALLING, pyb.Pin.PULL_DOWN, callback)
      extint = ExtInt(Pin('P7'), ExtInt.IRQ_RISING, Pin.PULL_NONE, callback)
      while(1):
      img = sensor.snapshot()
      d0 = img.find_lbp((0, 0, img.width(), img.height()))
      img = sensor.snapshot()
      if uart.any():
      t=uart.readline().decode().strip()
      print(t)
      for s in range(1, NUM_SUBJECTS+1):
      dist = 0
      for i in range(2, NUM_SUBJECTS_IMGS+1):
      img = image.Image("singtown/s%d/%d.pgm"%(s, i))
      d1 = img.find_lbp((0, 0, img.width(), img.height()))
      dist += image.match_descriptor(d0, d1)#计算d0 d1即样本图像与被检测人脸的特征差异度。
      pmin = min(pmin, dist/NUM_SUBJECTS_IMGS, s)#特征差异度越小,被检测人脸与此样本更相似更匹配。
      print(num) # num为当前最匹配的人的编号。
      uart.write(str(num)+'\r\n') #发送串口数据
      我没有添加



    • 没加外置拉电阻的话,要配置内部拉电阻,根据你的按键的电路。你用电压表量一下电压肯定都不对。