导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. pt6u
    3. 楼层
    P
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    pt6u 发布的帖子

    • RE: 人脸分辨采集失败问题

      你好,内存卡格式化之后,重新建的相关文件夹,重试之后设置的拍摄20张,但还是第一次只拍10张,修改序号后,第二次拍第一张后就失败断开

      发布在 OpenMV Cam
      P
      pt6u
    • 人脸分辨采集失败问题

      例程代码设置的20张采集样本,结果第一次运行只采集了10张就停了,然后修改num为1后,再次运行代码,只采集一次,机器就断开连接了,内存卡是16G的,对内存卡的识别也是正常的0_1649296328013_MEZP9N$ZYDFR}3WM_0FE1BN.png 0_1649296345356_4OIDQHVB}S7F85$2%VQ07{2.png 0_1649296356036_EKQ6(~3{W_D93C3OP52(QUE.png

      # Snapshot Example
      #
      # Note: You will need an SD card to run this example.
      #
      # You can use your OpenMV Cam to save image files.
      
      import sensor, image, pyb
      
      RED_LED_PIN = 1
      BLUE_LED_PIN = 3
      
      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)
      
      num = 2 #设置被拍摄者序号,第一个人的图片保存到s1文件夹,第二个人的图片保存到s2文件夹,以此类推。每次更换拍摄者时,修改num值。
      
      n = 20 #设置每个人拍摄图片数量。
      
      #连续拍摄n张照片,每间隔3s拍摄一次。
      while(n):
          #红灯亮
          pyb.LED(RED_LED_PIN).on()
          sensor.skip_frames(time = 3000) # Give the user time to get ready.等待3s,准备一下表情。
      
          #红灯灭,蓝灯亮
          pyb.LED(RED_LED_PIN).off()
          pyb.LED(BLUE_LED_PIN).on()
      
          #保存截取到的图片到SD卡
          print(n)
          sensor.snapshot().save("singtown/s%s/%s.pgm" % (num, n) ) # or "example.bmp" (or others)
      
          n -= 1
      
          pyb.LED(BLUE_LED_PIN).off()
          print("Done! Reset the camera to see the saved image.")
      
      
      发布在 OpenMV Cam
      P
      pt6u
    • 关于颜色识别能使用hsv进行识别吗?

      请问大佬们openmv支持用hsv进行颜色识别吗,替换掉rgb识别

      发布在 OpenMV Cam
      P
      pt6u
    • RE: 关于颜色识别和形状同时识别出现的问题

      最开始就是全部打印出来的,但其他的参数没有用,所以我打印了statistics.l_mode() statistics.a_mode() statistics.b_mode() 这三个参数,这三个参数就是if语句的判断条件,打印出来的结果是满足if语句的,但问题就是没运行if语句下的代码

      发布在 OpenMV Cam
      P
      pt6u
    • RE: 关于颜色识别和形状同时识别出现的问题

      你好,没有说同时执行if,else语句,我意思是在代码满足if语句条件的时候,但他没运行if语句下的代码块,而是运行了else下的代码块,这几天我测试发现把这一句:
      if 0<statistics.l_mode()<36 and -20<statistics.a_mode()<10 and -10<statistics.b_mode()<-128:
      中的and全部改成or的时候才能满足判断语句,然后运行if下的语句,但是我看颜色与形状识别视频教程时,教程用的就是and语句

      发布在 OpenMV Cam
      P
      pt6u
    • 关于颜色识别和形状同时识别出现的问题

      请问我在做颜色和形状同时识别时,为什么在满足if语句的条件时,程序还在执行else的语句(判断条件的色块范围我是根据打印的众数写的范围,因为之前试了多颜色例程中的蓝色的色块范围不行)1_1620916134460_JT$PPZ{JHN{IG4%RCCPNTY3.png 0_1620916134460_GN{K}5LYB(XVJ72B5.png

      import sensor, image, time
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False) # must be turned off for color tracking
      sensor.set_auto_whitebal(False) # must be turned off for color tracking
      clock = time.clock()
      
      while(True):
          clock.tick()
          img = sensor.snapshot().lens_corr(1.8)
          for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,
                  r_min = 2, r_max = 100, r_step = 2):
              area = (c.x()-c.r(), c.y()-c.r(), 2*c.r(), 2*c.r())
              #area为识别到的圆的区域,即圆的外接矩形框
              statistics = img.get_statistics(roi=area)#像素颜色统计
              print(statistics.l_mode(),statistics.a_mode(),statistics.b_mode())
              #(0,100,0,120,0,120)是红色的阈值,所以当区域内的众数(也就是最多的颜色),范围在这个阈值内,就说明是红色的圆。
              #l_mode(),a_mode(),b_mode()是L通道,A通道,B通道的众数。
              if 0<statistics.l_mode()<36 and -20<statistics.a_mode()<10 and -10<statistics.b_mode()<-128:#if the circle is red
                  img.draw_circle(c.x(), c.y(), c.r(), color = (0, 0, 255))#识别到的红色圆形用红色的圆框出来
                  print(1)
              else:
                  img.draw_rectangle(area, color = (255, 255, 255))
                  print(2)
                  #将非红色的圆用白色的矩形框出来
      
      
      发布在 OpenMV Cam
      P
      pt6u
    • RE: 关于利用识别线段来识别三角形的问题

      好的,谢谢大佬😁 😁

      发布在 OpenMV Cam
      P
      pt6u
    • 关于利用识别线段来识别三角形的问题

      在代码中 sum+=l.theta()一直报错,改为将l.theta()改为其他类型,还是报错,请问怎样解决啊0_1620213887604_QQ图片20210505192437.png

      
      import sensor, image, time, math
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565) # 灰度更快
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      
      # 所有线段都有 `x1()`, `y1()`, `x2()`, and `y2()` 方法来获得他们的终点
      # 一个 `line()` 方法来获得所有上述的四个元组值,可用于 `draw_line()`.
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens...
      
          for l in img.find_line_segments(merge_distance = 10, max_theta_diff = 10):
              img.draw_line(l.line(), color = (255, 0, 0))
              sum+=l.theta()
          sum-=180
      
          if sum<110 and sum>1:
              print('三角形')
              num_segment=1
      发布在 OpenMV Cam
      P
      pt6u
    • 关于利用瞳孔识别判断眨眼次数的问题

      最初的想法就是通过瞳孔识别进行眨眼次数的判断,当闭眼时,则无法识别到瞳孔,则num加一。我是通过调取瞳孔识别函数的返回的一个固定值,作为标志项,进行判断的,但是发现几个问题,一个是打印出的num速度过快,加了定时器还是一样的结果。还有就是将第一个判断语句的等号变成不等号,那代码将不往下执行打印,但显然当识别不到瞳孔的时候,标志不相等应该是恒成立的。代码如下,求大佬解惑

      
      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=1)
              
              if flag==2:
                  tim.callback(ad)
                  print(num)
              else:
                  print(1)
      发布在 OpenMV Cam
      P
      pt6u
    • 请问怎样让整个程序运行结束再回到程序开头继续运行

      import sensor, time, image, pyb
      from pyb import UART

      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

      uart = UART(3, 115200)

      while(True):
      if uart.any():
      a=uart.readline().decode().strip()
      print(a)
      break

      #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(2)

      print(num) # num为当前最匹配的人的编号。
      uart.write(str(num)+'\r\n')

      我想让人脸识别结束后,将结果发送出去后,再回到程序开始的串口接收部分继续运行程序,请问该怎样弄?
      发布在 OpenMV Cam
      P
      pt6u
    • RE: 请问openmv接收到数据后,怎样继续运行后面的代码?谢谢了

      @kidswong999 那请问我是应该用break跳出循环还是其他方法,麻烦你啦

      发布在 OpenMV Cam
      P
      pt6u
    • 请问openmv接收到数据后,怎样继续运行后面的代码?谢谢了
      import sensor, time, image, pyb
      from pyb import UART
      from pyb import Pin, ExtInt
      
      uart = UART(3, 115200)
      
      while(True):
          if uart.any():
              a=uart.readline().decode().strip()
              print(a)
      
      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')
      

      我在串口助手上发0给openmv,串行终端读到了0,然后就停在了那一步,我想问一下怎样修改代码,可以让openmv接收到数据后,能继续运行后面的人脸识别程序

      发布在 OpenMV Cam
      P
      pt6u
    • 请问我的这个中断代码用的对不对,有问题的话,麻烦给小白讲一下
      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
      
      
      发布在 OpenMV Cam
      P
      pt6u
    • RE: 求助关于人脸分辨的相关问题

      @kidswong999 是按照视频的步骤进行的

      发布在 OpenMV Cam
      P
      pt6u
    • face tracking: OSError: Could not find the file

      用给定的人脸分辨的例子,显示说断言失败 0_1609898160057_屏幕截图(205).png

      发布在 OpenMV Cam
      P
      pt6u
    • 求助关于人脸分辨的相关问题

      你好请问这个人脸识别代码为什么不能输出num的值,串行口显示没有输出值,万分感谢
      0_1609842711289_屏幕截图(206).png

      import sensor, time, image, pyb
      
      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
      num = 0
      def min(pmin, a, s):
          global num
          print(00000000)
          if a < pmin:
              pmin = a
              num = s
              
          return pmin
          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
          
          NUM_SUBJECTS = 2
          NUM_SUBJECTS_IMGS = 20
          img = sensor.snapshot()
          d0 = img.find_lbp((0, 0, img.width(), img.height()))
          img = None
          pmin = 999999
          num = 0
          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)
              print("Average dist for subject %d: %d" % (s, dist / NUM_SUBJECTS_IMGS))
              pmin = min(pmin, dist / NUM_SUBJECTS_IMGS, s)
              print(pmin)
              if dist / NUM_SUBJECTS_IMGS == pmin:
                  num = s
          print(num)
      
      
      发布在 OpenMV Cam
      P
      pt6u
    • 关于onenet和openmv之间的相关问题?

      请问我现在想将openmv的图片截取一张传给onenet平台,openmv这边可以实现吗?如果可以的话,能否通过stm32来发送这个截取图片的命令

      发布在 OpenMV Cam
      P
      pt6u
    • 关于openmv串口发送问题

      想通过串口给32发送mv识别二维码

      0_1608688097jpg 的信息,但只想发送四个xywh坐标,不想发送其他的信息,但是改的代码却把qrcode函数下的九类信息全发到调试助手上了,请问怎样修改才能让只发送qrcodes函数下的一部分信息给别的单片机?拜托了!

      import sensor, image, time
      from pyb import UART
      import json
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False) # must turn this off to prevent image washout...
      clock = time.clock()
      uart = UART(3, 115200)
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
          for code in img.find_qrcodes():
              img.draw_rectangle(code.rect(), color = (255, 0, 0))
              output_str = json.dumps(code)
              print('you send:',output_str)
              uart.write(output_str+'\n')
          else:
              print('not found!')
      
      

      0_1608687756488_pg

      0_1608687760pg

      0_160868776562pg

      发布在 OpenMV Cam
      P
      pt6u