星瞳实验室APP,快速收到回复
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 我电脑运行程序可以,但是脱机运行后就会卡住怎么回事?



    • Hello World Example

      Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

      import sensor, image, time,pyb
      from image import SEARCH_EX, SEARCH_DS
      from pyb import UART
      import ujson
      import lcd

      uart = UART(3, 19200)

      sensor.reset()

      Set sensor settings

      sensor.set_contrast(1)
      sensor.set_gainceiling(16)

      Max resolution for template matching with SEARCH_EX is QQVGA

      sensor.set_framesize(sensor.QQVGA)

      You can set windowing to reduce the search image.

      #sensor.set_windowing(((640-80)//2, (480-60)//2, 80, 60))
      sensor.set_pixformat(sensor.GRAYSCALE)
      lcd.init()
      led=pyb.LED(3)

      templates1= ["/16.pgm","/161.pgm","/162.pgm"] #正方形
      templates2= ["/12.pgm","/121.pgm","/122.pgm"] #五角星
      templates3= ["/13.pgm","/131.pgm","/132.pgm"] #n
      templates4= ["/14.pgm","/141.pgm","/142.pgm"] #三角形
      templates5= ["/11.pgm","/111.pgm","/112.pgm"] #圆
      templates6= ["/15.pgm","/151.pgm","/152.pgm"] #六边形

      while(True):
      led.on()
      img = sensor.snapshot() # Take a picture and return the image.
      lcd.display(sensor.snapshot())
      #x=str(10)
      #uart.write(x+'\r\n')
      #print(x)
      #time.sleep(1000)
      if(uart.any()):
      d=uart.readchar()-48
      #print(d)
      if d==1:
      print(d)
      for t in templates1:
      template = image.Image(t)
      r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
      if r:
      img.draw_rectangle(r, color=0)
      str1="16"
      uart.write(str1+'\r\n')
      print(str1)
      time.sleep(2)
      break
      else:
      #print(2)
      for t in templates2:
      template = image.Image(t)
      r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
      if r:
      img.draw_rectangle(r, color=0)
      str1="12"
      uart.write(str1+'\r\n')
      print(str1)
      time.sleep(2)
      break
      else:
      #print(3)
      for t in templates3:
      template = image.Image(t)
      r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
      if r:
      img.draw_rectangle(r, color=0)
      str1="13"
      uart.write(str1+'\r\n')
      print(str1)
      time.sleep(2)
      break
      else:
      #print(4)
      for t in templates4:
      template = image.Image(t)
      r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
      if r:
      img.draw_rectangle(r, color=0)
      str1="14"
      uart.write(str1+'\r\n')
      print(str1)
      time.sleep(2)
      break
      else:
      #print(5)
      for t in templates5:
      template = image.Image(t)
      r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
      if r:
      img.draw_rectangle(r, color=0)
      str1="11"
      uart.write(str1+'\r\n')
      print(str1)
      time.sleep(2)
      break
      else:
      for t in templates6:
      template = image.Image(t)
      r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
      if r:
      img.draw_rectangle(r, color=0)
      str1="15"
      uart.write(str1+'\r\n')
      print(str1)
      time.sleep(2)
      break
      else:
      str1="99"
      uart.write(str1+'\r\n')
      time.sleep(2)
      break
      break
      break
      break
      break
      break



    • 什么叫做卡住?具体的现象是什么。