导航

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

    2giq 发布的帖子

    • 如何实现当检测到人脸时,进行口罩识别,当检测到二维码时,进行二维码颜色识别

      人脸要用灰度图,二维码颜色检测要用彩色图,这要怎么处理

      发布在 OpenMV Cam
      2
      2giq
    • RE: 为什么右边的摄像区域还是灰度图

      @kidswong999 可是我还有人像识别,人像识别不是说要用灰度图吗

      发布在 OpenMV Cam
      2
      2giq
    • RE: 为什么比较复杂的二维码无法识别成功,不是特别方正的二维码也无法识别成功,而且有时候扫描二维码是一片空白,这个该怎么解决

      @kidswong999 删除后人脸识别就有一点问题,有时候能识别到,有时候不能,但能识别到的次数很少,一片白的情况解决了,二维码识别很慢,这些问题怎么解决

      发布在 OpenMV Cam
      2
      2giq
    • RE: 为什么比较复杂的二维码无法识别成功,不是特别方正的二维码也无法识别成功,而且有时候扫描二维码是一片空白,这个该怎么解决

      @2giq 在 为什么比较复杂的二维码无法识别成功,不是特别方正的二维码也无法识别成功,而且有时候扫描二维码是一片空白,这个该怎么解决 中说:

      @kidswong999 删除后人脸识别就有一点问题,有时候能识别到,有时候不能,但能识别到的次数很少,一片白的情况解决了,二维码识别很慢,这些问题怎么解决

      @kidswong999

      发布在 OpenMV Cam
      2
      2giq
    • RE: 为什么右边的摄像区域还是灰度图

      @kidswong999 可是我还有人像识别,人像识别不是说要用灰度图吗

      发布在 OpenMV Cam
      2
      2giq
    • RE: 为什么右边的摄像区域还是灰度图

      @kidswong999 那怎么才能先设置为灰度图,再进入循环,然后转为彩色图,进行多颜色识别,识别完成后再转为灰度图,进行这样的循环

      发布在 OpenMV Cam
      2
      2giq
    • 为什么右边的摄像区域还是灰度图
      # 多颜色组合识别
      #
      # 这个例子展示了使用OpenMV Cam进行多色代码跟踪。
      #
      # 颜色代码是由两种或更多颜色组成的色块。下面的例子只会跟踪其中有两种或多种颜色的彩色物体。
      
      import sensor, image, time
      
      # 颜色跟踪阈值(L Min, L Max, A Min, A Max, B Min, B Max)
      # 下面的阈值一般跟踪红色/绿色的东西。你可以调整它们…
      thresholds = [(33, 59, 45, 105, -7, 127), # generic_red_thresholds -> index is 0 so code == (1 << 0)
                    (42, 64, 5, 36, 3, 36), # generic_yellow_thresholds -> index is 1 so code == (1 << 1)
                    (14, 88, -128, -8, -124, 78)] # generic_green_thresholds -> index is 2 so code == (1 << 2)
      # 当“find_blobs”的“merge = True”时,code代码被组合在一起。
      
      sensor.reset()
      #初始化摄像头,reset()是sensor模块里面的函数
      
      sensor.set_pixformat(sensor.GRAYSCALE)
      #sensor.set_pixformat(sensor.RGB565)
      #设置图像色彩格式,有RGB565色彩图和GRAYSCALE灰度图两种
      
      sensor.set_framesize(sensor.QVGA)
      #设置图像像素大小
      
      sensor.skip_frames(time = 2000)
      sensor.set_auto_gain(False) # 颜色跟踪必须关闭自动增益
      sensor.set_auto_whitebal(True) # 颜色跟踪必须关闭白平衡
      clock = time.clock()
      
      # 只有比“pixel_threshold”多的像素和多于“area_threshold”的区域才被
      # 下面的“find_blobs”返回。 如果更改相机分辨率,
      # 请更改“pixels_threshold”和“area_threshold”。 “merge = True”合并图像中所有重叠的色块。
      
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          img=img.to_rgb565()
          for blob in img.find_blobs([thresholds[0]], pixels_threshold=100, area_threshold=100):
              img.draw_rectangle(blob.rect())
              img.draw_cross(blob.cx(), blob.cy())
              img.draw_string(blob.x() + 2, blob.y() + 2, "reg")
              print("reg")
          for blob in img.find_blobs([thresholds[1]], pixels_threshold=100, area_threshold=100):
              img.draw_rectangle(blob.rect())
              img.draw_cross(blob.cx(), blob.cy())
              img.draw_string(blob.x() + 2, blob.y() + 2, "yellow")
              print("yellow")
          for blob in img.find_blobs([thresholds[2]], pixels_threshold=100, area_threshold=100):
              img.draw_rectangle(blob.rect())
              img.draw_cross(blob.cx(), blob.cy())
              img.draw_string(blob.x() + 2, blob.y() + 2, "green")
              print("blue")
      

      0_1697110978147_7cd0eb4e-2779-4344-b05a-88d13b9c02dd-image.png
      img=img.to_rgb565()这个不是把灰度图转为彩色图了吗,为什么不能识别颜色区域

      发布在 OpenMV Cam
      2
      2giq
    • RE: 为什么比较复杂的二维码无法识别成功,不是特别方正的二维码也无法识别成功,而且有时候扫描二维码是一片空白,这个该怎么解决

      @kidswong999 删除后人脸识别就有一点问题,有时候能识别到,有时候不能,但能识别到的次数很少,一片白的情况解决了,二维码识别很慢,这些问题怎么解决

      发布在 OpenMV Cam
      2
      2giq
    • RE: 为什么比较复杂的二维码无法识别成功,不是特别方正的二维码也无法识别成功,而且有时候扫描二维码是一片空白,这个该怎么解决

      @kidswong999 用hello程序可以看清,也没有一片白的情况

      发布在 OpenMV Cam
      2
      2giq
    • RE: 为什么比较复杂的二维码无法识别成功,不是特别方正的二维码也无法识别成功,而且有时候扫描二维码是一片空白,这个该怎么解决

      并且转换角度之后不能及时调整亮度,先照人的话再照平板就会很亮,这该怎么解决

      发布在 OpenMV Cam
      2
      2giq
    • 为什么比较复杂的二维码无法识别成功,不是特别方正的二维码也无法识别成功,而且有时候扫描二维码是一片空白,这个该怎么解决
      import sensor, image, time,image, os, tf, uos, gc
      from pyb import UART
      uart = UART(3, 9600)
      sensor.reset()
      sensor.set_contrast(3)
      sensor.set_gainceiling(16)
      sensor.set_framesize(sensor.VGA)
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_auto_whitebal(True)
      sensor.set_auto_gain(False)  # 必须关闭此功能,以防止图像冲洗…
      sensor.set_windowing((240, 240))       # Set 240x240 window.
      sensor.skip_frames(time=2000)          # Let the camera adjust.
      net = None
      labels = None
      try:
          # load the model, alloc the model file on the heap if we have at least 64K free after loading
          net = tf.load("trained.tflite", load_to_fb=uos.stat('trained.tflite')[6] > (gc.mem_free() - (64*1024)))
      except Exception as e:
          print(e)
          raise Exception('Failed to load "trained.tflite", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      
      try:
          labels = [line.rstrip('\n') for line in open("labels.txt")]
      except Exception as e:
          raise Exception('Failed to load "labels.txt", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      # 加载Haar算子
      # 默认情况下,这将使用所有阶段,更低的satges更快,但不太准确。
      face_cascade = image.HaarCascade("frontalface", stages=25)
      #image.HaarCascade(path, stages=Auto)加载一个haar模型。haar模型是二进制文件,
      #这个模型如果是自定义的,则引号内为模型文件的路径;也可以使用内置的haar模型,
      #比如“frontalface” 人脸模型或者“eye”人眼模型。
      #stages值未传入时使用默认的stages。stages值设置的小一些可以加速匹配,但会降低准确率。
      # FPS clock
      clock = time.clock()
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          img.lens_corr(1.8) # 1.8的强度参数对于2.8mm镜头来说是不错的。
          objects = img.find_features(face_cascade, threshold=0.75, scale=1.35)
          QR_Code=img.find_qrcodes()
          if objects:
              for r in objects:
                  img.draw_rectangle(r)
              for obj in net.classify(img, min_scale=1.0, scale_mul=0.8, x_overlap=0.5, y_overlap=0.5):
                  img.draw_rectangle(obj.rect())
                  predictions_list = list(zip(labels, obj.output()))
                  radio=predictions_list[1][1]*100
                  print("%s = %.2f%%" % (predictions_list[1][0],radio ))
                  radio=str(radio)
                  uart.write('@'+radio+'\r\n')
          elif QR_Code:
              for code in QR_Code:
                  img.draw_rectangle(code.rect(), color = (255, 0, 0))
                  print(code.payload())
                  uart.write('@'+code.payload()+'\r\n')
          #else:
              #print("-----------error------------")
      

      0_1696943727512_fa223c5b-8e77-4778-9eea-4c17af116e4f-image.png
      0_1696943742799_6301b8ff-463a-4fd1-98de-5997ba3664ca-image.png

      发布在 OpenMV Cam
      2
      2giq
    • 为什么img=img.to_grayscale()可以使用,但使用img=img.to_rgb()会出现错误?

      错误:AttributeError: 'Image' object has no attribute 'to_rgb'
      img=img.to_grayscale()
      img=img.to_rgb()

      发布在 OpenMV Cam
      2
      2giq
    • RE: 为什么比较复杂的二维码无法识别成功,不是特别方正的二维码也无法识别成功,而且有时候扫描二维码是一片空白,这个该怎么解决

      并且转换角度之后不能及时调整亮度,先照人的话再照平板就会很亮,这该怎么解决

      发布在 OpenMV Cam
      2
      2giq
    • 为什么比较复杂的二维码无法识别成功,不是特别方正的二维码也无法识别成功,而且有时候扫描二维码是一片空白,这个该怎么解决

      先判断是二维码还是人物,是人的话则判断是否带口罩,是二维码的话输出二维码的内容

      import sensor, image, time,image, os, tf, uos, gc
      from pyb import UART
      uart = UART(3, 9600)
      sensor.reset()
      sensor.set_contrast(3)
      sensor.set_gainceiling(16)
      sensor.set_framesize(sensor.VGA)
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_auto_whitebal(True)
      sensor.set_auto_gain(False)  # 必须关闭此功能,以防止图像冲洗…
      sensor.set_windowing((240, 240))       # Set 240x240 window.
      sensor.skip_frames(time=2000)          # Let the camera adjust.
      net = None
      labels = None
      try:
          # load the model, alloc the model file on the heap if we have at least 64K free after loading
          net = tf.load("trained.tflite", load_to_fb=uos.stat('trained.tflite')[6] > (gc.mem_free() - (64*1024)))
      except Exception as e:
          print(e)
          raise Exception('Failed to load "trained.tflite", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      
      try:
          labels = [line.rstrip('\n') for line in open("labels.txt")]
      except Exception as e:
          raise Exception('Failed to load "labels.txt", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      # 加载Haar算子
      # 默认情况下,这将使用所有阶段,更低的satges更快,但不太准确。
      face_cascade = image.HaarCascade("frontalface", stages=25)
      #image.HaarCascade(path, stages=Auto)加载一个haar模型。haar模型是二进制文件,
      #这个模型如果是自定义的,则引号内为模型文件的路径;也可以使用内置的haar模型,
      #比如“frontalface” 人脸模型或者“eye”人眼模型。
      #stages值未传入时使用默认的stages。stages值设置的小一些可以加速匹配,但会降低准确率。
      # FPS clock
      clock = time.clock()
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          img.lens_corr(1.8) # 1.8的强度参数对于2.8mm镜头来说是不错的。
          objects = img.find_features(face_cascade, threshold=0.75, scale=1.35)
          QR_Code=img.find_qrcodes()
          if objects:
              for r in objects:
                  img.draw_rectangle(r)
              for obj in net.classify(img, min_scale=1.0, scale_mul=0.8, x_overlap=0.5, y_overlap=0.5):
                  img.draw_rectangle(obj.rect())
                  predictions_list = list(zip(labels, obj.output()))
                  radio=predictions_list[1][1]*100
                  print("%s = %.2f%%" % (predictions_list[1][0],radio ))
                  radio=str(radio)
                  uart.write('@'+radio+'\r\n')
          elif QR_Code:
              for code in QR_Code:
                  img.draw_rectangle(code.rect(), color = (255, 0, 0))
                  print(code.payload())
                  uart.write('@'+code.payload()+'\r\n')
          #else:
              #print("-----------error------------")
      
      

      0_1696337647526_f45b89a2-e4fd-4883-9d80-264de3a8130f-image.png

      0_1696337939739_6fc9a5ea-848b-45ac-9831-a8cdb0fdd550-image.png

      发布在 OpenMV Cam
      2
      2giq