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



    • 为什么我现在一运行这串代码,openmv就亮白光呢?我已经将软件更新到了最新版。

      import sensor, image, time
      from pyb import UART
      from pyb import LED #加入
      import json                    #载入库  加入
      import pyb
      import math
      def get_biggest_blob(b):
          max_blob = 0
          max_blob_nb = 0
          for i in range(len(b)):
              area = b[i].pixels()
              if area > max_blob:
                  max_blob = area
                  max_blob_nb = i
          return max_blob_nb
      def modified_data(data):
          data = int(data)
          str_data = ''
          if data < 10:
              str_data = str_data + '000' + str(data)
          elif data >= 10 and data < 100:
              str_data = str_data + '00' + str(data)
          elif data >=100 and data <1000:
              str_data = str_data + '0' + str(data)
          else:
              str_data = str_data + str(data)
          return str_data.encode('utf-8')
      led1 = pyb.LED(1)
      led2 = pyb.LED(2)
      led3 = pyb.LED(3)
      uart = UART(3, 115200)
      led1.on()
      led2.on()
      led3.on()
      sj=0
      clock = time.clock()
      x=20
      # 白天
      '''
      green_threshold_l   =(11, 69, -66, -11, -15, 54)
      yellow_threshold   =(35, 66, -11, 12, -4, 46) #黄色阈值
      gray_threshold  =(58, 88, -7, 23, -17, 6) #灰色阈值
      red_threshold_r   = (43, 62, 24, 88, 23, 69)
      red_threshold_l  = (6, 25, 0, 48, -18, 64)
      #red_threshold   = ((33, 74, 24, 80, -5, 73))#红色阈值
      '''
      # 夜晚
      gray_threshold  = (27, 92, -35, 26, -52, 5)
      yellow_threshold   =(56, 77, -4, 19, 7, 82) #黄色阈值
      green_threshold_l  =(30, 57, -36, -10, -35, 26) #灰色阈值
      red_threshold_r   = (28, 52, 43, 77, 15, 61)
      red_threshold_l  = (8, 35, -6, 56, -19, 29)
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QQVGA)
      sensor.skip_frames(10)
      sensor.set_auto_whitebal(False)
      clock = time.clock()
      while True:
          t=1
          clock.tick()
      
      
          if uart.any():
              sj = uart.read(1)
              #sj = uart.read(uart.any()).decode().strip()
              print("pp",sj,x)
      
          while (sj==b'1'):
              img = sensor.snapshot()
              green_blobs_l=img.find_blobs([green_threshold_l])
              gray_blobs=img.find_blobs([gray_threshold])
              yellow_blobs=img.find_blobs([yellow_threshold])
      
              if yellow_blobs:
                  ii = get_biggest_blob(yellow_blobs)
            
      


    • 因为第32行到34行把LED点亮了。