The sample demonstrates how to build a C/C++ barcode reader app on Raspberry Pi 4
.
- Raspberry Pi 4 (4GB model)
- Raspberry Pi RGB Cooling HAT with adjustable fan and OLED display
- Micro-HDMI to HDMI cable
- HDMI Female to HDMI Female Coupler Connector
- USB Webcam
-
Download OpenCV source code: https://github.com/opencv/opencv/releases
-
Install required packages:
sudo apt install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libjpeg-dev libpng-dev libtiff-dev
-
Build and install OpenCV:
mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENCV_GENERATE_PKGCONFIG=ON .. make -j4 sudo make install
-
Get a 30-day trial license of Dynamsoft Barcode Reader and update the following code in
main.cxx
:iRet = reader.InitLicense("LICENSE-KEY");
-
Build and run the barcode reader app on
Raspberry Pi 4
:mkdir build cd build cmake .. cmake --build . ./main
-
Create
/home/pi/autostart.sh
:#!/bin/sh /home/pi/raspberry-pi-cpp-barcode/build/main
-
Change the file permission:
chmod a+x autostart.sh
-
Create
/home/pi/.config/autostart/autostart.desktop
:[Desktop Entry] Type=Application Exec=sh /home/pi/autostart.sh
-
Reboot:
sudo reboot