Skip to content

Commit e422f5b

Browse files
committed
Updating to OpenALPR 2.2
1 parent 61e44e1 commit e422f5b

18 files changed

+126
-11
lines changed

Diff for: README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ var openalpr = require ("node-openalpr");
4242

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

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

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

8991
#### Windows
9092

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

104106
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
105107
and features requests - we will review them but we do not garunteed that they will be addressed. Pull requests are welcome
106-
and we'll review them as quickly as we can.
108+
and we'll review them as quickly as we can.

Diff for: includes/TRexpp.h

100644100755
File mode changed.

Diff for: includes/alpr.h

100644100755
+14-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
#include <fstream>
2626
#include <stdint.h>
2727

28+
#ifdef WIN32
29+
#define OPENALPR_DLL_EXPORT __declspec( dllexport )
30+
#else
31+
#define OPENALPR_DLL_EXPORT
32+
#endif
33+
2834
namespace alpr
2935
{
3036

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

87+
// The country (training data code) that was used to recognize the plate
88+
std::string country;
89+
8190
// the best plate is the topNPlate with the highest confidence
8291
AlprPlate bestPlate;
8392

@@ -101,10 +110,13 @@ namespace alpr
101110
class AlprResults
102111
{
103112
public:
104-
AlprResults() {};
113+
AlprResults() {
114+
frame_number = -1;
115+
};
105116
virtual ~AlprResults() {};
106117

107118
int64_t epoch_time;
119+
int64_t frame_number;
108120
int img_width;
109121
int img_height;
110122
float total_processing_time_ms;
@@ -118,7 +130,7 @@ namespace alpr
118130

119131
class Config;
120132
class AlprImpl;
121-
class Alpr
133+
class OPENALPR_DLL_EXPORT Alpr
122134
{
123135

124136
public:

Diff for: includes/alpr_impl.h

100644100755
+11-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ namespace alpr
6666
AlprResults results;
6767
};
6868

69+
struct AlprRecognizers
70+
{
71+
Detector* plateDetector;
72+
StateDetector* stateDetector;
73+
OCR* ocr;
74+
};
75+
6976
class AlprImpl
7077
{
7178

@@ -83,6 +90,8 @@ namespace alpr
8390

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

93+
AlprFullDetails analyzeSingleCountry(cv::Mat colorImg, cv::Mat grayImg, std::vector<cv::Rect> regionsOfInterest);
94+
8695
void setDetectRegion(bool detectRegion);
8796
void setTopN(int topn);
8897
void setDefaultRegion(std::string region);
@@ -99,9 +108,8 @@ namespace alpr
99108

100109
private:
101110

102-
Detector* plateDetector;
103-
StateDetector* stateDetector;
104-
OCR* ocr;
111+
std::map<std::string, AlprRecognizers> recognizers;
112+
105113
PreWarp* prewarp;
106114

107115
int topN;

Diff for: includes/binarize_wolf.h

100644100755
File mode changed.

Diff for: includes/cjson.h

100644100755
File mode changed.

Diff for: includes/colorfilter.h

100644100755
File mode changed.

Diff for: includes/config.h

100644100755
+25-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <stdio.h>
2828
#include <iostream>
29+
#include <vector>
2930
#include <stdlib.h> /* getenv */
3031
#include <math.h>
3132

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

4243
bool loaded;
44+
45+
std::string config_file_path;
4346

4447
std::string country;
4548

@@ -54,6 +57,9 @@ namespace alpr
5457

5558
bool skipDetection;
5659

60+
bool auto_invert;
61+
bool always_invert;
62+
5763
std::string prewarp;
5864

5965
int maxPlateAngleDegrees;
@@ -66,10 +72,15 @@ namespace alpr
6672
float plateWidthMM;
6773
float plateHeightMM;
6874

69-
float charHeightMM;
70-
float charWidthMM;
75+
std::vector<float> charHeightMM;
76+
std::vector<float> charWidthMM;
77+
78+
float avgCharHeightMM;
79+
float avgCharWidthMM;
80+
7181
float charWhitespaceTopMM;
7282
float charWhitespaceBotMM;
83+
float charWhitespaceBetweenLinesMM;
7384

7485
int templateWidthPx;
7586
int templateHeightPx;
@@ -88,13 +99,18 @@ namespace alpr
8899
float plateLinesSensitivityVertical;
89100
float plateLinesSensitivityHorizontal;
90101

102+
float segmentationMinSpeckleHeightPercent;
91103
int segmentationMinBoxWidthPx;
92104
float segmentationMinCharHeightPercent;
93105
float segmentationMaxCharWidthvsAverage;
94106

107+
std::string detectorFile;
108+
95109
std::string ocrLanguage;
96110
int ocrMinFontSize;
97111

112+
bool mustMatchPattern;
113+
98114
float postProcessMinConfidence;
99115
float postProcessConfidenceSkipLevel;
100116
unsigned int postProcessMinCharacters;
@@ -127,11 +143,16 @@ namespace alpr
127143

128144
std::string runtimeBaseDir;
129145

146+
std::vector<std::string> loaded_countries;
147+
148+
bool setCountry(std::string country);
149+
130150
private:
131151

132152
float ocrImagePercent;
133153
float stateIdImagePercent;
134154

155+
std::vector<std::string> parse_country_string(std::string countries);
135156

136157
void loadCommonValues(std::string configFile);
137158
void loadCountryValues(std::string configFile, std::string country);
@@ -143,7 +164,8 @@ namespace alpr
143164
{
144165
DETECTOR_LBP_CPU=0,
145166
DETECTOR_LBP_GPU=1,
146-
DETECTOR_MORPH_CPU=2
167+
DETECTOR_MORPH_CPU=2,
168+
DETECTOR_LBP_OPENCL=3
147169
};
148170

149171
}

Diff for: includes/constants.h

100644100755
File mode changed.

Diff for: includes/licenseplatecandidate.h

100644100755
File mode changed.

Diff for: includes/motiondetector.h

100644100755
File mode changed.

Diff for: includes/ocr.h

100644100755
File mode changed.

Diff for: includes/pipeline_data.h

100644100755
+6-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ namespace alpr
5858

5959
ScoreKeeper confidence_weights;
6060

61-
std::vector<cv::Rect> charRegions;
61+
// Boxes around characters in cropped image
62+
// Each row in a multiline plate is an entry in the vector
63+
std::vector<std::vector<cv::Rect> > charRegions;
64+
65+
// Same data, just not broken down by line
66+
std::vector<cv::Rect> charRegionsFlat;
6267

6368

6469

Diff for: includes/prewarp.h

100644100755
File mode changed.

Diff for: includes/result_aggregator.h

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2015 OpenALPR Technology, Inc.
3+
* Open source Automated License Plate Recognition [http://www.openalpr.com]
4+
*
5+
* This file is part of OpenALPR.
6+
*
7+
* OpenALPR is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Affero General Public License
9+
* version 3 as published by the Free Software Foundation
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#ifndef OPENALPR_RESULTAGGREGATOR_H
21+
#define OPENALPR_RESULTAGGREGATOR_H
22+
23+
24+
#include "alpr_impl.h"
25+
26+
27+
// Runs the analysis for multiple training sets, and aggregates the results into the best matches
28+
29+
struct PlateShapeInfo
30+
{
31+
cv::Point2f center;
32+
float area;
33+
int max_width;
34+
int max_height;
35+
};
36+
37+
namespace alpr
38+
{
39+
40+
class ResultAggregator
41+
{
42+
public:
43+
ResultAggregator();
44+
45+
virtual ~ResultAggregator();
46+
47+
void addResults(AlprFullDetails full_results);
48+
49+
AlprFullDetails getAggregateResults();
50+
51+
private:
52+
std::vector<AlprFullDetails> all_results;
53+
54+
PlateShapeInfo getShapeInfo(AlprPlateResult plate);
55+
56+
std::vector<std::vector<AlprPlateResult> > findClusters();
57+
int overlaps(AlprPlateResult plate, std::vector<std::vector<AlprPlateResult> > clusters);
58+
};
59+
60+
}
61+
62+
#endif //OPENALPR_RESULTAGGREGATOR_H

Diff for: includes/transformation.h

100644100755
File mode changed.

Diff for: includes/utility.h

100644100755
+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ namespace alpr
5555
bool isPointBelowLine(cv::Point tp);
5656

5757
float getPointAt(float x);
58+
float getXPointAt(float y);
5859

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

@@ -109,6 +110,9 @@ namespace alpr
109110
std::string toString(float value);
110111
std::string toString(double value);
111112

113+
std::string &ltrim(std::string &s);
114+
std::string &rtrim(std::string &s);
115+
std::string &trim(std::string &s);
112116
}
113117

114118
#endif // OPENALPR_UTILITY_H

Diff for: release/linux_x64/node_openalpr.node

100644100755
-5.83 KB
Binary file not shown.

0 commit comments

Comments
 (0)