remove broken openalpr plugin
parent
7c101c2580
commit
7b81878f67
|
@ -1,2 +0,0 @@
|
|||
conf.json
|
||||
cascades
|
|
@ -1,60 +0,0 @@
|
|||
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 "Adding Random Plugin Key to Main Configuration"
|
||||
|
||||
node $DIR/../../tools/modifyConfigurationForPlugin.js openalpr key=$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,60)}')
|
||||
echo "-----------------------------------"
|
||||
echo "Installing Modules.."
|
||||
apt install node-pre-gyp -y
|
||||
npm install nopt npmlog rimraf semver -g
|
||||
npm install
|
||||
npm uninstall nopt npmlog rimraf semver -g
|
||||
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
|
|
@ -1,76 +0,0 @@
|
|||
# OpenALPR
|
||||
|
||||
Install required libraries.
|
||||
|
||||
**Ubuntu 17.10 and 18.04 only**
|
||||
|
||||
> 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.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
```
|
||||
"pluginKeys":{
|
||||
"OpenALPR": "SomeOpenALPRkeySoPeopleDontMessWithYourShinobi"
|
||||
}
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
> 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.
|
||||
|
||||
Edit your plugins configuration file. Set the `hostPort` **to be different** than the `listening port for camera.js`.
|
||||
|
||||
```
|
||||
nano conf.json
|
||||
```
|
||||
|
||||
Here is a sample of a Host configuration for the plugin.
|
||||
- `plug` is the name of the plugin corresponding in the main configuration file.
|
||||
- `https` choose if you want to use SSL or not. Default is `false`.
|
||||
- `hostPort` can be any available port number. **Don't make this the same port number as Shinobi.** Default is `8082`.
|
||||
- `type` tells the main application (Shinobi) what kind of plugin it is. In this case it is a detector.
|
||||
|
||||
```
|
||||
{
|
||||
"plug":"OpenALPR",
|
||||
"hostPort":8082,
|
||||
"key":"SomeOpenALPRkeySoPeopleDontMessWithYourShinobi",
|
||||
"mode":"host",
|
||||
"type":"detector"
|
||||
}
|
||||
```
|
||||
|
||||
Now modify the **Main Configuration** file located in the main directory of Shinobi. *Where you currently should be.*
|
||||
|
||||
```
|
||||
nano conf.json
|
||||
```
|
||||
|
||||
Add the `plugins` array if you don't already have it. Add the following *object inside the array*.
|
||||
|
||||
```
|
||||
"plugins":[
|
||||
{
|
||||
"id" : "OpenALPR",
|
||||
"https" : false,
|
||||
"host" : "localhost",
|
||||
"port" : 8082,
|
||||
"key" : "SomeOpenALPRkeySoPeopleDontMessWithYourShinobi",
|
||||
"mode" : "host",
|
||||
"type" : "detector"
|
||||
}
|
||||
],
|
||||
```
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"plug":"OpenALPR",
|
||||
"host":"localhost",
|
||||
"port":8080,
|
||||
"hostPort":8082,
|
||||
"key":"SomeOpenALPRkeySoPeopleDontMessWithYourShinobi",
|
||||
"mode":"client",
|
||||
"type":"detector",
|
||||
"enabled": false
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
|
||||
; Specify the path to the runtime data directory
|
||||
runtime_dir = ${CMAKE_INSTALL_PREFIX}/share/openalpr/runtime_data
|
||||
|
||||
|
||||
ocr_img_size_percent = 1.33333333
|
||||
state_id_img_size_percent = 2.0
|
||||
|
||||
; Calibrating your camera improves detection accuracy in cases where vehicle plates are captured at a steep angle
|
||||
; Use the openalpr-utils-calibrate utility to calibrate your fixed camera to adjust for an angle
|
||||
; Once done, update the prewarp config with the values obtained from the tool
|
||||
prewarp =
|
||||
|
||||
; detection will ignore plates that are too large. This is a good efficiency technique to use if the
|
||||
; plates are going to be a fixed distance away from the camera (e.g., you will never see plates that fill
|
||||
; up the entire image
|
||||
max_plate_width_percent = 100
|
||||
max_plate_height_percent = 100
|
||||
|
||||
; detection_iteration_increase is the percentage that the LBP frame increases each iteration.
|
||||
; It must be greater than 1.0. A value of 1.01 means increase by 1%, 1.10 increases it by 10% each time.
|
||||
; So a 1% increase would be ~10x slower than 10% to process, but it has a higher chance of landing
|
||||
; directly on the plate and getting a strong detection
|
||||
detection_iteration_increase = 1.1
|
||||
|
||||
; The minimum detection strength determines how sure the detection algorithm must be before signaling that
|
||||
; a plate region exists. Technically this corresponds to LBP nearest neighbors (e.g., how many detections
|
||||
; are clustered around the same area). For example, 2 = very lenient, 9 = very strict.
|
||||
detection_strictness = 3
|
||||
|
||||
; The detection doesn't necessarily need an extremely high resolution image in order to detect plates
|
||||
; Using a smaller input image should still find the plates and will do it faster
|
||||
; Tweaking the max_detection_input values will resize the input image if it is larger than these sizes
|
||||
; max_detection_input_width/height are specified in pixels
|
||||
max_detection_input_width = 1280
|
||||
max_detection_input_height = 720
|
||||
|
||||
; detector is the technique used to find license plate regions in an image. Value can be set to
|
||||
; lbpcpu - default LBP-based detector uses the system CPU
|
||||
; lbpgpu - LBP-based detector that uses Nvidia GPU to increase recognition speed.
|
||||
; lbpopencl - LBP-based detector that uses OpenCL GPU to increase recognition speed. Requires OpenCV 3.0
|
||||
; morphcpu - Experimental detector that detects white rectangles in an image. Does not require training.
|
||||
detector = lbpgpu
|
||||
|
||||
; If set to true, all results must match a postprocess text pattern if a pattern is available.
|
||||
; If not, the result is disqualified.
|
||||
must_match_pattern = 0
|
||||
|
||||
; Bypasses plate detection. If this is set to 1, the library assumes that each region provided is a likely plate area.
|
||||
skip_detection = 0
|
||||
|
||||
; Specifies the full path to an image file that constrains the detection area. Only the plate regions allowed through the mask
|
||||
; will be analyzed. The mask image must match the resolution of your image to be analyzed. The mask is black and white.
|
||||
; Black areas will be ignored, white areas will be searched. An empty value means no mask (scan the entire image)
|
||||
detection_mask_image =
|
||||
|
||||
; OpenALPR can scan the same image multiple times with different randomization. Setting this to a value larger than
|
||||
; 1 may increase accuracy, but will increase processing time linearly (e.g., analysis_count = 3 is 3x slower)
|
||||
analysis_count = 1
|
||||
|
||||
; OpenALPR detects high-contrast plate crops and uses an alternative edge detection technique. Setting this to 0.0
|
||||
; would classify ALL images as high-contrast, setting it to 1.0 would classify no images as high-contrast.
|
||||
contrast_detection_threshold = 0.3
|
||||
|
||||
max_plate_angle_degrees = 15
|
||||
|
||||
ocr_min_font_point = 6
|
||||
|
||||
; Minimum OCR confidence percent to consider.
|
||||
postprocess_min_confidence = 65
|
||||
|
||||
; Any OCR character lower than this will also add an equally likely
|
||||
; chance that the character is incorrect and will be skipped. Value is a confidence percent
|
||||
postprocess_confidence_skip_level = 80
|
||||
|
||||
|
||||
debug_general = 0
|
||||
debug_timing = 0
|
||||
debug_detector = 0
|
||||
debug_prewarp = 0
|
||||
debug_state_id = 0
|
||||
debug_plate_lines = 0
|
||||
debug_plate_corners = 0
|
||||
debug_char_segment = 0
|
||||
debug_char_analysis = 0
|
||||
debug_color_filter = 0
|
||||
debug_ocr = 0
|
||||
debug_postprocess = 0
|
||||
debug_show_images = 0
|
||||
debug_pause_on_frame = 0
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"name": "shinobi-openalpr",
|
||||
"version": "1.0.0",
|
||||
"description": "OpenALPR plugin for Shinobi",
|
||||
"main": "shinobi-openalpr.js",
|
||||
"dependencies": {
|
||||
"express": "^4.16.2",
|
||||
"moment": "^2.19.2",
|
||||
"socket.io": "^4.4.1",
|
||||
"socket.io-client": "^4.5.3",
|
||||
"node-openalpr-shinobi": "1.1.4"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Moe Alam",
|
||||
"license": "ISC"
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
//
|
||||
// Shinobi - OpenALPR Plugin
|
||||
// Copyright (C) 2016-2025 Moe Alam, moeiscool
|
||||
//
|
||||
// # Donate
|
||||
//
|
||||
// If you like what I am doing here and want me to continue please consider donating :)
|
||||
// PayPal : paypal@m03.ca
|
||||
//
|
||||
// Base Init >>
|
||||
var fs = require('fs');
|
||||
var config = require('./conf.json')
|
||||
var exec = require('child_process').exec;
|
||||
var openalpr = {
|
||||
us: require ("node-openalpr-shinobi"),
|
||||
eu: require ("node-openalpr-shinobi"),
|
||||
};
|
||||
var s
|
||||
const {
|
||||
workerData
|
||||
} = require('worker_threads');
|
||||
if(workerData && workerData.ok === true){
|
||||
try{
|
||||
s = require('../pluginWorkerBase.js')(__dirname,config)
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
try{
|
||||
s = require('./pluginWorkerBase.js')(__dirname,config)
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
return console.log(config.plug,'WORKER : Plugin start has failed. pluginBase.js was not found.')
|
||||
}
|
||||
}
|
||||
}else{
|
||||
try{
|
||||
s = require('../pluginBase.js')(__dirname,config)
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
try{
|
||||
s = require('./pluginBase.js')(__dirname,config)
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
return console.log(config.plug,'Plugin start has failed. pluginBase.js was not found.')
|
||||
}
|
||||
}
|
||||
}
|
||||
// Base Init />>
|
||||
// OpenALPR Init >>
|
||||
if(config.alprConfig === undefined){
|
||||
config.alprConfig = __dirname + '/openalpr.conf'
|
||||
}
|
||||
Object.keys(openalpr).forEach(function(region){
|
||||
openalpr[region].Start(config.alprConfig, null, null, true, region)
|
||||
})
|
||||
var convertResultsToMatrices = function(results){
|
||||
var mats = []
|
||||
var plates = []
|
||||
results.forEach(function(v){
|
||||
v.candidates.forEach(function(g,n){
|
||||
if(v.candidates[n].matches_template){
|
||||
delete(v.candidates[n].matches_template)
|
||||
}
|
||||
})
|
||||
plates.push({
|
||||
coordinates: v.coordinates,
|
||||
candidates: v.candidates,
|
||||
confidence: v.confidence,
|
||||
plate: v.plate
|
||||
})
|
||||
var width = Math.sqrt( Math.pow(v.coordinates[1].x - v.coordinates[0].x, 2) + Math.pow(v.coordinates[1].y - v.coordinates[0].y, 2));
|
||||
var height = Math.sqrt( Math.pow(v.coordinates[2].x - v.coordinates[1].x, 2) + Math.pow(v.coordinates[2].y - v.coordinates[1].y, 2))
|
||||
mats.push({
|
||||
x: v.coordinates[0].x,
|
||||
y: v.coordinates[0].y,
|
||||
width: width,
|
||||
height: height,
|
||||
tag: v.plate
|
||||
})
|
||||
})
|
||||
return mats
|
||||
}
|
||||
// OpenALPR Init />>
|
||||
s.detectObject = function(buffer,d,tx,frameLocation,callback){
|
||||
try{
|
||||
var region = d.mon.detector_lisence_plate_country || 'us'
|
||||
openalpr[region].IdentifyLicense(buffer, {}, function (error, output){
|
||||
var results = output.results
|
||||
if(results.length > 0){
|
||||
var matrices = convertResultsToMatrices(results)
|
||||
tx({
|
||||
f: 'trigger',
|
||||
id: d.id,
|
||||
ke: d.ke,
|
||||
details: {
|
||||
plug: config.plug,
|
||||
name: 'licensePlate',
|
||||
reason: 'object',
|
||||
matrices: matrices,
|
||||
imgHeight: d.mon.detector_scale_y,
|
||||
imgWidth: d.mon.detector_scale_x,
|
||||
},
|
||||
frame: buffer
|
||||
})
|
||||
}
|
||||
callback()
|
||||
})
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue