• 星瞳AI VISION软件内测!可以离线标注,训练,并生成OpenMV的模型。可以替代edge impulse https://forum.singtown.com/topic/8206
  • 我们只解决官方正版的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, math
      from machine import UART
      
      uart = UART(2, baudrate=115200)
      sensor.reset()                      # Reset and initialize the sensor.
      sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
      sensor.set_framesize(sensor.QVGA)   # Set frame size to QVGA (320x240)
      sensor.skip_frames(time = 2000)     # Wait for settings take effect.
      clock = time.clock()                # Create a clock object to track the FPS.
      thresholds = (64, 81)
      
      while(True):
          clock.tick()                    # Update the FPS clock.
          img = sensor.snapshot()         # Take a picture and return the image.
          uart_num = uart.any()      # 获取当前串口数据数量
          if(uart_num):
              uart_str = uart.read(uart_num).decode().strip() # 读取串口数据
              print(uart_str) 
              if(uart_str==3):
                 print("lllll")
                 for blob in img.find_blobs([thresholds], pixels_threshold=100, area_threshold=100, merge=True):
                     # These values depend on the blob not being circular - otherwise they will be shaky.
                     if blob.elongation() > 0.5:
                        img.draw_edges(blob.min_corners(), color=0)
                        img.draw_line(blob.major_axis_line(), color=0)
                        img.draw_line(blob.minor_axis_line(), color=0)
                        # These values are stable all the time.
                     img.draw_rectangle(blob.rect(), color=127)
                     if blob.cy()>110   and blob.cx()<200 and blob.cx()> 160 and blob.cy()<  130:
                        uart.write("t")
                        print("t")
                     elif blob.cy()< 110  and blob.cx()> 160 and blob.cx() < 200:
                        uart.write("h")
                        print("q")
                     elif blob.cy()> 130 and blob.cx()<200 and blob.cx()> 160:
                        uart.write("q")
                        print("h")
                     elif blob.cx()<160:
                        uart.write("y")
                        print("z")
                     elif blob.cx() > 200:
                        uart.write("z")
                        print("y")
      

      等于3判定不通过
      接受的是
      3
      3
      3
      3
      3
      3
      这样的



    • if(uart_str==3):

      改为

      if(uart_str=='3'):



    • 不对
      enable_lens_corr = False # turn on for straighter lines...

      import sensor, image, time, pyb, math
      import os, tf
      from machine import UART
      from pyb import LED
      from struct import pack

      white=LED(4)
      uart = UART(2, 115200)
      sensor.reset()
      sensor.set_auto_gain(False) # must be turned off for color tracking
      sensor.set_auto_whitebal(False) # must be turned off for color tracking
      #sensor.set_auto_whitebal(False)
      sensor.set_pixformat(sensor.RGB565) # 灰度更快(160x120 max on OpenMV-M7)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(time = 2000)
      clock = time.clock()
      thresholds=(30, 65, -27, 47, -15, 33)
      #Large_area=[76,22,210,122]
      net_path = "mobilenet_v2-2022-06-29T03-44-15.608Z_in-int8_out-int8_channel_ptq.tflite" # 定义模型的路径
      labels = [line.rstrip() for line in open("/sd/labels_animal_fruits_traffic.txt")] # 加载标签
      net = tf.load(net_path, load_to_fb=True) # 加载模型

      min_degree = 70
      max_degree = 110

      #点到直线距离公式
      def get_point_line_distance(point, p0, p1):
      point_x = point[0]
      point_y = point[1]
      line_s_x, line_s_y=p0
      line_e_x, line_e_y=p1
      #若直线与y轴平行,则距离为点的x坐标与直线上任意一点的x坐标差值的绝对值
      if line_e_x - line_s_x == 0:
      return math.fabs(point_x - line_s_x)
      #若直线与x轴平行,则距离为点的y坐标与直线上任意一点的y坐标差值的绝对值
      if line_e_y - line_s_y == 0:
      return math.fabs(point_y - line_s_y)
      #斜率
      k = (line_e_y - line_s_y) / (line_e_x - line_s_x)
      #截距
      b = line_s_y - k * line_s_x
      #带入公式得到距离dis
      dis = math.fabs(k * point_x - point_y + b) / math.pow(k * k + 1, 0.5)
      return dis
      #两点长度计算
      def get_point_point_distance(p0, p1):
      line_s_x, line_s_y=p0
      line_e_x, line_e_y=p1
      line_long = math.sqrt(pow(line_s_x-line_e_x,2)+pow(line_s_y-line_e_y,2))
      return line_long

      while(True):
      clock.tick()
      img = sensor.snapshot().lens_corr(1.8)
      white.on()
      uart_str = uart.read(uart.any()).decode().strip()
      print(uart_str)
      if(uart_str=='1'):
      print("a")
      print("...........")

      这样我仍然无法打印a



    • 打印a那是有空格的



    • 0_1658068677719_b9a48104-1e01-4d35-bc30-b3815d054ba6-image.png
      这是发送端



    • 可以收到
      1
      1
      1
      1



    • @2nc3 把OpenMV终端的log发一下。



    • 先用串口调试扩展板,和星瞳串口助手测试。

      https://singtown.com/learn/50240/