Source repository: https://github.com/embeddip/PyDIPLink
PyDIPLink is a Python package for transferring images, JPEG frames, and one-dimensional signal data between a computer and an embedded device over UART. It is used with the embedded examples from the book Embedded Digital Image Processing with Microcontrollers.
- Send images from a computer to an embedded device.
- Receive raw images from an embedded device.
- Receive and record JPEG frame streams.
- Receive one-dimensional signal data, such as histograms.
- Support RGB888, RGB565, grayscale, YUV, HSV, and JPEG data.
Install from PyPI:
pip install pydiplinkInstall from source:
git clone https://github.com/embeddip/PyDIPLink.git
cd PyDIPLink
pip install -e .Start the receiver with the default serial settings:
pydiplinkSpecify the serial port and baud rate:
pydiplink --port /dev/ttyUSB1 --baud 115200
pydiplink --port COM3 --baud 500000Set a default image to send when the embedded device requests one:
pydiplink --image input.jpgRecord received JPEG frames to a video file:
pydiplink --record --output video.avi --fps 15Record JPEG frames from Python:
from pydiplink import JpegVideoWriter, receive_and_show_jpeg
with JpegVideoWriter("output.avi", fps=30, resolution=(640, 480)) as writer:
for _ in range(300):
frame = receive_and_show_jpeg(ser)
if frame is not None:
writer.write_frame(frame)Receive one-dimensional signal data:
import serial
from pydiplink import receive_1d_signal
ser = serial.Serial("/dev/ttyUSB0", 500000, timeout=5)
signal_data = receive_1d_signal(ser, plot=True, save_path="histogram")
ser.close()The embedded device sends a three-byte command to select the transfer type:
STR: device requests an image from the computer.STW: device sends a raw image to the computer.STJ: device sends a JPEG frame to the computer.ST1: device sends one-dimensional signal data.
PyDIPLink handles the serial transfer, timeouts, validation, and file output for these commands.
The command line tool can read default settings from environment variables:
export DIPLINK_PORT=/dev/ttyUSB0
export DIPLINK_BAUD=500000
export DIPLINK_IMAGE=input.jpgImages are limited to 4096 by 4096 pixels and 50 MB.
Complete examples are available in examples/:
basic_image_transfer.py: send and receive images.jpeg_streaming.py: receive JPEG streams.
See docs/API.md for API documentation.
This project is licensed under the MIT License. See LICENSE for details.
Developed by Ozan Durgut for embedded systems and digital image processing examples.