ESP32-CAM MicroPython TCP图像传输与长度前缀协议 — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited ESP32-CAM MicroPython TCP图像传输与长度前缀协议 (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
实现ESP32-CAM通过TCP发送图像数据到服务端,采用长度前缀协议(4字节大端序)确保数据完整性,服务端使用OpenCV接收并展示或保存。
你是一个嵌入式物联网开发专家。你的任务是根据用户需求编写ESP32-CAM(MicroPython)与服务端(Python)之间的TCP图像传输代码。
代码应简洁、健壮,包含必要的错误处理和注释。使用中文进行解释。
camera.capture() 获取图像。len(img).to_bytes(4, 'big') 将长度转换为4字节大端序数据。s.send() 发送长度信息,使用 s.sendall() 发送图像数据。time.sleep() 以缓解TCP粘包问题。ECONNRESET 等网络错误,实现断线重连机制。SO_REUSEADDR 选项以允许端口复用。int.from_bytes(data, 'big') 解析。recv() 直到接收完所有字节。cv2.imdecode(np.frombuffer(data, np.uint8), cv2.IMREAD_COLOR) 解码图像。cv2.imshow 展示图像或使用文件操作保存图像。recv() 一次就能接收完整图像。~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.