• 免费好用的星瞳AI云服务上线!简单标注,云端训练,支持OpenMV H7和OpenMV H7 Plus。可以替代edge impulse。 https://forum.singtown.com/topic/9519
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 串口数据传输速度太慢怎么提高速度呢?



    • # Edge Impulse - OpenMV Image Classification Example
      
      import sensor, image, time, os, tf
      from pyb import UART
      import json
      
      
      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.set_windowing((240, 240))       # Set 240x240 window.
      sensor.skip_frames(time=2000)          # Let the camera adjust.
      
      net = "trained.tflite"#调用神经网络模型
      labels = [line.rstrip('\n') for line in open("labels.txt")]
      color_threshold = [(0, 100, 19, 127, -9, 127)]#红色色块提取
      uart = UART(3, 115200)#串口通信
      
      def zfl(s, width):
          return '{:0>{w}}'.format(s, w=width)
      
      def find_max(blobs):
          max_pixels=0
          for blob in blobs:
              if blob[4] > max_pixels:
                  max_blob=blob
                  max_pixels = blob[4]
          return max_blob
      
      clock = time.clock()
      while(True):
          clock.tick()
      
          img = sensor.snapshot()
          blobs = img.find_blobs(color_threshold,pixels_threshold=100, area_threshold=10)
          #色块提取,确定roi区域
          if blobs:
              max_blob = find_max(blobs)
              x = max_blob.x()
              y = max_blob.y()
              w = max_blob.w()
              h = max_blob.h()
              thresholds = (x,y,w,h)
              #获取图像xy伸缩率,float形式
              x_change = 240.0/w
              y_change = 240.0/h
              #中心位置转为4位字符串形式
              X = zfl(str(max_blob.cx()),4)
              Y = zfl(str(max_blob.cy()),4)
              #图像roi区域复制,便于之后操作
              img = img.crop(roi=thresholds,x_scale=x_change,y_scale=y_change,copy_to_fb=True)
              #神经网络判别并输出,置信度70%
              for obj in tf.classify(net, img, min_scale=1.0, scale_mul=0.8, x_overlap=0.5, y_overlap=0.5):
       #           print("----------" )
                  predictions_list = list(zip(labels, obj.output()))
                  for i in range(len(predictions_list)):
                      if (predictions_list[i][1] > 0.6):#相似度达到60%以上认为是
                          output_str = 'AB'+X+Y
                          print("%s"%(predictions_list[i][0]))
      
                          uart.write(output_str)
                          print(output_str)
                          print(clock.fps()) 
      

      输出的fps只有3.5,我需要fps至少为20,怎么提高传输的速度呢?0_1620800958864_微信图片_20210512142902.png



    • 不是传输速度慢,是神经网络需要的计算量大,计算起来慢。这个没法解决的。