logo

想将图片分包用串口发送,出错

2022-07-13 14:42
S
飞吧托利
5b41db66-31e2-486f-8664-f56e1d2d483c.png

将图片分包用串口发送,但是出现图中错误

代码为:

import sensor, image, time,pyb
from pyb import UART
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)

clock = time.clock()
uart = UART(3, 115200)

clock.tick()
img = sensor.snapshot()
#img.compress()
package_len = 50
for i in range(0,img.size(),package_len):
    uart.write(img[i:i+package_len])
    pyb.delay(8000)
2022-07-13 18:39
I
网红小智智 星瞳科技

img对象,不支持切片操作。

2022-07-14 09:52
S
飞吧托利

那想图片分包该怎么做?

2022-07-14 20:55
I
网红小智智 星瞳科技

要么一起发送,要么获取每个像素值单独发送

2022-07-15 11:39
S
飞吧托利

@kidswong999 在 [想将图片分包用串口发送,出错](/post/26562) 中说:

> 要么获取每个像素值单独发送

如何获取每个像素值?另外我看以前的帖子不是可以这样操作的吗https://forum.singtown.com/topic/5532/%E5%A6%82%E4%BD%95%E5%B0%86%E6%8B%8D%E6%91%84%E7%9A%84%E5%9B%BE%E7%89%87%E5%8E%8B%E7%BC%A9%E5%B9%B6%E4%B8%94%E5%88%86%E5%8C%85

2022-07-15 21:14
I
网红小智智 星瞳科技

@m1aw 应该是后面程序更新就没了。