• OpenMV VSCode 扩展发布了,在插件市场直接搜索OpenMV就可以安装
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 想问一下,进行颜色识别后再将RGB565转为灰度图,但是之后的模板匹配没现象?



    • import sensor, image, time
      
      from image import SEARCH_EX, SEARCH_DS
      
      thresholds = [(16, 50, 24, 99, -18, 67),
                    (40, 65, -32, 32, 27, 82),
                    (10, 27, -52, -16, -19, 99)]
      
      sensor.reset()
      
      sensor.set_pixformat(sensor.RGB565)
      #sensor.set_pixformat(sensor.GRAYSCALE)
      
      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()
      
      #templates = ["/left.pgm", "/right.pgm", "/band.pgm"] #保存多个模板
      template1 = image.Image("left.pgm")
      template2 = image.Image("right.pgm")
      template3 = image.Image("band.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())
      
              if blob.code() == 1:
                 print("前方为红灯")
      
              if blob.code() == 2:
                 print("前方为黄灯")
      
              if blob.code() == 4:
                 print("前方为绿灯")
              if blob.code()!=1 and blob.code()!=2 and blob.code()!=4:
                  img = img.to_grayscale()
                  r = img.find_template(template1, 0.10, step=4, search=SEARCH_EX) #, roi=(81, 49, 165, 166))
                  if r:
                      img.draw_rectangle(r)
                      print("前方左转")
                  r = img.find_template(template2, 0.10, step=4, search=SEARCH_EX) #, roi=(81, 49, 165, 166))
                  if r:
                      img.draw_rectangle(r)
                      print("前方右转")
                  r = img.find_template(template3, 0.10, step=4, search=SEARCH_EX) #, roi=(81, 49, 165, 166))
                  if r:
                      img.draw_rectangle(r)
                      print("禁止通行")
      
      
      


    • https://singtown.com/learn/49598/

      单独模板匹配的代码,是正常的吗?