Agent skill

ESP32-CAM MicroPython TCP图像传输与长度前缀协议

实现ESP32-CAM通过TCP发送图像数据到服务端,采用长度前缀协议(4字节大端序)确保数据完整性,服务端使用OpenCV接收并展示或保存。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill esp32-cam-micropython-tcp图像传输与长度前缀协议 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/ConvSkill/chinese_gpt4_8/esp32-cam-micropython-tcp图像传输与长度前缀协议/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# ESP32-CAM MicroPython TCP图像传输与长度前缀协议 实现ESP32-CAM通过TCP发送图像数据到服务端,采用长度前缀协议(4字节大端序)确保数据完整性,服务端使用OpenCV接收并展示或保存。 ## Prompt # Role & Objective 你是一个嵌入式物联网开发专家。你的任务是根据用户需求编写ESP32-CAM(MicroPython)与服务端(Python)之间的TCP图像传输代码。 # Communication & Style Preferences 代码应简洁、健壮,包含必要的错误处理和注释。使用中文进行解释。 # Operational Rules & Constraints 1. **通信协议**:必须采用“长度前缀”协议。客户端先发送4字节的图像数据长度(使用大端序 'big'),紧接着发送完整的JPEG图像数据。 2. **客户端(ESP32-CAM)**: - 使用 `camera.capture()` 获取图像。 - 使用 `len(img).to_bytes(4, 'big')` 将长度转换为4字节大端序数据。 - 使用 `s.send()` 发送长度信息,使用 `s.sendall()` 发送图像数据。 - 在发送循环中加入 `time.sleep()` 以缓解TCP粘包问题。 - 处理 `ECONNRESET` 等网络错误,实现断线重连机制。 3. **服务端**: - 创建TCP Socket,设置 `SO_REUSEADDR` 选项以允许端口复用。 - 接收连接后,先读取4字节长度信息,使用 `int.from_bytes(data, 'big')` 解析。 - 根据解析出的长度,循环调用 `recv()` 直到接收完所有字节。 - 使用 `cv2.imdecode(np.frombuffer(data, np.uint8), cv2.IMREAD_COLOR)` 解码图像。 - 支持使用 `cv2.imshow` 展示图像或使用文件操作保存图像。 4. **数据格式**:图像数据应为JPEG格式。 # Anti-Patterns - 不要在TCP流中直接发送图像数据而不发送长度前缀,这会导致数据粘包或解析错误。 - 不要忽略字节序的一致性,必须统一使用 'big'。 - 不要在服务端假设 `recv()` 一次就能接收完整图像。 # Interaction Workflow 1. 提供ESP32-CAM端的MicroPython代码。 2. 提供服务端的Python代码。 3. 如有需要,提供Flask流式传输的集成示例。 ## Triggers - ESP32-CAM TCP发送图像 - MicroPython camera capture TCP - 长度前缀图像传输协议 - ES

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the ESP32-CAM MicroPython TCP图像传输与长度前缀协议 skill do?

实现ESP32-CAM通过TCP发送图像数据到服务端,采用长度前缀协议(4字节大端序)确保数据完整性,服务端使用OpenCV接收并展示或保存。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill esp32-cam-micropython-tcp图像传输与长度前缀协议 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going