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



    • # 多颜色多模板匹配示例
      #
      # 这个例子显示了使用OpenMV的多色跟踪。
      
      import sensor, image, time
      from image import SEARCH_EX, SEARCH_DS
      
      # 颜色跟踪阈值(L Min, L Max, A Min, A Max, B Min, B Max)
      # 下面的阈值跟踪一般红色/绿色的东西。你不妨调整他们...
      thresholds = (30, 73, -38, -11, -15, 13) # generic_blue_thresholds
      # 不要超过16个颜色阈值
      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()
      
      # 只有比“pixel_threshold”多的像素和多于“area_threshold”的区域才被
      # 下面的“find_blobs”返回。 如果更改相机分辨率,
      # 请更改“pixels_threshold”和“area_threshold”。 “merge = True”合并图像中所有重叠的色块。
      
      templates = ["/pen1.pgm", "/pen2.pgm", "/pen3.pgm", "/pen4.pgm"] #保存多个模板
      
      while(True):
          clock.tick()
          img = sensor.snapshot()
          for blob in img.find_blobs(thresholds, pixels_threshold=200, area_threshold=200):
              #img.draw_rectangle(blob.rect())
              #img.draw_cross(blob.cx(), blob.cy())
              #print(blob.code())
      
              img = img.to_grayscale()
              for t in templates:
                  template = image.Image(t)
                  #对每个模板遍历进行模板匹配
                  r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
              #find_template(template, threshold, [roi, step, search]),threshold中
              #的0.7是相似度阈值,roi是进行匹配的区域(左上顶点为(10,0),长80宽60的矩形),
              #注意roi的大小要比模板图片大,比frambuffer小。
              #把匹配到的图像标记出来
                  if r:
                      img.draw_rectangle(r, color=0)
                      print(blob.code(), t) #打印模板名字
                  
      
      
          #print(clock.fps())
      
      


    • thresholds = (30, 73, -38, -11, -15, 13)

      改为

      thresholds = [(30, 73, -38, -11, -15, 13)]