• 星瞳AI VISION软件内测!可以离线标注,训练,并生成OpenMV的模型。可以替代edge impulse https://forum.singtown.com/topic/8206
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • openmv脱机运行控制舵机有时会重启?



    • import sensor, image, time,lcd,math,pyb
      import json
      from pyb import UART
      from pyb import Servo
      from pyb import Pin
      from pyb import LED
      led = LED(4)
      a=0
      q=0
      c=0
      H=0
      cir_r=0
      rec_w=0
      rec_h=0
      led.toggle()
      blue_threshold   = (18, 38, 9, 58, -90, -33)
      red_threshold   =  (29, 53, 34, 74, 15, 55)#(13, 38, 30, 58, 16, 45)
      yellow_threshold   = [(54, 67, -13, 4, 49, 71),(72, 95, -17, 9, 54, 82)]
      fangkuai_thresholds =[(13, 38, 75, 61, 17, 52),(19, 57, 19, 87, 16, 58)]
      thresholds = [(13, 38, 6, 61, 17, 52)]
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(20)
      sensor.set_auto_whitebal(False)
      s2=Servo(2)
      s1=Servo(1)
      uart = UART(3, 115200)
      clock = time.clock()
      #lcd.init()
      s1.angle(-55)
      while(True):
          clock.tick()
          a=uart.readchar()
          led = LED(1)
          led = LED(4)
          led.off()
          
          if a==49 and c!=2:
              led = LED(2)
              led.off()
              s1=Servo(2)
              s2=Servo(1)
              s2.angle(-85)
              s1.angle(30)
              pyb.delay(200)
          if a==52 and c!=2:
              s2=Servo(2)
              s1=Servo(1)
              img = sensor.snapshot()
              sensor.set_framesize(sensor.QVGA)
              led = LED(1)
              led.off()
              sensor.set_windowing((156,1,117,240))
              led = LED(4)
              led.off()
              blobs0 = img.find_blobs([blue_threshold],pixels_threshold=100)
              blobs1 = img.find_blobs([red_threshold],pixels_threshold=40)
              if blobs1 :
                  led.off()
                  s1.angle(-15)
                  s2.angle(60)
                  pyb.delay(200)
                  s1.angle(70)
                  pyb.delay(200)
                  s1.angle(-15)
                  pyb.delay(200)
                  c=c+1
          if a==50 and c!=2:
              sensor.set_framesize(sensor.QVGA)
              sensor.set_windowing((165,20,148,100))
              s2=Servo(2)
              s1=Servo(1)
              led = LED(4)
              led.on()
              img = sensor.snapshot()
              blobs0 = img.find_blobs([blue_threshold],pixels_threshold=100)
              blobs1 = img.find_blobs([red_threshold],pixels_threshold=40)
              blobs2 = img.find_blobs(yellow_threshold,pixels_threshold=40)
              if blobs0 :
                  s1.angle(-15)
              elif blobs2 :
                  s1.angle(-15)
                  s2.angle(-5)
                  pyb.delay(200)
                  s1.angle(45)
                  pyb.delay(200)
                  s1.angle(-15)
                  pyb.delay(200)
              elif blobs1:
                  s1.angle(-15)
                  s2.angle(60)
                  pyb.delay(200)
                  s1.angle(45)
                  pyb.delay(200)
                  s1.angle(-15)
                  pyb.delay(200)
          if  c==2:
              s1.angle(-75)
              led = LED(2)
              led.on()
              sensor.set_framesize(sensor.QVGA)
              img = sensor.snapshot()
              sensor.set_windowing((0,0,307,233))
              #img.lens_corr(1.8)
              for code in img.find_qrcodes():
                  q=code.payload()
              led = LED(4)
              led.off()
              blobs3 = img.find_blobs(fangkuai_thresholds,pixels_threshold=20)
              if q=='R':
                  uart.write('1')
                  s2.angle(30)
                  print(1)
              if blobs3:
                  for blob in img.find_blobs(fangkuai_thresholds,pixels_threshold=50):
                      if blob.density()>0.68:
                      uart.write('1')
                      s2.angle(30)
                      led = LED(4)
                      led.on()
                      print(1)
              if   0.61>blob.density()>0.20:
                  img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
                  img.draw_circle((blob.cx(), blob.cy(),int((blob.w()+blob.h())/4)))
                  uart.write('2')
                  s2.angle(30)
                  led = LED(4)
                  led.on()
                  print(2)
      


    • 首先代码118行缩进有错误。

      先找到复现问题的情况,你的代码逻辑太复杂。比如每个状态单独测试。