• 免费好用的星瞳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, pyb
      from pyb import UART
      from pyb import Pin, ExtInt
      
      pin0 = Pin('P0', Pin.IN, Pin.PULL_UP)
      
      def callback_PIN0(line):
      
          pin0.value()==0
      
          pyb.delay(10)
      
      extint = pyb.ExtInt(pin0, pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_UP, callback_PIN0)
      
      while(True):
      
          if pin0.value()==0:
      
              uart = UART(3, 115200)
      
              if uart.any():
      
                      a=uart.readline().decode().strip()
      
              pyb.delay(10)
      
      
      
      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 = 5000) #等待5s
      
      
      #SUB = "s1"
      NUM_SUBJECTS = 2 #图像库中不同人数,一共6人
      NUM_SUBJECTS_IMGS = 20 #每人有20张样本图片
      
      # 拍摄当前人脸。
      img = sensor.snapshot()
      #img = image.Image("singtown/%s/1.pgm"%(SUB))
      d0 = img.find_lbp((0, 0, img.width(), img.height()))
      #d0为当前人脸的lbp特征
      img = None
      pmin = 999999
      num=0
      
      def min(pmin, a, s):
          global num
          if a<pmin:
              pmin=a
              num=s
          return pmin
      
      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()))
              #d1为第s文件夹中的第i张图片的lbp特征
              dist += image.match_descriptor(d0, d1)#计算d0 d1即样本图像与被检测人脸的特征差异度。
          print("Average dist for subject %d: %d"%(s, dist/NUM_SUBJECTS_IMGS))
          pmin = min(pmin, dist/NUM_SUBJECTS_IMGS, s)#特征差异度越小,被检测人脸与此样本更相似更匹配。
          print(pmin)
      
      print(num) # num为当前最匹配的人的编号。
      uart.write(str(num)+'\r\n')
      
      
      主要想实现stm32发送信息给openmv,用来触发openmv中断下的接收函数,在接受到信息后,能运行人脸识别程序,再将openmv人脸识别结果发给32
      
      


    • 用不到中断啊,直接死循环里检查串口是否有数据,然后处理,然后发送就完事了。