Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to OpenALPR 2.2 #8

Merged
merged 1 commit into from
Jan 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ var openalpr = require ("node-openalpr");

function identify (id, path) {
console.log (openalpr.IdentifyLicense (path, function (error, output) {
console.log (id +" "+ output.processing_time_ms);
var results = output.results;
console.log (id +" "+ output.processing_time_ms +" "+ ((results.length > 0) ? results[0].plate : "No results"));

if (id == 349) {
console.log (openalpr.Stop ());
Expand Down Expand Up @@ -85,6 +86,7 @@ This is a breakdown of all of the methods available for node-openalpr. Start nee

0. [Download and install io.js v3.0.0+](https://iojs.org/en/index.html)
0. [Download and install git](https://git-scm.com/downloads)
0. [Download and install cmake](https://cmake.org/download/)

#### Windows

Expand All @@ -103,4 +105,4 @@ This is a breakdown of all of the methods available for node-openalpr. Start nee

All of the code is provided as-is. We will not provide on-going support for any bugs that may be found. Please submit bug
and features requests - we will review them but we do not garunteed that they will be addressed. Pull requests are welcome
and we'll review them as quickly as we can.
and we'll review them as quickly as we can.
Empty file modified includes/TRexpp.h
100644 → 100755
Empty file.
16 changes: 14 additions & 2 deletions includes/alpr.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
#include <fstream>
#include <stdint.h>

#ifdef WIN32
#define OPENALPR_DLL_EXPORT __declspec( dllexport )
#else
#define OPENALPR_DLL_EXPORT
#endif

namespace alpr
{

Expand Down Expand Up @@ -78,6 +84,9 @@ namespace alpr
// The number requested is always >= the topNPlates count
int requested_topn;

// The country (training data code) that was used to recognize the plate
std::string country;

// the best plate is the topNPlate with the highest confidence
AlprPlate bestPlate;

Expand All @@ -101,10 +110,13 @@ namespace alpr
class AlprResults
{
public:
AlprResults() {};
AlprResults() {
frame_number = -1;
};
virtual ~AlprResults() {};

int64_t epoch_time;
int64_t frame_number;
int img_width;
int img_height;
float total_processing_time_ms;
Expand All @@ -118,7 +130,7 @@ namespace alpr

class Config;
class AlprImpl;
class Alpr
class OPENALPR_DLL_EXPORT Alpr
{

public:
Expand Down
14 changes: 11 additions & 3 deletions includes/alpr_impl.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ namespace alpr
AlprResults results;
};

struct AlprRecognizers
{
Detector* plateDetector;
StateDetector* stateDetector;
OCR* ocr;
};

class AlprImpl
{

Expand All @@ -83,6 +90,8 @@ namespace alpr

void applyRegionTemplate(AlprPlateResult* result, std::string region);

AlprFullDetails analyzeSingleCountry(cv::Mat colorImg, cv::Mat grayImg, std::vector<cv::Rect> regionsOfInterest);

void setDetectRegion(bool detectRegion);
void setTopN(int topn);
void setDefaultRegion(std::string region);
Expand All @@ -99,9 +108,8 @@ namespace alpr

private:

Detector* plateDetector;
StateDetector* stateDetector;
OCR* ocr;
std::map<std::string, AlprRecognizers> recognizers;

PreWarp* prewarp;

int topN;
Expand Down
Empty file modified includes/binarize_wolf.h
100644 → 100755
Empty file.
Empty file modified includes/cjson.h
100644 → 100755
Empty file.
Empty file modified includes/colorfilter.h
100644 → 100755
Empty file.
28 changes: 25 additions & 3 deletions includes/config.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <stdio.h>
#include <iostream>
#include <vector>
#include <stdlib.h> /* getenv */
#include <math.h>

Expand All @@ -40,6 +41,8 @@ namespace alpr
virtual ~Config();

bool loaded;

std::string config_file_path;

std::string country;

Expand All @@ -54,6 +57,9 @@ namespace alpr

bool skipDetection;

bool auto_invert;
bool always_invert;

std::string prewarp;

int maxPlateAngleDegrees;
Expand All @@ -66,10 +72,15 @@ namespace alpr
float plateWidthMM;
float plateHeightMM;

float charHeightMM;
float charWidthMM;
std::vector<float> charHeightMM;
std::vector<float> charWidthMM;

float avgCharHeightMM;
float avgCharWidthMM;

float charWhitespaceTopMM;
float charWhitespaceBotMM;
float charWhitespaceBetweenLinesMM;

int templateWidthPx;
int templateHeightPx;
Expand All @@ -88,13 +99,18 @@ namespace alpr
float plateLinesSensitivityVertical;
float plateLinesSensitivityHorizontal;

float segmentationMinSpeckleHeightPercent;
int segmentationMinBoxWidthPx;
float segmentationMinCharHeightPercent;
float segmentationMaxCharWidthvsAverage;

std::string detectorFile;

std::string ocrLanguage;
int ocrMinFontSize;

bool mustMatchPattern;

float postProcessMinConfidence;
float postProcessConfidenceSkipLevel;
unsigned int postProcessMinCharacters;
Expand Down Expand Up @@ -127,11 +143,16 @@ namespace alpr

std::string runtimeBaseDir;

std::vector<std::string> loaded_countries;

bool setCountry(std::string country);

private:

float ocrImagePercent;
float stateIdImagePercent;

std::vector<std::string> parse_country_string(std::string countries);

void loadCommonValues(std::string configFile);
void loadCountryValues(std::string configFile, std::string country);
Expand All @@ -143,7 +164,8 @@ namespace alpr
{
DETECTOR_LBP_CPU=0,
DETECTOR_LBP_GPU=1,
DETECTOR_MORPH_CPU=2
DETECTOR_MORPH_CPU=2,
DETECTOR_LBP_OPENCL=3
};

}
Expand Down
Empty file modified includes/constants.h
100644 → 100755
Empty file.
Empty file modified includes/licenseplatecandidate.h
100644 → 100755
Empty file.
Empty file modified includes/motiondetector.h
100644 → 100755
Empty file.
Empty file modified includes/ocr.h
100644 → 100755
Empty file.
7 changes: 6 additions & 1 deletion includes/pipeline_data.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ namespace alpr

ScoreKeeper confidence_weights;

std::vector<cv::Rect> charRegions;
// Boxes around characters in cropped image
// Each row in a multiline plate is an entry in the vector
std::vector<std::vector<cv::Rect> > charRegions;

// Same data, just not broken down by line
std::vector<cv::Rect> charRegionsFlat;



Expand Down
Empty file modified includes/prewarp.h
100644 → 100755
Empty file.
62 changes: 62 additions & 0 deletions includes/result_aggregator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2015 OpenALPR Technology, Inc.
* Open source Automated License Plate Recognition [http://www.openalpr.com]
*
* This file is part of OpenALPR.
*
* OpenALPR is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License
* version 3 as published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef OPENALPR_RESULTAGGREGATOR_H
#define OPENALPR_RESULTAGGREGATOR_H


#include "alpr_impl.h"


// Runs the analysis for multiple training sets, and aggregates the results into the best matches

struct PlateShapeInfo
{
cv::Point2f center;
float area;
int max_width;
int max_height;
};

namespace alpr
{

class ResultAggregator
{
public:
ResultAggregator();

virtual ~ResultAggregator();

void addResults(AlprFullDetails full_results);

AlprFullDetails getAggregateResults();

private:
std::vector<AlprFullDetails> all_results;

PlateShapeInfo getShapeInfo(AlprPlateResult plate);

std::vector<std::vector<AlprPlateResult> > findClusters();
int overlaps(AlprPlateResult plate, std::vector<std::vector<AlprPlateResult> > clusters);
};

}

#endif //OPENALPR_RESULTAGGREGATOR_H
Empty file modified includes/transformation.h
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions includes/utility.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace alpr
bool isPointBelowLine(cv::Point tp);

float getPointAt(float x);
float getXPointAt(float y);

cv::Point closestPointOnSegmentTo(cv::Point p);

Expand Down Expand Up @@ -109,6 +110,9 @@ namespace alpr
std::string toString(float value);
std::string toString(double value);

std::string &ltrim(std::string &s);
std::string &rtrim(std::string &s);
std::string &trim(std::string &s);
}

#endif // OPENALPR_UTILITY_H
Binary file modified release/linux_x64/node_openalpr.node
100644 → 100755
Binary file not shown.