logo

如何将jpg数据分片成500字节大小,以便通过NB通讯发送到服务器?

2024-11-07 14:33
M
ogdm
  img = sensor.snapshot()

    for i, detection_list in enumerate(net.predict([img], callback=fomo_post_process)):
        if i == 0: continue  # background class
        if len(detection_list) == 0: continue  # no detections for this class?

        print("This is %s " % labels[i])
       # for x, y, w, h, score in detection_list:
       #     center_x = math.floor(x + (w / 2))
       #     center_y = math.floor(y + (h / 2))
       #     print(f"x {center_x}\ty {center_y}\tscore {score}")
       #     img.draw_circle((center_x, center_y, 12), color=colors[i])

       #print(clock.fps(), "fps", end="\n\n")
       # uart3.write("This is %s " % labels[i])

        img_compressed = img.compress(quality=(50))
        size = ustruct.pack("<L", len(img_compressed))

        for xxx in range(0,len(img_compressed),500):
           
            uart3.write(size)
            uart3.write(b';')
            uart3.write(img_compressed)
            time.sleep(1)