You MUST run the following script with sudo:
sudo ./install-openalpr.sh
install-openalpr.sh
# Options
TESSERACT_INSTALL_DIR=${TESSERACT_INSTALL_DIR:-"$HOME"}
LEPTONICA_INSTALL_DIR=${LEPTONICA_INSTALL_DIR:-"$HOME"}
OPENALPR_INSTALL_DIR=${OPENALPR_INSTALL_DIR:-"$HOME"}
# Temp directory for downloads
TEMP_DIR=$(mktemp -d -t openalpr-installer-XXXXXXXXXXXX)
mkdir -p $TEMP_DIR
echo "
############################################################
# 1. Remove any previously installed versions of
# Tesseract & Leptonica and install all required
# dependencies and build tools.
############################################################
"
apt update -y #fetch list of available updates
apt upgrade -y #install updates – does not remove packages
apt autoremove -y #removes unused/outdated packages
# remove any tesseract binaries and languages
apt remove -y tesseract-ocr*
# remove any previously installed leptonica
apt remove -y libleptonica-dev
# make sure other dependencies are removed too
apt autoclean -y
apt autoremove -y --purge
# install deps
sudo apt install -y unzip libtool m4 automake cmake pkg-config python3-opencv liblog4cplus-1.1-9 liblog4cplus-dev build-essential wget software-properties-common libcurl4 libcurl4-openssl-dev ffmpeg fswebcam mpg321 gpsd gpsd-clients
echo "
############################################################
# 2. Download & install leptonica 1.74.1
############################################################
"
cd $TEMP_DIR
wget https://github.com/DanBloomberg/leptonica/archive/1.74.1.tar.gz
# unpack tarball and cd into leptonica directory
mkdir -p $LEPTONICA_INSTALL_DIR
cd $LEPTONICA_INSTALL_DIR
tar -xvzf "$TEMP_DIR/1.74.1.tar.gz"
cd leptonica-1.74.1
# build leptonica
./autobuild
./configure
make
make install
echo "
############################################################
# 3. Download & install tesseract 3.0.5
############################################################
"
cd $TEMP_DIR
wget https://github.com/tesseract-ocr/tesseract/archive/3.05.02.tar.gz
# unpack tarball and cd into tesseract directory
mkdir -p $TESSERACT_INSTALL_DIR
cd $TESSERACT_INSTALL_DIR
tar -xvzf "$TEMP_DIR/3.05.02.tar.gz"
cd tesseract-3.05.02/
# build tesseract
./autogen.sh
./configure --enable-debug LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include"
make
make install
make install-langs
ldconfig
# check everything worked
tesseract --version
echo "
############################################################
# 5. Download and install OpenALPR
############################################################
"
cd $TEMP_DIR
wget https://github.com/openalpr/openalpr/archive/master.zip
# unpack
mkdir -p $OPENALPR_INSTALL_DIR
cd $OPENALPR_INSTALL_DIR
unzip "$TEMP_DIR/master.zip"
cd openalpr-master/src
mkdir build
cd build
# setup the compile environment
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc ..
# and compile the library
sudo make && sudo make install
echo "
############################################################
# Cleaning up files
############################################################
"
rm -rf $TEMP_DIR$ wget http://plates.openalpr.com/h786poj.jpg -O lp.jpg
$ alpr lp.jpg
# if everything worked you should see:
plate0: 10 results
- 786P0 confidence: 89.6593
- 786PO confidence: 85.9889
- 786PQ confidence: 85.8115
- 786PD confidence: 85.7408
- 786PG confidence: 84.4258
- 786P confidence: 83.0879
- 7B6P0 confidence: 72.5012
- 7B6PO confidence: 68.8309
- 7B6PQ confidence: 68.6534
- 7B6PD confidence: 68.5827
You can directly execute following script;
install-predator.sh
#Predator Install Script
#make sure python installed
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.8
cd ~/
git clone https://github.com/connervieira/Predator.git
cd ./Predator
python3 -m venv venv
source venv/bin/activate
pip3 install validators opencv-python-headless==4.5.3.56 cvlib tensorflow keras silence-tensorflow psutil gps geopy gpsd-py3 requests
echo$(alpr -help)