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



    • 我是想用uart3传输板子,uart1传输PC串口看,同时传输同一组数据,但uart3正常传输,uart1完全没效果(先前uart3也能单独传输),然后代码就改了4个地方,仿照uart3改的4句:定义,初始化,2个传输数据语句 接口连线也没问题,连接串口前也没有打开IDE(我用自己做的串口助手,可以同时读双串口的,不是这的问题)

      import sensor, image, time
      import pyb
      import utime
      from pyb import UART
      from pyb import LED
      from pyb import Pin, Timer
      import ustruct
      EXPOSURE_TIME_SCALE = 0.001
      thresholds = (100, 255)
      high_threshold = (100, 255)
      red_threshold = (0,100,   0,127,   0,127)
      brightness = 0
      uart = UART(3, 115200)
      uart1 =UART(1, 115200)
      uart.init(115200, bits=8, parity=None, stop=1)
      uart1.init(115200, bits=8, parity=None, stop=1)
      x_deviation = 0
      y_deviation = 0
      gainx = -1
      gainy = -1
      imageSize = 128
      roi2 = (155, 110, 165, 120) 
      xPositionNow = 0
      yPositionNow = 0
      xPositionLast = 0
      yPositionLast = 0
      blue_led = LED(3)
      green_led = LED(2)
      red_led = LED(1)
      def send_data(cx, cy):
          out_data = data = ustruct.pack("<bbhhb",
                                         0x2C,
                                         0x12,
                                         int(cx),
                                         int(cy),
                                         0x5B)
          return out_data
      def find_max(blobs):
          max_size = 0
          for blob in blobs:
              if blob.pixels() > max_size:
                  max_blob = blob
                  max_size = blob.pixels()
          return max_blob
      sensor.reset()
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_framesize(sensor.  QVGA)
      sensor.skip_frames(time=900)
      sensor.set_auto_gain(False)
      sensor.set_auto_exposure(False, 100)
      sensor.set_auto_gain(False)
      sensor.set_windowing(roi2)
      x1 = 0
      y1 = 0
      while True:
          img = sensor.snapshot()
          blobs = img.find_blobs([thresholds],x_stride=1, y_stride=1, area_threshold=10, pixels_threshold=10,merge=True,margin=1)
          for b in blobs:
              max_blob = find_max(blobs)
              img.draw_rectangle(max_blob.rect())
              img.draw_cross(max_blob.cx(), max_blob.cy())
              x1 = max_blob.cx()
              y1 = max_blob.cy()
          if len(blobs) >= 1:
              uart.write(send_data(x1, y1))
              uart1.write(send_data(x1, y1))
              print(x1,y1)
          else:
              uart.write(send_data(-1, -1))
              uart1.write(send_data(-1, -1))
      
      


    • 没事儿了,代码是对的,同一套代码,昨天不行今天又行了,炒!