导航

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

    lmrz

    @lmrz

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

    lmrz 关注

    lmrz 发布的帖子

    • 请问为什么我一与stm32建立起连接并且找到目标就开始掉帧呢

      ![0_1579411056541_U%DUWPEYA_JX(}P_7RBMZ2I.jpg](正在上传 100%)

      0_1579411062329.jpg

      c sensor, image, time, math, struct,random
      from pyb import UART
      
      red = (49, 97, -31, 67, 52, 94)
      red1 = (39, 100, 20, 127, -128, 127)
      
      sensor.reset()
      sensor.set_pixformat(sensor.RGB565)
      sensor.set_framesize(sensor.QVGA)
      sensor.skip_frames(time = 10)
      sensor.set_auto_gain(False)
      sensor.set_auto_whitebal(False)
      
      clock = time.clock()
      
      # 串口初始化
      uart = UART(4, 115200)
      uart.init(115200, bits=8, parity=None, stop=1)
      
      
      def find_max(blobs):
          max_size = 0
          for blob in blobs:
              if blob[2]*blob[3] > max_size:
                  max_blob=blob
                  max_size = blob[2]*blob[3]
          return max_blob
      
      def blob_sort(blobs):
          new_blobs = []
          for i in range(0,len(blobs)):
              max_blob = find_max(blobs)
              new_blobs.append(blobs.pop(blobs.index(max_blob)))
          return new_blobs
      
      def send_message(blob):
          #for blob in blobs:
              x = int((blob.cx())*128/320)
              y = int((blob.cy())*60/240)
              z = int(blob.area()*(128*60)/(320*240))
              num = 1
              dateout = struct.pack("<bbhhhb",          # 打包数据
                                      0xaa,             # 帧头1
                                      0xae,             # 帧头2
                                      x,                # 数据1
                                      y,                # 数据2
                                      num,              # 数据3
                                      0xff)             # 帧尾
              uart.write(dateout + '\n')
              print(dateout)
      
      #将获取到的色块的坐标变为json json.dumps([max_blob.cx(),max_blob.cy()])
      while(True):
          Location = []
          clock.tick()
          img = sensor.snapshot()
          red_blobs = img.find_blobs([red1],area_threshold=10,pixels_threshold=20)
          if red_blobs:
              #new_blobs = blob_sort(red_blobs)              #对色块的大小进行排序
              #send_message(new_blobs)                       #获取排序后色块的信息并依次发送至muc
              max_blob = find_max(red_blobs)
              img.draw_rectangle(max_blob.rect())
              img.draw_cross(max_blob.cx(), max_blob.cy())
              send_message(max_blob)
      
      
      发布在 OpenMV Cam
      L
      lmrz