Update OpenALPR README and add Plugin Installer

+ Update OpenALPR installer to check for OpenCV
merge-requests/63/head
Moe 2019-01-08 15:27:28 -08:00
parent 4884597ae8
commit 1763353e00
6 changed files with 131 additions and 43 deletions

View File

@ -0,0 +1,41 @@
# Install prerequisites
DIR=`dirname $0`
INSTALLERS_DIR="$DIR"
echo "-----------------------------------"
if ! [ -x "$(command -v opencv_version)" ]; then
echo "Installing OpenCV"
dos2unix $INSTALLERS_DIR/opencv-cuda.sh
sh $INSTALLERS_DIR/opencv-cuda.sh
else
echo "OpenCV found... : $(opencv_version)"
fi
# this includes all the ones missing from OpenALPR's guide.
sudo apt install libtesseract-dev git cmake build-essential libleptonica-dev -y
sudo apt install liblog4cplus-dev libcurl3-dev -y
sudo apt install libleptonica-dev -y
sudo apt install libcurl4-openssl-dev -y
sudo apt install liblog4cplus-dev -y
sudo apt install beanstalkd -y
sudo apt install openjdk-8-jdk -y
# Clone the latest code from GitHub
git clone https://github.com/openalpr/openalpr.git
# Setup the build directory
cd openalpr/src
mkdir build
cd build
# setup the compile environment
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc ..
# compile the library
make
# Install the binaries/libraries to your local system (prefix is /usr)
sudo make install
# Test the library
wget http://plates.openalpr.com/h786poj.jpg -O lp.jpg
alpr lp.jpg
rm lp.jpg

View File

@ -1,4 +1,14 @@
# Install prerequisites
DIR=`dirname $0`
INSTALLERS_DIR="$DIR"
echo "-----------------------------------"
if ! [ -x "$(command -v opencv_version)" ]; then
echo "Installing OpenCV"
dos2unix $INSTALLERS_DIR/opencv-cuda.sh
sh $INSTALLERS_DIR/opencv-cuda.sh
else
echo "OpenCV found... : $(opencv_version)"
fi
# this includes all the ones missing from OpenALPR's guide.
sudo apt install libtesseract-dev git cmake build-essential libleptonica-dev -y
sudo apt install liblog4cplus-dev libcurl3-dev -y
@ -28,4 +38,4 @@ sudo make install
# Test the library
wget http://plates.openalpr.com/h786poj.jpg -O lp.jpg
alpr lp.jpg
rm lp.jpg
rm lp.jpg

View File

@ -0,0 +1,53 @@
DIR=`dirname $0`
INSTALLERS_DIR="$DIR/../../INSTALL"
if ! [ -x "$(command -v dos2unix)" ]; then
echo "-----------------------------------"
echo "Installing dos2unix"
apt install dos2unix -y
fi
echo "-----------------------------------"
if ! [ -x "$(command -v alpr)" ]; then
echo "Installing OpenALPR"
echo "Do you want to Install OpenALPR with CUDA enabled?"
echo "(Y)es or (n)o?"
echo "Press [ENTER] for default (Yes)"
read openalprcudaenabled
if [ "$openalprcudaenabled" = "n" ] || [ "$openalprcudaenabled" = "N" ]; then
sed -i -e 's/detector = lbpgpu/detector = lbpcpu/g' "$DIR/openalpr.conf"
dos2unix $INSTALLERS_DIR/openalpr-cpu-easy.sh
sh $INSTALLERS_DIR/openalpr-cpu-easy.sh
else
sed -i -e 's/detector = lbpcpu/detector = lbpgpu/g' "$DIR/openalpr.conf"
dos2unix $INSTALLERS_DIR/openalpr-gpu-easy.sh
sh $INSTALLERS_DIR/openalpr-gpu-easy.sh
fi
else
echo "OpenALPR found... : $(alpr --version)"
fi
echo "-----------------------------------"
if [ ! -e "$DIR/conf.json" ]; then
echo "Creating conf.json"
cp $DIR/conf.sample.json $DIR/conf.json
else
echo "conf.json already exists..."
fi
echo "-----------------------------------"
echo "Installing Modules.."
npm install --unsafe-perm
echo "Finding and Fixing Module Vulnerabilities.."
npm audit fix --force
echo "Shinobi - Do you want to start the plugin?"
echo "(Y)es or (n)o?"
echo "Press [ENTER] for default (Yes)"
read startplugin
if [ "$startplugin" = "n" ] || [ "$startplugin" = "N" ]; then
echo "-----------------------------------"
echo "Start the plugin with pm2 like so :"
echo "pm2 start $DIR/shinobi-openalpr.js"
echo "-----------------------------------"
echo "Start the plugin without pm2 :"
echo "node $DIR/shinobi-openalpr.js"
else
pm2 start shinobi-openalpr.js
pm2 save
fi

View File

@ -1,49 +1,32 @@
# OpenALPR and Motion Detector
# OpenALPR
Install required libraries.
**Ubuntu and Debian only**
**Ubuntu 17.10 and 18.04 only**
```
sudo apt update && sudo apt install libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++ openalpr openalpr-daemon openalpr-utils libopenalpr-dev -y
```
> By default plugins run as a client. `camera.js` is running as the host awaiting a plugin to connect to it. To learn about how to connect a plugin as a Host please review the "Run the plugin as a Host" section at the end of this README.
**Install the Node.js Canvas engine**
1. Go to the plugin's directory and run the installer for OpenALPR. **/home/Shinobi** is the default directory for where Shinobi is installed.
```
cd /home/Shinobi/plugins/openalpr
sh INSTALL.sh
```
```
sudo npm install canvas@1.6
```
Go to the Shinobi directory. **Below is an example.**
2. Then add the plugin key to the **Main Configuration** file, the `conf.json` located in **/home/Shinobi**. You will find the `pluginKeys` object empty on a new install as seen below.
```
"pluginKeys":{}
```
> Add the key so it looks something like this.
```
cd /home/Shinobi
```
```
"pluginKeys":{
"OpenALPR": "SomeOpenALPRkeySoPeopleDontMessWithYourShinobi"
}
```
Copy the config file.
3. Restart Shinobi to apply the Plugin Key. Shinobi does not need to be restarted when a plugin is initiated or stopped after applying changes to the Main Configuration file.
```
cp plugins/openalpr/conf.sample.json plugins/openalpr/conf.json
```
Edit it the new file. Host should be `localhost` and port should match the `listening port for camera.js`.
```
nano plugins/openalpr/conf.json
```
Start the plugin.
```
node plugins/openalpr/shinobi-openalpr.js
```
Or to daemonize with PM2.
```
pm2 start plugins/openalpr/shinobi-openalpr.js
```
Doing this will reveal options in the monitor configuration. Shinobi does not need to be restarted when a plugin is initiated or stopped.
> You should change `SomeOpenALPRkeySoPeopleDontMessWithYourShinobi` to something else in both the main configuration and plugin configuration. Both files changed need to be matching keys of course.
## Run the plugin as a Host
> The main app (Shinobi) will be the client and the plugin will be the host. The purpose of allowing this method is so that you can use one plugin for multiple Shinobi instances. Allowing you to easily manage connections without starting multiple processes.
@ -51,7 +34,7 @@ Doing this will reveal options in the monitor configuration. Shinobi does not ne
Edit your plugins configuration file. Set the `hostPort` **to be different** than the `listening port for camera.js`.
```
nano plugins/openalpr/conf.json
nano conf.json
```
Here is a sample of a Host configuration for the plugin.
@ -70,7 +53,7 @@ Here is a sample of a Host configuration for the plugin.
}
```
Now modify the **main configuration file** located in the main directory of Shinobi. *Where you currently should be.*
Now modify the **Main Configuration** file located in the main directory of Shinobi. *Where you currently should be.*
```
nano conf.json
@ -90,4 +73,4 @@ Add the `plugins` array if you don't already have it. Add the following *object
"type" : "detector"
}
],
```
```

View File

@ -4,7 +4,6 @@
"description": "OpenALPR plugin for Shinobi",
"main": "shinobi-openalpr.js",
"dependencies": {
"canvas": "^1.6.7",
"express": "^4.16.2",
"moment": "^2.19.2",
"socket.io": "^2.0.4"

View File

@ -26,7 +26,9 @@ try{
}
// Base Init />>
// OpenALPR Init >>
if(config.alprConfig===undefined){config.alprConfig=__dirname+'/openalpr.conf'}
if(config.alprConfig === undefined){
config.alprConfig = __dirname + '/openalpr.conf'
}
// OpenALPR Init />>
s.detectObject = function(buffer,d,tx,frameLocation){
var detectStuff = function(frame){