导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. axql
    A
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    axql

    @axql

    0
    声望
    1
    楼层
    458
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    axql 关注

    axql 发布的帖子

    • 我电脑运行程序可以,但是脱机运行后就会卡住怎么回事?
      # 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
      
      发布在 OpenMV Cam
      A
      axql