• 免费好用的星瞳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, image, time,lcd,math,pyb
      import json
      import gc
      from image import SEARCH_EX, SEARCH_DS
      import lcd
      from pyb import UART
      from pyb import Servo
      from pyb import Pin
      from pyb import LED
      from fenghuang import QQQ
      from fenghong import ppp
      led = LED(4)
      a=0
      c=0
      q=0
      led.toggle()
      blue_threshold   = (18, 38, 9, 58, -90, -33)
      red_threshold   =  [(29, 53, 34, 74, 15, 55),(75, 50, 10, 68, 12, 67)]
      yellow_threshold   = [(54, 67, -13, 4, 49, 71),(72, 95, -17, 9, 54, 82),(51, 77, -7, 24, 11, 55)]
      fangkuai_thresholds =[(13, 38, 75, 61, 17, 52),(19, 57, 19, 87, 16, 58)]
      thresholds = [(59, 63, 56, 64, 24, 41),(11, 33, -8, 58, 16, 44),
                    (35, 53, 49, 74, 26, 63),(23, 50, 44, 79, 14, 63),
                    (22, 53, 31, 74, 16, 51),(40, 56, 41, 84, 23, 65),
                    (49, 65, 17, 75, 21, 64),(55, 76, 27, 55, 10, 64),
                    (56, 71, 69, 52, 18, 49),(25, 70, 86, 19, -5, 65),
                    (23, 84, 86, 19, -5, 65)]
      erweima_threshold =[(90, 100, -28, 24, 35, -20) ]
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(20)
      sensor.set_auto_whitebal(False)
      sensor.set_auto_gain(False)
      uart = UART(3, 115200)
      clock = time.clock()
      sensor.set_auto_exposure(True, exposure_us=5000) 
      templates3 = ["/gaochangfangti1.pgm","/gaozhengfangti1.pgm",
                    "/dichangfangti2.pgm","/dizhengfangti2.pgm",
                    "/zhongzhengfangti1.pgm","/zhongchangfangti1.pgm"]
      templates4 = ["/gaoyuanhuan1.pgm","/diyuanhuan2.pgm","/zhongyuanhuan1.pgm"]
      
      s1=Servo(1)
      s2=Servo(2)
      s3=Servo(3)
      s1.angle(15)
      s2.angle(28)
      s3.angle(-15)
      while(True):
        clock.tick()
        lcd.display(sensor.snapshot())
        a=uart.readchar()
        #print(a)
        c=2
        led = LED(1)
        led = LED(4)
        led.off()
        if a==52 and c!=2:
           img = sensor.snapshot()
           sensor.set_framesize(sensor.QVGA)
           led = LED(1)
           led.off()
           s2.angle(60)
           sensor.set_windowing((70,1,80,170))
           led = LED(4)
           led.off()
           blobs0 = img.find_blobs([blue_threshold],pixels_threshold=180)
           blobs3 = img.find_blobs(red_threshold,pixels_threshold=80)
           if blobs0 :
              s3.angle(-75)
           if blobs3 :
              led.off()
              s3.angle(-75)
              pyb.delay(200)
              s3.angle(40)
              pyb.delay(200)
              s3.angle(-75)
              pyb.delay(200)
              c=c+1
        if a==50 and c!=2:
           s1=Servo(1)
           s2=Servo(2)
           s3=Servo(3)
           sensor.set_framesize(sensor.QVGA)
           sensor.set_windowing((165,20,148,100))
           led = LED(4)
           led.on()
           img = sensor.snapshot()
           blobs0 = img.find_blobs([blue_threshold],pixels_threshold=100)
           blobs3 = img.find_blobs(red_threshold,pixels_threshold=60)
           blobs2 = img.find_blobs(yellow_threshold,pixels_threshold=40)
           if blobs0 :
              s3.angle(-45)
           elif blobs2 :
              s3.angle(-45)
              s2.angle(-5)
              pyb.delay(200)
              s3.angle(40)
              pyb.delay(200)
              s3.angle(-45)
              pyb.delay(200)
           elif blobs3:
              s3.angle(-45)
              s2.angle(60)
              pyb.delay(200)
              s3.angle(40)
              pyb.delay(200)
              s3.angle(-45)
              pyb.delay(200)
        if  c==2 :
           sensor.set_framesize(sensor.QQVGA)
           img = sensor.snapshot()
           uart.write('0')
           #sensor.set_windowing((160,120))
           for code in img.find_qrcodes():
              img.draw_rectangle(code.rect(), color = (255, 0, 0))
              q=code.payload()
              if code.payload() =='R' :
                 uart.write('1')
                 print(q)
                 pyb.delay(1800)
                 ppp()
                 pyb.delay(4500)
                 QQQ()
              else :
                 uart.write('0')
           for blob in img.find_blobs(thresholds, pixels_threshold=250, area_threshold=200):
              img = img.to_grayscale()
              for t in templates3:#高方块
                  template = image.Image(t)
                  r = img.find_template(template, 0.85, step=4, search=SEARCH_EX)
                  if r and blob.cxf()<90 :
                      uart.write('1')
                      img.draw_rectangle(r, color=0)
                      print(blob.code(), t,1)
                      pyb.delay(1800)
                      ppp()
                      pyb.delay(4500)
                      QQQ()
                  else :
                       uart.write('0')
              for t in templates4:#高原换
                  template = image.Image(t)
                  r = img.find_template(template, 0.60, step=4, search=SEARCH_EX)
                  if r  and blob.cxf()<70  :
                      uart.write('2')
                      img.draw_rectangle(r, color=0)
                      print(blob.code(), t,2)
                      pyb.delay(1800)
                      ppp()
                      pyb.delay(4500)
                      QQQ()
                  else :
                      uart.write('0')
      


    • 卡是因为有pyb.delay



    • 没识别到图片没有进入到那个if里面,delay不起作用的,
      现在只要看到红色就一卡一卡的



    • @tvfa 把代码精简,只留要测试的部分