Example Code for Raspberry Pi-Video Stream and Control
Last revision 2025/12/17
This project explains how to use the video stream and video control software packages for the SEN0338 Night Camera Module on Raspberry Pi. Users will learn to set up the camera, enable necessary interfaces, download and install software packages, and use tools for real-time video preview, recording, capture, and parameter configuration.
Hardware Preparation
- Raspberry Pi x1
- Ethernet cable x1
- Micro SD card x1
- HDMI Display x1
- Camera Module (SEN0338) x1
- FFC Connector x1
- Dupont Wires
Software Preparation
- Raspberry Pi OS (download from Raspberry Pi website)
- Software package from GitHub:
git clone https://github.com/veyeimaging/raspberrypi.gitor DFRobot link - Low-level support libraries:
sudo apt-get update && sudo apt-get install libopencv-devsudo apt-get install python-opencvsudo apt-get install libzbar-dev
Wiring Diagram
As shown in the figure below, connect the camera module onto the Raspberry Pi board with a FFC connector and Dupont wires (black to GND, red to 5V).


Other Preparation Work
- Insert the microSD card with Raspberry Pi OS into the card slot, connect Ethernet cable, HDMI display, and USB power.
- Power on Raspberry Pi and enable Camera and I2C via
sudo raspi-config(Option 5). - Restart Raspberry Pi.
- Enable SSH and Samba service (optional, refer to online guides).
- Download the software package:
- Use
git clone https://github.com/veyeimaging/raspberrypi.gitor download from DFRobot link.
- Use
- Transfer the software package to Raspberry Pi via Samba or USB.
raspicam type toolkit
Add executable permissions:
cd raspberrypi/veye_raspcam/bin/
chmod +x *
- Real-time video preview (20s, 1280x720):
./veye_raspipreview -t 20000 -p '0,0,1280,720' - Continuous full-screen preview:
./veye_raspipreview -t -1 - Video recording (5s to ~/test.h264):
./veye_raspivid -t 5000 -o ~/test.h264 - Network transmission (Raspberry Pi):
./veye_raspivid -b 4000000 -t 0 -o - | nc -l -p 5000 - Network reception (PC with gstreamer):
./gst-launch-1.0 -v tcpclientsrc host=x.x.x.x port=5000 ! decodebin ! autovideosink - Network reception (PC with mplayer):
./mplayer -x 1280 -y 720 -geometry 0:0 -fps 200 -demuxer h264es -noborder ffmpeg://tcp://x.x.x.x:5000 - YUV video recording (200ms to /dev/shm/test.yuv):
./veye_raspividyuv -t 200 -o /dev/shm/test.yuv - Capture raw YUV pictures (200ms to /dev/shm):
./veye_raspiraw -md 2 -t 200 -o /dev/shm/out.%04d.yuv - Capture single YUV picture:
./veye_raspistillyuv -o /dev/shm/test.yuv - Capture YUV pictures at 50ms intervals for 1s:
./veye_raspistillyuv -tl 50 -t 1000 -o /dev/shm/test%d.yuv - Capture JPG picture:
./veye_raspistill -o ~/test.jpg - Capture BMP pictures at 50ms intervals for 1s:
./veye_raspistill -e bmp -tl 50 -t 1000 -o /dev/shm/test%d.bmp - Real-time preview with keyboard capture:
./veye_raspistill -k -o ~/test%d.jpg -t 0
D-SDK Software Package
Install low-level support libraries:
sudo apt-get update && sudo apt-get install libopencv-dev
sudo apt-get install python-opencv
sudo apt-get install libzbar-dev
Compile and install SDK:
./buildme
sudo install -m 644 ./libdmipicam.so /usr/lib/
C Sample commands:
- Real-time preview:
./preview - Dual-camera preview (RPI CM):
./preview-dualcam - Video compression to H.264:
./video - Capture JPEG picture:
./Capture - Pipeline video output:
./video2stdout | nc -l -p 5000 - Capture YUV picture:
./capture_yuv - Dual-camera capture:
./capture-dualcam - YUV stream export:
./yuv_stream - OpenCV display:
./capture2opencv - QR code detection:
./qrcode_detection
Python Sample commands:
- Real-time preview:
python preview.py - Capture JPEG picture:
python capture.py - Capture YUV picture:
python capture_yuv.py - Video compression:
python video.py - OpenCV display:
python capture2opencv.py
Video Control Software Package
Use I2C-0 for control. Refer to I2C Script User Guide.
Result
- Real-time Preview: HDMI display shows live video from the camera.
- Video Recording: Recorded files (e.g., ~/test.h264) can be played back.
- Picture Capture: Captured JPG/BMP/YUV files are saved to specified directories.
- Network Transmission: PC receives and displays video stream from Raspberry Pi.
- Parameter Configuration: Camera settings (brightness, contrast, etc.) are adjustable via I2C commands.
Additional Information
- Software package includes two parts:
veye_raspcam(raspicam toolkit) andD_mipi_rpi(C/Python SDK). - Both software parts are open source.
- More details on I2C control: I2C Script User Guide.
Was this article helpful?
