Skip to content

Latest commit

 

History

History

raspberry_pi_oled

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

C/C++ Barcode Reader for Raspberry Pi 4

The sample demonstrates how to build a C/C++ barcode reader app on Raspberry Pi 4.

Prerequisites

Install OpenCV

  1. Download OpenCV source code: https://github.com/opencv/opencv/releases

  2. 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
  3. 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
    

Build and Run

  1. Get a 30-day trial license of Dynamsoft Barcode Reader and update the following code in main.cxx:

    iRet = reader.InitLicense("LICENSE-KEY");
  2. Build and run the barcode reader app on Raspberry Pi 4:

    mkdir build
    cd build
    cmake ..
    cmake --build .
    ./main
    

    Raspberry Pi barcode QR detection

App Auto Start

  1. Create /home/pi/autostart.sh:

    #!/bin/sh
    /home/pi/raspberry-pi-cpp-barcode/build/main
    
  2. Change the file permission:

    chmod a+x autostart.sh
    
  3. Create /home/pi/.config/autostart/autostart.desktop:

    [Desktop Entry]
    Type=Application
    Exec=sh /home/pi/autostart.sh
    
  4. Reboot:

    sudo reboot
    

Blog

How to Build C/C++ Barcode Reader App on Raspberry Pi 4