From 564e0d30879893d603993ff598b0edc6cab3156c Mon Sep 17 00:00:00 2001 From: Philippe Vaucher Date: Mon, 24 Mar 2014 10:21:14 +0100 Subject: [PATCH 1/4] Remove useless empty lines --- src/main.cpp | 8 ----- src/misc_utilities/benchmark.cpp | 11 ------- src/misc_utilities/classifychars.cpp | 8 ----- src/misc_utilities/prepcharsfortraining.cpp | 6 ---- src/misc_utilities/sortstate.cpp | 4 --- src/openalpr/alpr.cpp | 3 -- src/openalpr/alpr.h | 3 -- src/openalpr/alpr_impl.cpp | 3 -- src/openalpr/alpr_impl.h | 3 -- src/openalpr/binarize_wolf.cpp | 6 ---- src/openalpr/binarize_wolf.h | 6 ---- src/openalpr/characteranalysis.cpp | 25 ---------------- src/openalpr/characteranalysis.h | 7 ----- src/openalpr/characterregion.cpp | 3 -- src/openalpr/characterregion.h | 3 -- src/openalpr/charactersegmenter.cpp | 33 --------------------- src/openalpr/charactersegmenter.h | 2 -- src/openalpr/cjson.h | 1 - src/openalpr/colorfilter.cpp | 4 --- src/openalpr/colorfilter.h | 6 ---- src/openalpr/config.cpp | 3 -- src/openalpr/config.h | 4 --- src/openalpr/featurematcher.cpp | 16 ---------- src/openalpr/featurematcher.h | 12 -------- src/openalpr/licenseplatecandidate.cpp | 5 ---- src/openalpr/licenseplatecandidate.h | 5 ---- src/openalpr/ocr.cpp | 4 --- src/openalpr/ocr.h | 9 ------ src/openalpr/platecorners.cpp | 8 ----- src/openalpr/platecorners.h | 2 -- src/openalpr/platelines.cpp | 7 ----- src/openalpr/platelines.h | 4 --- src/openalpr/postprocess.cpp | 16 ---------- src/openalpr/postprocess.h | 7 ----- src/openalpr/regiondetector.cpp | 4 --- src/openalpr/regiondetector.h | 10 ------- src/openalpr/simpleini/simpleini.h | 8 ----- src/openalpr/stateidentifier.cpp | 2 -- src/openalpr/stateidentifier.h | 6 ---- src/openalpr/support/filesystem.h | 3 -- src/openalpr/support/timing.cpp | 5 ---- src/openalpr/support/timing.h | 1 - src/openalpr/support/tinydir.h | 3 -- src/openalpr/support/windows/dirent.h | 6 ---- src/openalpr/utility.cpp | 7 ----- src/openalpr/utility.h | 10 ------- src/openalpr/verticalhistogram.cpp | 8 ----- src/openalpr/verticalhistogram.h | 2 -- 48 files changed, 322 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c51cc32..692abf6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,7 +51,6 @@ int main( int argc, const char** argv ) try { - TCLAP::CmdLine cmd("OpenAlpr Command Line Utility", ' ', OPENALPR_VERSION); TCLAP::UnlabeledValueArg fileArg( "image_file", "Image containing license plates", true, "", "image_file_path" ); @@ -85,7 +84,6 @@ int main( int argc, const char** argv ) templateRegion = templateRegionArg.getValue(); topn = topNArg.getValue(); measureProcessingTime = clockSwitch.getValue(); - } catch (TCLAP::ArgException &e) // catch any exceptions { @@ -157,7 +155,6 @@ int main( int argc, const char** argv ) { std::cerr << "Video file not found: " << filename << std::endl; } - } else if (hasEnding(filename, ".png") || hasEnding(filename, ".jpg") || hasEnding(filename, ".gif")) { @@ -171,7 +168,6 @@ int main( int argc, const char** argv ) { std::cerr << "Image file not found: " << filename << std::endl; } - } else if (DirectoryExists(filename.c_str())) { @@ -195,7 +191,6 @@ int main( int argc, const char** argv ) //cv::waitKey(50); } } - } } else @@ -209,7 +204,6 @@ int main( int argc, const char** argv ) bool detectandshow( Alpr* alpr, cv::Mat frame, std::string region, bool writeJson) { - std::vector buffer; cv::imencode(".bmp", frame, buffer ); @@ -232,7 +226,6 @@ bool detectandshow( Alpr* alpr, cv::Mat frame, std::string region, bool writeJso { std::cout << " - " << results[i].topNPlates[k].characters << "\t confidence: " << results[i].topNPlates[k].overall_confidence << "\t template_match: " << results[i].topNPlates[k].matches_template << std::endl; } - } } @@ -244,5 +237,4 @@ bool detectandshow( Alpr* alpr, cv::Mat frame, std::string region, bool writeJso if (results.size() > 0) return true; return false; - } diff --git a/src/misc_utilities/benchmark.cpp b/src/misc_utilities/benchmark.cpp index bcfe1b9..832e5c6 100644 --- a/src/misc_utilities/benchmark.cpp +++ b/src/misc_utilities/benchmark.cpp @@ -57,7 +57,6 @@ int main( int argc, const char** argv ) benchmarkName = argv[2]; inDir = argv[3]; outDir = argv[4]; - } else { @@ -133,9 +132,7 @@ int main( int argc, const char** argv ) imshow("Current LP", frame); waitKey(5); - } - } delete config; @@ -157,9 +154,7 @@ int main( int argc, const char** argv ) imshow("Current LP", frame); waitKey(5); - } - } } else if (benchmarkName.compare("speed") == 0) @@ -254,9 +249,7 @@ int main( int argc, const char** argv ) } waitKey(5); - } - } cout << endl << "---------------------" << endl; @@ -319,14 +312,11 @@ int main( int argc, const char** argv ) imshow("Current LP", frame); waitKey(5); - } - } outputdatafile.close(); } - } void outputStats(vector datapoints) @@ -341,5 +331,4 @@ void outputStats(vector datapoints) double stdev = std::sqrt(sq_sum / datapoints.size()); cout << "\t" << datapoints.size() << " samples, avg: " << mean << "ms, stdev: " << stdev << endl; - } diff --git a/src/misc_utilities/classifychars.cpp b/src/misc_utilities/classifychars.cpp index c8f2463..8f6aea7 100644 --- a/src/misc_utilities/classifychars.cpp +++ b/src/misc_utilities/classifychars.cpp @@ -66,7 +66,6 @@ vector showCharSelection(Mat image, vector charRegions, string state int main( int argc, const char** argv ) { - string inDir; string outDir; Mat frame; @@ -76,7 +75,6 @@ int main( int argc, const char** argv ) { inDir = argv[1]; outDir = argv[2]; - } else { @@ -227,7 +225,6 @@ int main( int argc, const char** argv ) // Save if (somethingSelected && chardataTagged) { - for (int c = 0; c < charSegmenter.characters.size(); c++) { if (humanInputs[c] == ' ') @@ -253,19 +250,15 @@ int main( int argc, const char** argv ) } waitkey = (char) waitKey(50); - } if (waitkey == 'p') i = i - 2; if (i < -1) i = -1; - } - } } - } void showDashboard(vector images, vector selectedImages, int selectedIndex) @@ -351,7 +344,6 @@ vector showCharSelection(Mat image, vector charRegions, string state if (humanInputs[i] != (char) SPACE_KEY) cout << "Tagged " << state << " char code: '" << humanInputs[i] << "' at char position: " << i << endl; } - } destroyWindow("Character selector"); diff --git a/src/misc_utilities/prepcharsfortraining.cpp b/src/misc_utilities/prepcharsfortraining.cpp index b49ac33..6fbfde7 100644 --- a/src/misc_utilities/prepcharsfortraining.cpp +++ b/src/misc_utilities/prepcharsfortraining.cpp @@ -33,14 +33,12 @@ using namespace cv; // Also creates a box file so Tesseract can recognize it int main( int argc, const char** argv ) { - string inDir; //Check if user specify image to process if(argc == 2) { inDir = argv[1]; - } else { @@ -149,15 +147,11 @@ int main( int argc, const char** argv ) //imshow("characterImg", cropped); waitKey(2); - } - } imwrite("combined.tif", bigTif); ofstream boxFile("combined.box", std::ios::out); boxFile << boxFileOut.str(); - } - } diff --git a/src/misc_utilities/sortstate.cpp b/src/misc_utilities/sortstate.cpp index 36449dd..68770ef 100644 --- a/src/misc_utilities/sortstate.cpp +++ b/src/misc_utilities/sortstate.cpp @@ -40,7 +40,6 @@ bool detectPlate( StateIdentifier* identifier, Mat frame); int main( int argc, const char** argv ) { - string inDir; string outDir; Mat frame; @@ -51,7 +50,6 @@ int main( int argc, const char** argv ) inDir = argv[1]; outDir = argv[2]; outDir = outDir + "/"; - } else { @@ -107,10 +105,8 @@ int main( int argc, const char** argv ) else waitKey(50); } - } } - } bool detectPlate( StateIdentifier* identifier, Mat frame); diff --git a/src/openalpr/alpr.cpp b/src/openalpr/alpr.cpp index be03f49..59f4e8a 100644 --- a/src/openalpr/alpr.cpp +++ b/src/openalpr/alpr.cpp @@ -34,7 +34,6 @@ std::vector Alpr::recognize(std::string filepath) { cv::Mat img = cv::imread(filepath, CV_LOAD_IMAGE_COLOR); return impl->recognize(img); - } std::vector Alpr::recognize(std::vector imageBuffer) @@ -72,9 +71,7 @@ bool Alpr::isLoaded() AlprResult::AlprResult() { - } AlprResult::~AlprResult() { - } diff --git a/src/openalpr/alpr.h b/src/openalpr/alpr.h index 2e69292..1200a51 100644 --- a/src/openalpr/alpr.h +++ b/src/openalpr/alpr.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef ALPR_H #define ALPR_H @@ -60,8 +59,6 @@ class AlprResult std::string region; }; - - class AlprImpl; class Alpr { diff --git a/src/openalpr/alpr_impl.cpp b/src/openalpr/alpr_impl.cpp index 22178f0..cfd69b2 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -32,7 +32,6 @@ AlprImpl::AlprImpl(const std::string country, const std::string runtimeDir) if (config->opencl_enabled) { - cv::ocl::PlatformsInfo platinfo; cv::ocl::getOpenCLPlatforms(platinfo); @@ -155,14 +154,12 @@ std::vector AlprImpl::recognize(cv::Mat img) for (int z = 0; z < 4; z++) line(img, lp.plateCorners[z], lp.plateCorners[(z + 1) % 4], Scalar(255,0,255), 2); } - } else { if (config->debugGeneral) rectangle(img, plateRegions[i], Scalar(0, 0, 255), 2); } - } if (config->debugTiming) diff --git a/src/openalpr/alpr_impl.h b/src/openalpr/alpr_impl.h index a8ce479..41bc61c 100644 --- a/src/openalpr/alpr_impl.h +++ b/src/openalpr/alpr_impl.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef ALPRIMPL_H #define ALPRIMPL_H @@ -35,8 +34,6 @@ #include #include "opencv2/ocl/ocl.hpp" - - #define DEFAULT_TOPN 25 #define DEFAULT_DETECT_REGION false diff --git a/src/openalpr/binarize_wolf.cpp b/src/openalpr/binarize_wolf.cpp index a8bf5bd..23117c9 100644 --- a/src/openalpr/binarize_wolf.cpp +++ b/src/openalpr/binarize_wolf.cpp @@ -40,7 +40,6 @@ float calcLocalStats (Mat &im, Mat &map_m, Mat &map_s, int winx, int winy) { - float m,s,max_s; long sum, sum_sq; uchar foo; @@ -73,7 +72,6 @@ float calcLocalStats (Mat &im, Mat &map_m, Mat &map_s, int winx, int winy) // Shift the window, add and remove new/old values to the histogram for (int i=1 ; i <= im.cols-winx; i++) { - // Remove the left old column and add the right new column for (int wy=0; wy. */ - #ifndef BINARIZEWOLF_H #define BINARIZEWOLF_H @@ -40,17 +39,12 @@ enum NiblackVersion #define BINARIZEWOLF_VERSION "2.3 (February 26th, 2013)" #define BINARIZEWOLF_DEFAULTDR 128 - #define uget(x,y) at(y,x) #define uset(x,y,v) at(y,x)=v; #define fget(x,y) at(y,x) #define fset(x,y,v) at(y,x)=v; - - void NiblackSauvolaWolfJolion (Mat im, Mat output, NiblackVersion version, int winx, int winy, float k); - - #endif // BINARIZEWOLF_H diff --git a/src/openalpr/characteranalysis.cpp b/src/openalpr/characteranalysis.cpp index b9b3c39..3454ca3 100644 --- a/src/openalpr/characteranalysis.cpp +++ b/src/openalpr/characteranalysis.cpp @@ -21,7 +21,6 @@ CharacterAnalysis::CharacterAnalysis(Mat img, Config* config) { - this->config = config; this->hasPlateMask = false; @@ -36,7 +35,6 @@ CharacterAnalysis::CharacterAnalysis(Mat img, Config* config) img_gray = Mat(img.size(), img.type()); img.copyTo(img_gray); } - } CharacterAnalysis::~CharacterAnalysis() @@ -50,7 +48,6 @@ CharacterAnalysis::~CharacterAnalysis() void CharacterAnalysis::analyze() { - thresholds = produceThresholds(img_gray, config); /* @@ -64,7 +61,6 @@ void CharacterAnalysis::analyze() //morphologyEx( mask, mask, MORPH_CLOSE, element ); morphologyEx( thresholds[i], thresholds[i], MORPH_OPEN, element ); //dilate( thresholds[i], thresholds[i], element ); - } */ @@ -129,7 +125,6 @@ void CharacterAnalysis::analyze() int bestFitIndex = -1; for (int i = 0; i < thresholds.size(); i++) { - //vector goodIndices = this->filter(thresholds[i], allContours[i], allHierarchy[i]); //charSegments.push_back(goodIndices); @@ -157,7 +152,6 @@ void CharacterAnalysis::analyze() if (this->config->debugCharAnalysis) { - Mat img_contours(bestThreshold.size(), CV_8U); bestThreshold.copyTo(img_contours); cvtColor(img_contours, img_contours, CV_GRAY2RGB); @@ -201,12 +195,10 @@ void CharacterAnalysis::analyze() this->charBoxBottom = LineSegment(this->charArea[3].x, this->charArea[3].y, this->charArea[2].x, this->charArea[2].y); this->charBoxLeft = LineSegment(this->charArea[3].x, this->charArea[3].y, this->charArea[0].x, this->charArea[0].y); this->charBoxRight = LineSegment(this->charArea[2].x, this->charArea[2].y, this->charArea[1].x, this->charArea[1].y); - } } this->thresholdsInverted = isPlateInverted(); - } int CharacterAnalysis::getGoodIndicesCount(vector goodIndices) @@ -269,7 +261,6 @@ Mat CharacterAnalysis::findOuterBoxMask() lowestArea = boxArea; } } - } if (this->config->debugCharAnalysis) @@ -356,7 +347,6 @@ Mat CharacterAnalysis::findOuterBoxMask() allHierarchy[winningIndex], 0 ); - } if (this->config->debugCharAnalysis) @@ -382,12 +372,10 @@ Mat CharacterAnalysis::findOuterBoxMask() Mat fullMask = Mat::zeros(thresholds[0].size(), CV_8U); bitwise_not(fullMask, fullMask); return fullMask; - } Mat CharacterAnalysis::getCharacterMask() { - Mat charMask = Mat::zeros(bestThreshold.size(), CV_8U); for (int i = 0; i < bestContours.size(); i++) @@ -421,7 +409,6 @@ Mat CharacterAnalysis::getCharacterMask() // Returns a polygon "stripe" across the width of the character region. The lines are voted and the polygon starts at 0 and extends to image width vector CharacterAnalysis::getBestVotedLines(Mat img, vector > contours, vector goodIndices) { - //if (this->debug) // cout << "CharacterAnalysis::getBestVotedLines" << endl; @@ -519,7 +506,6 @@ vector CharacterAnalysis::getBestVotedLines(Mat img, vector int curScore = 0; for (int charidx = 0; charidx < charRegions.size(); charidx++) { - float topYPos = topLines[i].getPointAt(charRegions[charidx].x); float botYPos = bottomLines[i].getPointAt(charRegions[charidx].x); @@ -535,7 +521,6 @@ vector CharacterAnalysis::getBestVotedLines(Mat img, vector //cout << "Slope: " << topslope << " yPos: " << topYPos << endl; //drawAndWait(&tempImg); - } // Tie goes to the one with longer line segments @@ -573,7 +558,6 @@ vector CharacterAnalysis::getBestVotedLines(Mat img, vector bestStripe.push_back(topRight); bestStripe.push_back(bottomRight); bestStripe.push_back(bottomLeft); - } return bestStripe; @@ -624,7 +608,6 @@ vector CharacterAnalysis::filter(Mat img, vector > contours, // Goes through the contours for the plate and picks out possible char segments based on min/max height vector CharacterAnalysis::filterByBoxSize(vector< vector< Point> > contours, vector goodIndices, int minHeightPx, int maxHeightPx) { - float idealAspect=config->charWidthMM / config->charHeightMM; float aspecttolerance=0.25; @@ -645,7 +628,6 @@ vector CharacterAnalysis::filterByBoxSize(vector< vector< Point> > contour //Mat auxRoi(img, mr); if(mr.height >= minHeightPx && mr.height <= maxHeightPx && mr.width > minWidth) { - float charAspect= (float)mr.width/(float)mr.height; if (abs(charAspect - idealAspect) < aspecttolerance) @@ -654,12 +636,10 @@ vector CharacterAnalysis::filterByBoxSize(vector< vector< Point> > contour } return includedIndices; - } vector< bool > CharacterAnalysis::filterContourHoles(vector< vector< Point > > contours, vector< Vec4i > hierarchy, vector< bool > goodIndices) { - vector includedIndices(contours.size()); for (int j = 0; j < contours.size(); j++) includedIndices.push_back(false); @@ -692,7 +672,6 @@ vector< bool > CharacterAnalysis::filterContourHoles(vector< vector< Point > > c // returns a vector of indices corresponding to valid contours vector CharacterAnalysis::filterByParentContour( vector< vector< Point> > contours, vector hierarchy, vector goodIndices) { - vector includedIndices(contours.size()); for (int j = 0; j < contours.size(); j++) includedIndices[j] = false; @@ -725,7 +704,6 @@ vector CharacterAnalysis::filterByParentContour( vector< vector< Point> > { votes[voteIndex] = votes[voteIndex] + 1; } - } // Tally up the votes, pick the winner @@ -816,7 +794,6 @@ vector CharacterAnalysis::filterBetweenLines(Mat img, vector for (int tempContourIdx = 0; tempContourIdx < tempContours.size(); tempContourIdx++) { areaBetweenLines += contourArea(tempContours[tempContourIdx]); - } if (areaBetweenLines / totalArea >= MIN_AREA_PERCENT_WITHIN_LINES) @@ -882,7 +859,6 @@ std::vector< bool > CharacterAnalysis::filterByOuterMask(vector< vector< Point > bool CharacterAnalysis::isPlateInverted() { - Mat charMask = getCharacterMask(); Scalar meanVal = mean(bestThreshold, charMask)[0]; @@ -920,7 +896,6 @@ bool CharacterAnalysis::verifySize(Mat r, float minHeightPx, float maxHeightPx) return true; else return false; - } vector CharacterAnalysis::getCharArea() diff --git a/src/openalpr/characteranalysis.h b/src/openalpr/characteranalysis.h index 4b483b8..be0980b 100644 --- a/src/openalpr/characteranalysis.h +++ b/src/openalpr/characteranalysis.h @@ -17,8 +17,6 @@ * along with this program. If not, see . */ - - #ifndef CHARACTERANALYSIS_H #define CHARACTERANALYSIS_H @@ -30,7 +28,6 @@ using namespace cv; using namespace std; - class CharacterAnalysis { @@ -68,8 +65,6 @@ class CharacterAnalysis Mat getCharacterMask(); - - private: Config* config; @@ -77,7 +72,6 @@ class CharacterAnalysis Mat findOuterBoxMask( ); - bool isPlateInverted(); vector filter(Mat img, vector > contours, vector hierarchy); @@ -95,7 +89,6 @@ class CharacterAnalysis int getGoodIndicesCount(vector goodIndices); - }; #endif // CHARACTERANALYSIS_H diff --git a/src/openalpr/characterregion.cpp b/src/openalpr/characterregion.cpp index 5146d75..f3996b2 100644 --- a/src/openalpr/characterregion.cpp +++ b/src/openalpr/characterregion.cpp @@ -96,7 +96,6 @@ CharacterRegion::CharacterRegion(Mat img, Config* config) if (charAnalysis->linePolygon.size() > 0) { - int confidenceDrainers = 0; int charSegmentCount = charAnalysis->bestCharSegmentsCount; if (charSegmentCount == 1) @@ -114,7 +113,6 @@ CharacterRegion::CharacterRegion(Mat img, Config* config) this->confidence=1; else this->confidence = 100 - confidenceDrainers; - } if (config->debugTiming) @@ -123,7 +121,6 @@ CharacterRegion::CharacterRegion(Mat img, Config* config) getTime(&endTime); cout << "Character Region Time: " << diffclock(startTime, endTime) << "ms." << endl; } - } CharacterRegion::~CharacterRegion() diff --git a/src/openalpr/characterregion.h b/src/openalpr/characterregion.h index 3a43243..e20756a 100644 --- a/src/openalpr/characterregion.h +++ b/src/openalpr/characterregion.h @@ -17,8 +17,6 @@ * along with this program. If not, see . */ - - #ifndef CHARACTERREGION_H #define CHARACTERREGION_H @@ -31,7 +29,6 @@ using namespace cv; using namespace std; - class CharacterRegion { diff --git a/src/openalpr/charactersegmenter.cpp b/src/openalpr/charactersegmenter.cpp index 3eef1de..3b68037 100644 --- a/src/openalpr/charactersegmenter.cpp +++ b/src/openalpr/charactersegmenter.cpp @@ -21,7 +21,6 @@ CharacterSegmenter::CharacterSegmenter(Mat img, bool invertedColors, Config* config) { - this->config = config; this->confidence = 0; @@ -52,7 +51,6 @@ CharacterSegmenter::CharacterSegmenter(Mat img, bool invertedColors, Config* con if (this->config->debugCharSegmenter) { - Mat img_contours(charAnalysis->bestThreshold.size(), CV_8U); charAnalysis->bestThreshold.copyTo(img_contours); cvtColor(img_contours, img_contours, CV_GRAY2RGB); @@ -118,7 +116,6 @@ CharacterSegmenter::CharacterSegmenter(Mat img, bool invertedColors, Config* con vector allBoxes; for (int i = 0; i < charAnalysis->allContours.size(); i++) { - Mat histogramMask = Mat::zeros(charAnalysis->thresholds[i].size(), CV_8U); fillConvexPoly(histogramMask, charAnalysis->linePolygon.data(), charAnalysis->linePolygon.size(), Scalar(255,255,255)); @@ -215,7 +212,6 @@ CharacterSegmenter::CharacterSegmenter(Mat img, bool invertedColors, Config* con if (this->config->debugCharSegmenter) { - Mat imgDash = drawImageDashboard(charAnalysis->thresholds, CV_8U, 3); displayImage(config, "Segmentation after cleaning", imgDash); @@ -257,7 +253,6 @@ vector CharacterSegmenter::getHistogramBoxes(VerticalHistogram histogram, for (int i = 0; i < allBoxes.size(); i++) { - if (allBoxes[i].width >= config->segmentationMinBoxWidthPx && allBoxes[i].width <= MAX_SEGMENT_WIDTH && allBoxes[i].height > MIN_HISTOGRAM_HEIGHT ) { @@ -292,7 +287,6 @@ vector CharacterSegmenter::getHistogramBoxes(VerticalHistogram histogram, charBoxes.push_back(Rect(topLeft, allBoxes[i].br()) ); } } - } return charBoxes; @@ -300,7 +294,6 @@ vector CharacterSegmenter::getHistogramBoxes(VerticalHistogram histogram, vector CharacterSegmenter::getBestCharBoxes(Mat img, vector charBoxes, float avgCharWidth) { - float MAX_SEGMENT_WIDTH = avgCharWidth * 1.55; // This histogram is based on how many char boxes (from ALL of the many thresholded images) are covering each column @@ -410,7 +403,6 @@ vector CharacterSegmenter::getBestCharBoxes(Mat img, vector charBoxe this->imgDbgGeneral.push_back(addLabel(histoImg, "All Histograms")); this->imgDbgGeneral.push_back(addLabel(imgBestBoxes, "Best Boxes")); - } return bestBoxes; @@ -443,7 +435,6 @@ vector CharacterSegmenter::get1DHits(Mat img, int yOffset) onSegment = false; curSegmentLength = 0; } - } return hits; @@ -456,7 +447,6 @@ void CharacterSegmenter::removeSmallContours(vector thresholds, vector thresholds, vector CharacterSegmenter::combineCloseBoxes( vector charBoxes, floa { newCharBoxes.push_back(charBoxes[i]); } - } return newCharBoxes; @@ -577,14 +565,12 @@ void CharacterSegmenter::cleanCharRegions(vector thresholds, vector c tallestContourHeight = r.height; totalArea += contourArea(contours[c]); - } //else if (r.height > tallestContourHeight) //{ // tallestContourIndex = c; // tallestContourHeight = h; //} - } if (totalArea < MIN_CONTOUR_AREA) @@ -612,7 +598,6 @@ void CharacterSegmenter::cleanCharRegions(vector thresholds, vector c } rectangle(thresholds[i], charRegions[j], Scalar(0, 0, 0), -1); } - } Mat closureElement = getStructuringElement( 1, @@ -633,7 +618,6 @@ void CharacterSegmenter::cleanCharRegions(vector thresholds, vector c line(thresholds[i], Point(charRegions[j].x + charRegions[j].width + 1, charRegions[j].y), Point(charRegions[j].x + charRegions[j].width + 1, charRegions[j].y + charRegions[j].height), Scalar(0, 0, 0)); } } - } void CharacterSegmenter::cleanBasedOnColor(vector thresholds, Mat colorMask, vector charRegions) @@ -644,10 +628,8 @@ void CharacterSegmenter::cleanBasedOnColor(vector thresholds, Mat colorMask for (int i = 0; i < thresholds.size(); i++) { - for (int j = 0; j < charRegions.size(); j++) { - Mat boxChar = Mat::zeros(thresholds[i].size(), CV_8U); rectangle(boxChar, charRegions[j], Scalar(255,255,255), CV_FILLED); @@ -687,7 +669,6 @@ void CharacterSegmenter::cleanBasedOnColor(vector thresholds, Mat colorMask } } } - } } @@ -733,7 +714,6 @@ vector CharacterSegmenter::filterMostlyEmptyBoxes(vector thresholds, for (int i = 0; i < thresholds.size(); i++) { - for (int j = 0; j < charRegions.size(); j++) { //float minArea = charRegions[j].area() * MIN_AREA_PERCENT; @@ -755,7 +735,6 @@ vector CharacterSegmenter::filterMostlyEmptyBoxes(vector thresholds, for (int z = 0; z < contours[c].size(); z++) allPointsInBox.push_back(contours[c][z]); - } float height = 0; @@ -772,9 +751,7 @@ vector CharacterSegmenter::filterMostlyEmptyBoxes(vector thresholds, { drawX(imgDbgCleanStages[i], charRegions[j], COLOR_DEBUG_EMPTYFILTER, 3); } - } - } vector newCharRegions; @@ -809,7 +786,6 @@ vector CharacterSegmenter::filterMostlyEmptyBoxes(vector thresholds, drawX(imgDbgCleanStages[z], charRegions[i], COLOR_DEBUG_EMPTYFILTER, 1); } - } } @@ -879,7 +855,6 @@ void CharacterSegmenter::filterEdgeBoxes(vector thresholds, const vector= 0) { - int rowLength = getLongestBlobLengthBetweenLines(rotated, col); if (rowLength > MIN_CONNECTED_EDGE_PIXELS) @@ -894,7 +869,6 @@ void CharacterSegmenter::filterEdgeBoxes(vector thresholds, const vector MIN_CONNECTED_EDGE_PIXELS) @@ -909,7 +883,6 @@ void CharacterSegmenter::filterEdgeBoxes(vector thresholds, const vector thresholds, const vectordebug) { - rectangle(imgDbgCleanStages[i], charRegions[boxidx], COLOR_DEBUG_EDGE, 2); cout << "Edge Filter: threshold " << i << " box " << boxidx << endl; } @@ -1045,12 +1017,10 @@ void CharacterSegmenter::filterEdgeBoxes(vector thresholds, const vector= avgCharHeight * 0.9 && ((tallestContourWidth < config->segmentationMinBoxWidthPx) || (tallestContourArea < avgCharWidth * avgCharHeight * 0.1))) @@ -1162,7 +1130,6 @@ int CharacterSegmenter::isSkinnyLineInsideBox(Mat threshold, Rect box, vector charBoxes) { - Mat mask = Mat::zeros(img_threshold.size(), CV_8U); for (int i = 0; i < charBoxes.size(); i++) rectangle(mask, charBoxes[i], Scalar(255, 255, 255), -1); diff --git a/src/openalpr/charactersegmenter.h b/src/openalpr/charactersegmenter.h index 9baabb9..511a47e 100644 --- a/src/openalpr/charactersegmenter.h +++ b/src/openalpr/charactersegmenter.h @@ -17,8 +17,6 @@ * along with this program. If not, see . */ - - #ifndef CHARACTERSEGMENTER_H #define CHARACTERSEGMENTER_H diff --git a/src/openalpr/cjson.h b/src/openalpr/cjson.h index 4703a6d..177807d 100644 --- a/src/openalpr/cjson.h +++ b/src/openalpr/cjson.h @@ -62,7 +62,6 @@ typedef struct cJSON_Hooks /* Supply malloc, realloc and free functions to cJSON */ extern void cJSON_InitHooks(cJSON_Hooks* hooks); - /* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */ extern cJSON *cJSON_Parse(const char *value); /* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */ diff --git a/src/openalpr/colorfilter.cpp b/src/openalpr/colorfilter.cpp index 5be932e..d123bc4 100644 --- a/src/openalpr/colorfilter.cpp +++ b/src/openalpr/colorfilter.cpp @@ -21,7 +21,6 @@ ColorFilter::ColorFilter(Mat image, Mat characterMask, Config* config) { - timespec startTime; getTime(&startTime); @@ -54,7 +53,6 @@ ColorFilter::ColorFilter(Mat image, Mat characterMask, Config* config) ColorFilter::~ColorFilter() { - } bool ColorFilter::imageIsGrayscale(Mat image) @@ -163,7 +161,6 @@ void ColorFilter::findCharColors() hStdDevs.push_back(stddev[0]); sStdDevs.push_back(stddev[1]); vStdDevs.push_back(stddev[2]); - } if (hMeans.size() == 0) @@ -362,7 +359,6 @@ void ColorFilter::findCharColors() Mat dashboard = drawImageDashboard(debugImagesSet, imgDebugHueOnly.type(), 3); displayImage(config, "Color Filter Images", dashboard); } - } // Goes through an array of values, picks the winner based on the highest percentage of other values that are within the maxValDifference diff --git a/src/openalpr/colorfilter.h b/src/openalpr/colorfilter.h index 694bde4..1e51201 100644 --- a/src/openalpr/colorfilter.h +++ b/src/openalpr/colorfilter.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef COLORFILTER_H #define COLORFILTER_H @@ -31,8 +30,6 @@ using namespace cv; using namespace std; - - class ColorFilter { @@ -42,8 +39,6 @@ class ColorFilter Mat colorMask; - - private: Config* config; @@ -52,7 +47,6 @@ class ColorFilter Mat hsv; Mat charMask; - bool grayscale; void preprocessImage(); diff --git a/src/openalpr/config.cpp b/src/openalpr/config.cpp index f57c42f..f90e4fb 100644 --- a/src/openalpr/config.cpp +++ b/src/openalpr/config.cpp @@ -30,7 +30,6 @@ Config::Config(const std::string country, const std::string runtimeBaseDir) if (runtimeBaseDir.compare("") != 0) { // User has supplied a runtime directory. Use that. - } else if (envRuntimeDir!=NULL) { @@ -69,7 +68,6 @@ Config::~Config() void Config::loadValues(string country) { - opencl_enabled = getBoolean("common", "opencl_enabled", false); maxPlateWidthPercent = getFloat("common", "max_plate_width_percent", 100); maxPlateHeightPercent = getFloat("common", "max_plate_height_percent", 100); @@ -129,7 +127,6 @@ void Config::loadValues(string country) debugOcr = getBoolean("debug", "ocr", false); debugPostProcess = getBoolean("debug", "postprocess", false); debugShowImages = getBoolean("debug", "show_images", false); - } void Config::debugOff() diff --git a/src/openalpr/config.h b/src/openalpr/config.h index 78e6b7e..0c72b27 100644 --- a/src/openalpr/config.h +++ b/src/openalpr/config.h @@ -17,11 +17,9 @@ * along with this program. If not, see . */ - #ifndef CONFIG_H #define CONFIG_H - #include "simpleini/simpleini.h" #include "support/filesystem.h" @@ -89,7 +87,6 @@ class Config int postProcessMinCharacters; int postProcessMaxCharacters; - bool debugGeneral; bool debugTiming; bool debugStateId; @@ -123,5 +120,4 @@ class Config bool getBoolean(string section, string key, bool defaultValue); }; - #endif // CONFIG_H diff --git a/src/openalpr/featurematcher.cpp b/src/openalpr/featurematcher.cpp index 0540262..fa24e24 100644 --- a/src/openalpr/featurematcher.cpp +++ b/src/openalpr/featurematcher.cpp @@ -45,7 +45,6 @@ FeatureMatcher::~FeatureMatcher() descriptorMatcher.release(); detector.release(); extractor.release(); - } bool FeatureMatcher::isLoaded() @@ -78,7 +77,6 @@ void FeatureMatcher::surfStyleMatching( const Mat& queryDescriptors, vector > matchesKnn, vector& matches12) { - //objectMatches.clear(); //objectMatches.resize(objectIds.size()); //cout << "starting matcher" << matchesKnn.size() << endl; @@ -90,7 +88,6 @@ void FeatureMatcher::_surfStyleMatching(const Mat& queryDescriptors, vector 1) { - // Next throw out matches with a crappy score // Ignore... already handled by the radiusMatch //if (matchesKnn[descInd][0].distance < MAX_DISTANCE_TO_MATCH) @@ -140,19 +137,15 @@ void FeatureMatcher::_surfStyleMatching(const Mat& queryDescriptors, vector queryKeypoints, const vector inputMatches, vector &outputMatches) { - Rect crissCrossAreaVertical(0, 0, config->stateIdImageWidthPx, config->stateIdimageHeightPx * 2); Rect crissCrossAreaHorizontal(0, 0, config->stateIdImageWidthPx * 2, config->stateIdimageHeightPx); @@ -222,7 +215,6 @@ void FeatureMatcher::crisscrossFiltering(const vector queryKeypoints, hlines.erase(hlines.begin() + mostIntersectionsIndex); matchIdx.erase(matchIdx.begin() + mostIntersectionsIndex); } - } // Push the non-crisscrosses back on the list @@ -231,7 +223,6 @@ void FeatureMatcher::crisscrossFiltering(const vector queryKeypoints, outputMatches.push_back(matchesForOnePlate[matchIdx[j]]); } } - } // Returns true if successful, false otherwise @@ -276,7 +267,6 @@ bool FeatureMatcher::loadRecognitionSet(string country) trainImages.push_back(descriptors); trainingImgKeypoints.push_back(keypoints); } - } this->descriptorMatcher->add(trainImages); @@ -286,7 +276,6 @@ bool FeatureMatcher::loadRecognitionSet(string country) } return false; - } RecognitionResult FeatureMatcher::recognize( const Mat& queryImg, bool drawOnImage, Mat* outputImage, @@ -376,7 +365,6 @@ RecognitionResult FeatureMatcher::recognize( const Mat& queryImg, bool drawOnIma if (result.haswinner == true) { - std::ostringstream out; out << result.winner << " (" << result.confidence << "%)"; @@ -384,19 +372,15 @@ RecognitionResult FeatureMatcher::recognize( const Mat& queryImg, bool drawOnIma //putText(*outputImage, out.str(), Point(15, 27), FONT_HERSHEY_DUPLEX, 1.1, CV_RGB(0, 0, 0), 2); } } - } if (this->config->debugStateId) { - for (int i = 0; i < billMapping.size(); i++) { cout << billMapping[i] << " : " << bill_match_counts[i] << endl; } - } return result; - } diff --git a/src/openalpr/featurematcher.h b/src/openalpr/featurematcher.h index a5d101f..1af3b92 100644 --- a/src/openalpr/featurematcher.h +++ b/src/openalpr/featurematcher.h @@ -17,9 +17,6 @@ * along with this program. If not, see . */ - - - #ifndef FEATUREMATCHER_H #define FEATUREMATCHER_H @@ -36,8 +33,6 @@ using namespace cv; using namespace std; - - struct RecognitionResult { bool haswinner; @@ -52,12 +47,9 @@ class FeatureMatcher FeatureMatcher(Config* config); virtual ~FeatureMatcher(); - - RecognitionResult recognize( const Mat& queryImg, bool drawOnImage, Mat* outputImage, bool debug_on, vector debug_matches_array ); - bool loadRecognitionSet(string country); bool isLoaded(); @@ -71,18 +63,14 @@ class FeatureMatcher Ptr detector; Ptr extractor; - vector > trainingImgKeypoints; - void _surfStyleMatching(const Mat& queryDescriptors, vector > matchesKnn, vector& matches12); void crisscrossFiltering(const vector queryKeypoints, const vector inputMatches, vector &outputMatches); vector billMapping; - - void surfStyleMatching( const Mat& queryDescriptors, vector queryKeypoints, vector& matches12 ); diff --git a/src/openalpr/licenseplatecandidate.cpp b/src/openalpr/licenseplatecandidate.cpp index 08831ea..6666d93 100644 --- a/src/openalpr/licenseplatecandidate.cpp +++ b/src/openalpr/licenseplatecandidate.cpp @@ -54,7 +54,6 @@ void LicensePlateCandidate::recognize() if (charRegion.confidence > 10) { - PlateLines plateLines(config); //Mat boogedy = charRegion.getPlateMask(); @@ -76,11 +75,9 @@ void LicensePlateCandidate::recognize() //strcpy(this->recognizedText, ocr.recognizedText); this->confidence = 100; - } charRegion.confidence = 0; } - } // Re-maps the coordinates from the smallImage to the coordinate space of the bigImage. @@ -103,7 +100,6 @@ vector LicensePlateCandidate::transformPointsToOriginalImage(Mat bigIma Mat LicensePlateCandidate::deSkewPlate(Mat inputImage, vector corners) { - // Figure out the appoximate width/height of the license plate region, so we can maintain the aspect ratio. LineSegment leftEdge(round(corners[3].x), round(corners[3].y), round(corners[0].x), round(corners[0].y)); LineSegment rightEdge(round(corners[2].x), round(corners[2].y), round(corners[1].x), round(corners[1].y)); @@ -179,5 +175,4 @@ void LicensePlateCandidate::cleanupColors(Mat inputImage, Mat outputImage) { displayImage(config, "After cleanup", outputImage); } - } diff --git a/src/openalpr/licenseplatecandidate.h b/src/openalpr/licenseplatecandidate.h index 04ab72a..5d5c15f 100644 --- a/src/openalpr/licenseplatecandidate.h +++ b/src/openalpr/licenseplatecandidate.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef STAGE2_H #define STAGE2_H @@ -39,8 +38,6 @@ using namespace std; using namespace cv; - - //vector getCharacterRegions(Mat frame, vector regionsOfInterest); //vector getCharSegmentsBetweenLines(Mat img, vector > contours, LineSegment top, LineSegment bottom); @@ -64,7 +61,6 @@ class LicensePlateCandidate Config* config; - Mat frame; Rect plateRegion; @@ -77,5 +73,4 @@ class LicensePlateCandidate }; - #endif // STAGE2_H diff --git a/src/openalpr/ocr.cpp b/src/openalpr/ocr.cpp index 2be8c85..e665f96 100644 --- a/src/openalpr/ocr.cpp +++ b/src/openalpr/ocr.cpp @@ -48,7 +48,6 @@ OCR::~OCR() void OCR::performOCR(vector thresholds, vector charRegions) { - timespec startTime; getTime(&startTime); @@ -56,7 +55,6 @@ void OCR::performOCR(vector thresholds, vector charRegions) for (int i = 0; i < thresholds.size(); i++) { - // Make it black text on white background bitwise_not(thresholds[i], thresholds[i]); tesseract->SetImage((uchar*) thresholds[i].data, thresholds[i].size().width, thresholds[i].size().height, thresholds[i].channels(), thresholds[i].step1()); @@ -117,7 +115,6 @@ void OCR::performOCR(vector thresholds, vector charRegions) delete ri; } - } if (config->debugTiming) @@ -126,5 +123,4 @@ void OCR::performOCR(vector thresholds, vector charRegions) getTime(&endTime); cout << "OCR Time: " << diffclock(startTime, endTime) << "ms." << endl; } - } diff --git a/src/openalpr/ocr.h b/src/openalpr/ocr.h index 119d7be..ea61657 100644 --- a/src/openalpr/ocr.h +++ b/src/openalpr/ocr.h @@ -17,9 +17,6 @@ * along with this program. If not, see . */ - - - #ifndef OCR_H #define OCR_H @@ -38,7 +35,6 @@ using namespace tesseract; using namespace std; using namespace cv; - class OCR { @@ -53,16 +49,11 @@ class OCR //float confidence; //float overallConfidence; - private: Config* config; TessBaseAPI *tesseract; - - }; - - #endif // OCR_H diff --git a/src/openalpr/platecorners.cpp b/src/openalpr/platecorners.cpp index 68a91f9..d2c0e05 100644 --- a/src/openalpr/platecorners.cpp +++ b/src/openalpr/platecorners.cpp @@ -47,7 +47,6 @@ PlateCorners::PlateCorners(Mat inputImage, PlateLines* plateLines, CharacterRegi PlateCorners::~PlateCorners() { - } vector PlateCorners::findPlateCorners() @@ -69,7 +68,6 @@ vector PlateCorners::findPlateCorners() if (h1 == h2 && h1 != NO_LINE) continue; this->scoreHorizontals(h1, h2); - } } @@ -86,7 +84,6 @@ vector PlateCorners::findPlateCorners() if (this->config->debugPlateCorners) { - cout << "Drawing debug stuff..." << endl; Mat imgCorners = Mat(inputImage.size(), inputImage.type()); @@ -100,7 +97,6 @@ vector PlateCorners::findPlateCorners() line(imgCorners, this->bestLeft.p1, this->bestLeft.p2, Scalar(255, 0, 0), 1, CV_AA); displayImage(config, "Winning top/bottom Boundaries", imgCorners); - } // Check if a left/right edge has been established. @@ -129,7 +125,6 @@ vector PlateCorners::findPlateCorners() void PlateCorners::scoreVerticals(int v1, int v2) { - float score = 0; // Lower is better LineSegment left; @@ -237,13 +232,11 @@ void PlateCorners::scoreVerticals(int v1, int v2) bestLeft = LineSegment(left.p1.x, left.p1.y, left.p2.x, left.p2.y); bestRight = LineSegment(right.p1.x, right.p1.y, right.p2.x, right.p2.y); } - } // Score a collection of lines as a possible license plate region. // If any segments are missing, extrapolate the missing pieces void PlateCorners::scoreHorizontals(int h1, int h2) { - //if (this->debug) // cout << "PlateCorners::scorePlate" << endl; @@ -400,5 +393,4 @@ void PlateCorners::scoreHorizontals(int h1, int h2) bestTop = LineSegment(top.p1.x, top.p1.y, top.p2.x, top.p2.y); bestBottom = LineSegment(bottom.p1.x, bottom.p1.y, bottom.p2.x, bottom.p2.y); } - } diff --git a/src/openalpr/platecorners.h b/src/openalpr/platecorners.h index ff068cf..ce5ddf9 100644 --- a/src/openalpr/platecorners.h +++ b/src/openalpr/platecorners.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef PLATECORNERS_H #define PLATECORNERS_H @@ -32,7 +31,6 @@ using namespace std; #define NO_LINE -1 - #define SCORING_MISSING_SEGMENT_PENALTY_VERTICAL 10 #define SCORING_MISSING_SEGMENT_PENALTY_HORIZONTAL 15 diff --git a/src/openalpr/platelines.cpp b/src/openalpr/platelines.cpp index 9235d61..b264481 100644 --- a/src/openalpr/platelines.cpp +++ b/src/openalpr/platelines.cpp @@ -26,12 +26,10 @@ PlateLines::PlateLines(Config* config) if (debug) cout << "PlateLines constructor" << endl; - } PlateLines::~PlateLines() { - } void PlateLines::processImage(Mat inputImage, float sensitivity) @@ -150,13 +148,11 @@ void PlateLines::processImage(Mat inputImage, float sensitivity) //minEnclosingCircle( (Mat)contours_poly[i], center[i], radius[i] ); } */ - } /* vector PlateLines::getLines(Mat edges, bool vertical) { - vector filteredLines; int sensitivity; @@ -169,7 +165,6 @@ vector PlateLines::getLines(Mat edges, bool vertical) for( size_t i = 0; i < lsegs.size(); i++ ) { - if (vertical) { LineSegment candidate; @@ -213,7 +208,6 @@ vector PlateLines::getLines(Mat edges, bool vertical) for( size_t i = 0; i < filteredLines.size(); i++ ) { - line( debugImg, filteredLines[i].p1, filteredLines[i].p2, Scalar(0,0,255), 1, CV_AA); } if (vertical) @@ -281,7 +275,6 @@ vector PlateLines::getLines(Mat edges, float sensitivityMultiplier, } else { - if ( (angle > 70 && angle < 110) || (angle > 250 && angle < 290)) { // good horizontal diff --git a/src/openalpr/platelines.h b/src/openalpr/platelines.h index 51cdbaf..49594a0 100644 --- a/src/openalpr/platelines.h +++ b/src/openalpr/platelines.h @@ -17,8 +17,6 @@ * along with this program. If not, see . */ - - #ifndef PLATELINES_H #define PLATELINES_H @@ -31,7 +29,6 @@ using namespace cv; using namespace std; - class PlateLines { @@ -50,7 +47,6 @@ class PlateLines Config* config; bool debug; - Mat customGrayscaleConversion(Mat src); void findLines(Mat inputImage); vector getLines(Mat edges, float sensitivityMultiplier, bool vertical); diff --git a/src/openalpr/postprocess.cpp b/src/openalpr/postprocess.cpp index bc18921..204c6e0 100644 --- a/src/openalpr/postprocess.cpp +++ b/src/openalpr/postprocess.cpp @@ -51,7 +51,6 @@ PostProcess::PostProcess(Config* config) //vector test = rules["base"]; //for (int i = 0; i < test.size(); i++) // cout << "Rule: " << test[i].regex << endl; - } PostProcess::~PostProcess() @@ -65,7 +64,6 @@ PostProcess::~PostProcess() { delete iter->second[i]; } - } } @@ -86,12 +84,10 @@ void PostProcess::addLetter(char letter, int charposition, float score) //{ // insertLetter('O', charposition, score - 0.5); //} - } void PostProcess::insertLetter(char letter, int charposition, float score) { - score = score - config->postProcessMinConfidence; int existingIndex = -1; @@ -128,7 +124,6 @@ void PostProcess::insertLetter(char letter, int charposition, float score) letters[charposition][existingIndex].occurences = letters[charposition][existingIndex].occurences + 1; letters[charposition][existingIndex].totalscore = letters[charposition][existingIndex].totalscore + score; } - } void PostProcess::clear() @@ -149,7 +144,6 @@ void PostProcess::clear() } void PostProcess::analyze(string templateregion, int topn) { - timespec startTime; getTime(&startTime); @@ -174,14 +168,12 @@ void PostProcess::analyze(string templateregion, int topn) if (this->config->debugPostProcess) { - // Print all letters for (int i = 0; i < letters.size(); i++) { for (int j = 0; j < letters[i].size(); j++) cout << "PostProcess Letter: " << letters[i][j].charposition << " " << letters[i][j].letter << " -- score: " << letters[i][j].totalscore << " -- occurences: " << letters[i][j].occurences << endl; } - } // Prune the letters based on the topN value. @@ -270,12 +262,10 @@ void PostProcess::analyze(string templateregion, int topn) { allPossibilities[i].totalscore = maxPercentScore * (allPossibilities[i].totalscore / highestRelativeScore); } - } if (this->config->debugPostProcess) { - // Print top words for (int i = 0; i < allPossibilities.size(); i++) { @@ -335,7 +325,6 @@ float PostProcess::calculateMaxConfidenceScore() // Y-95 Z-90 vector PostProcess::getMaxDepth(int topn) { - vector depth; for (int i = 0; i < letters.size(); i++) depth.push_back(0); @@ -394,14 +383,12 @@ const vector PostProcess::getResults() void PostProcess::findAllPermutations(vector prevletters, int charPos, int substitutionsLeft) { - if (substitutionsLeft < 0) return; // Add my letter to the chain and recurse for (int i = 0; i < letters[charPos].size(); i++) { - if (charPos == letters.size() - 1) { // Last letter, add the word @@ -442,7 +429,6 @@ void PostProcess::findAllPermutations(vector prevletters, int charPos, i // Just pass it along findAllPermutations(prevletters, charPos + 1, substitutionsLeft); } - } bool wordCompare( const PPResult &left, const PPResult &right ) @@ -450,7 +436,6 @@ bool wordCompare( const PPResult &left, const PPResult &right ) if (left.totalscore < right.totalscore) return false; return true; - } bool letterCompare( const Letter &left, const Letter &right ) @@ -476,7 +461,6 @@ RegexRule::RegexRule(string region, string pattern) i++; } this->regex = this->regex + ']'; - } else if (pattern.at(i) == '?') { diff --git a/src/openalpr/postprocess.h b/src/openalpr/postprocess.h index 446f5f1..babc12a 100644 --- a/src/openalpr/postprocess.h +++ b/src/openalpr/postprocess.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef POSTPROCESS_H #define POSTPROCESS_H @@ -32,7 +31,6 @@ using namespace std; - #define SKIP_CHAR '~' struct Letter @@ -50,17 +48,14 @@ struct PPResult bool matchesTemplate; }; - bool wordCompare( const PPResult &left, const PPResult &right ); bool letterCompare( const Letter &left, const Letter &right ); - class RegexRule { public: RegexRule(string region, string pattern); - bool match(string text); string filterSkips(string text); @@ -73,7 +68,6 @@ class RegexRule vector skipPositions; }; - class PostProcess { public: @@ -104,7 +98,6 @@ class PostProcess vector > letters; vector unknownCharPositions; - vector allPossibilities; // Functions used to prune the list of letters (based on topn) to improve performance diff --git a/src/openalpr/regiondetector.cpp b/src/openalpr/regiondetector.cpp index 3f8f061..5dd2505 100644 --- a/src/openalpr/regiondetector.cpp +++ b/src/openalpr/regiondetector.cpp @@ -44,7 +44,6 @@ RegionDetector::RegionDetector(Config* config) this->loaded = false; printf("--(!)Error loading classifier\n"); } - } RegionDetector::~RegionDetector() @@ -59,7 +58,6 @@ bool RegionDetector::isLoaded() vector RegionDetector::detect(Mat frame) { - Mat frame_gray; cvtColor( frame, frame_gray, CV_BGR2GRAY ); @@ -94,7 +92,6 @@ vector RegionDetector::doCascade(Mat frame) } else { - plate_cascade->detectMultiScale( frame, plates, 1.1, 3, 0, //0|CV_HAAR_SCALE_IMAGE, @@ -117,5 +114,4 @@ vector RegionDetector::doCascade(Mat frame) } return plates; - } diff --git a/src/openalpr/regiondetector.h b/src/openalpr/regiondetector.h index 45b0242..c0d63c2 100644 --- a/src/openalpr/regiondetector.h +++ b/src/openalpr/regiondetector.h @@ -17,9 +17,6 @@ * along with this program. If not, see . */ - - - #ifndef REGIONDETECTOR_H #define REGIONDETECTOR_H @@ -36,10 +33,6 @@ #include "support/timing.h" #include "constants.h" - - - - class RegionDetector { @@ -62,7 +55,4 @@ class RegionDetector }; - - - #endif // REGIONDETECTOR_H diff --git a/src/openalpr/simpleini/simpleini.h b/src/openalpr/simpleini/simpleini.h index 25cf2bf..160d53d 100644 --- a/src/openalpr/simpleini/simpleini.h +++ b/src/openalpr/simpleini/simpleini.h @@ -16,7 +16,6 @@ Windows and Linux/Unix. It is fast, simple and source code using this component will compile unchanged on either OS. - @section features FEATURES - MIT Licence allows free use in all software (including GPL and commercial) @@ -44,7 +43,6 @@ - Windows/VC 2005 (warning level 4) - Linux/gcc (-Wall) - @section usage USAGE SUMMARY -# Define the appropriate symbol for the converter you wish to use and @@ -267,7 +265,6 @@ enum SI_Error # define SI_WCHAR_T UChar #endif - // --------------------------------------------------------------------------- // MAIN TEMPLATE CLASS // --------------------------------------------------------------------------- @@ -1226,7 +1223,6 @@ class CSimpleIniTempl return (ch == ';' || ch == '#'); } - /** Skip over a newline character (or characters) for either DOS or UNIX */ inline void SkipNewLine(SI_CHAR *& a_pData) const { @@ -2881,7 +2877,6 @@ class SI_ConvertA } }; - // --------------------------------------------------------------------------- // SI_CONVERT_GENERIC // --------------------------------------------------------------------------- @@ -3103,7 +3098,6 @@ class SI_ConvertW #endif // SI_CONVERT_GENERIC - // --------------------------------------------------------------------------- // SI_CONVERT_ICU // --------------------------------------------------------------------------- @@ -3299,7 +3293,6 @@ class SI_ConvertW #endif // SI_CONVERT_ICU - // --------------------------------------------------------------------------- // SI_CONVERT_WIN32 // --------------------------------------------------------------------------- @@ -3475,7 +3468,6 @@ class SI_ConvertW #endif // SI_CONVERT_WIN32 - // --------------------------------------------------------------------------- // TYPE DEFINITIONS // --------------------------------------------------------------------------- diff --git a/src/openalpr/stateidentifier.cpp b/src/openalpr/stateidentifier.cpp index c32a536..ee54326 100644 --- a/src/openalpr/stateidentifier.cpp +++ b/src/openalpr/stateidentifier.cpp @@ -49,7 +49,6 @@ int StateIdentifier::recognize(Mat img, Rect frame, char* stateCode) // with the value of the country/state int StateIdentifier::recognize(Mat img, char* stateCode) { - timespec startTime; getTime(&startTime); @@ -69,7 +68,6 @@ int StateIdentifier::recognize(Mat img, char* stateCode) if (this->config->debugStateId) { - displayImage(config, "State Identifier1", plateImg); displayImage(config, "State Identifier", debugImg); cout << result.haswinner << " : " << result.confidence << " : " << result.winner << endl; diff --git a/src/openalpr/stateidentifier.h b/src/openalpr/stateidentifier.h index e991ca6..d12597d 100644 --- a/src/openalpr/stateidentifier.h +++ b/src/openalpr/stateidentifier.h @@ -17,8 +17,6 @@ * along with this program. If not, see . */ - - #ifndef STATEIDENTIFIER_H #define STATEIDENTIFIER_H @@ -28,8 +26,6 @@ #include "utility.h" #include "config.h" - - class StateIdentifier { @@ -45,10 +41,8 @@ class StateIdentifier protected: Config* config; - private: - FeatureMatcher* featureMatcher; }; diff --git a/src/openalpr/support/filesystem.h b/src/openalpr/support/filesystem.h index 9bff48f..e519956 100644 --- a/src/openalpr/support/filesystem.h +++ b/src/openalpr/support/filesystem.h @@ -2,7 +2,6 @@ #ifndef FILESYSTEM_H #define FILESYSTEM_H - #ifdef WINDOWS #include "windows/dirent.h" #include "windows/utils.h" @@ -18,7 +17,6 @@ #include #include - bool hasEnding (std::string const &fullString, std::string const &ending); bool DirectoryExists( const char* pzPath ); bool fileExists( const char* pzPath ); @@ -26,5 +24,4 @@ std::vector getFilesInDir(const char* dirPath); bool stringCompare( const std::string &left, const std::string &right ); - #endif // FILESYSTEM_H diff --git a/src/openalpr/support/timing.cpp b/src/openalpr/support/timing.cpp index dbf1c7a..7d5e2a1 100644 --- a/src/openalpr/support/timing.cpp +++ b/src/openalpr/support/timing.cpp @@ -71,7 +71,6 @@ int clock_gettime(int X, timespec *tv) void getTime(timespec* time) { clock_gettime(0, time); - } double diffclock(timespec time1,timespec time2) { @@ -101,7 +100,6 @@ timespec diff(timespec start, timespec end) void getTime(timespec* time) { - #ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time clock_serv_t cclock; mach_timespec_t mts; @@ -113,16 +111,13 @@ void getTime(timespec* time) #else clock_gettime(CLOCK_PROCESS_CPUTIME_ID, time); #endif - } double diffclock(timespec time1,timespec time2) { - timespec delta = diff(time1,time2); double milliseconds = (delta.tv_sec * 1000) + (((double) delta.tv_nsec) / 1000000.0); return milliseconds; - } timespec diff(timespec start, timespec end) diff --git a/src/openalpr/support/timing.h b/src/openalpr/support/timing.h index 843629e..7eb506a 100644 --- a/src/openalpr/support/timing.h +++ b/src/openalpr/support/timing.h @@ -19,5 +19,4 @@ void getTime(timespec* time); double diffclock(timespec time1,timespec time2); - #endif diff --git a/src/openalpr/support/tinydir.h b/src/openalpr/support/tinydir.h index 1f0d26c..7239f7b 100644 --- a/src/openalpr/support/tinydir.h +++ b/src/openalpr/support/tinydir.h @@ -37,7 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif - /* types */ #define _TINYDIR_PATH_MAX 4096 @@ -88,7 +87,6 @@ typedef struct #endif } tinydir_dir; - /* declarations */ _TINYDIR_FUNC @@ -110,7 +108,6 @@ int tinydir_open_subdir_n(tinydir_dir *dir, int i); _TINYDIR_FUNC int _tinydir_file_cmp(const void *a, const void *b); - /* definitions*/ _TINYDIR_FUNC diff --git a/src/openalpr/support/windows/dirent.h b/src/openalpr/support/windows/dirent.h index d434ec9..92adcd1 100644 --- a/src/openalpr/support/windows/dirent.h +++ b/src/openalpr/support/windows/dirent.h @@ -212,12 +212,10 @@ /* Return number of bytes needed to store d_namlen */ #define _D_ALLOC_NAMLEN(p) (PATH_MAX + 1) - #ifdef __cplusplus extern "C" { #endif - /* Wide-character version */ struct _wdirent { @@ -244,7 +242,6 @@ static struct _wdirent *_wreaddir (_WDIR *dirp); static int _wclosedir (_WDIR *dirp); static void _wrewinddir (_WDIR* dirp); - /* For compatibility with Symbian */ #define wdirent _wdirent #define WDIR _WDIR @@ -253,7 +250,6 @@ static void _wrewinddir (_WDIR* dirp); #define wclosedir _wclosedir #define wrewinddir _wrewinddir - /* Multi-byte character versions */ struct dirent { @@ -277,7 +273,6 @@ static struct dirent *readdir (DIR *dirp); static int closedir (DIR *dirp); static void rewinddir (DIR* dirp); - /* Internal utility functions */ static WIN32_FIND_DATAW *dirent_first (_WDIR *dirp); static WIN32_FIND_DATAW *dirent_next (_WDIR *dirp); @@ -873,7 +868,6 @@ dirent_set_errno( #endif } - #ifdef __cplusplus } #endif diff --git a/src/openalpr/utility.cpp b/src/openalpr/utility.cpp index 96b0323..f3ec573 100644 --- a/src/openalpr/utility.cpp +++ b/src/openalpr/utility.cpp @@ -155,7 +155,6 @@ vector produceThresholds(const Mat img_gray, Config* config) return thresholds; //threshold(img_equalized, img_threshold, 100, 255, THRESH_BINARY); - } double median(int array[], int arraySize) @@ -172,7 +171,6 @@ double median(int array[], int arraySize) Mat equalizeBrightness(Mat img) { - // Divide the image by its morphologically closed counterpart Mat kernel = getStructuringElement(MORPH_ELLIPSE, Size(19,19)); Mat closed; @@ -188,12 +186,10 @@ Mat equalizeBrightness(Mat img) void drawRotatedRect(Mat* img, RotatedRect rect, Scalar color, int thickness) { - Point2f rect_points[4]; rect.points( rect_points ); for( int j = 0; j < 4; j++ ) line( *img, rect_points[j], rect_points[(j+1)%4], color, thickness, 8 ); - } void fillMask(Mat img, const Mat mask, Scalar color) @@ -212,7 +208,6 @@ void fillMask(Mat img, const Mat mask, Scalar color) img.at(row, col)[z] = ((int) color[z]) | prevVal; } } - } } } @@ -339,11 +334,9 @@ Point LineSegment::intersection(LineSegment line) { intersection_X = (c2 - c1) / (slope - line.slope); intersection_Y = slope * intersection_X + c1; - } return Point(intersection_X, intersection_Y); - } Point LineSegment::midpoint() diff --git a/src/openalpr/utility.h b/src/openalpr/utility.h index 74b8037..c7021ca 100644 --- a/src/openalpr/utility.h +++ b/src/openalpr/utility.h @@ -17,15 +17,9 @@ * along with this program. If not, see . */ - - - #ifndef UTILITY_H #define UTILITY_H - - - #include #include #include @@ -39,8 +33,6 @@ #include #include "config.h" - - /* struct LineSegment { @@ -51,7 +43,6 @@ struct LineSegment }; */ - class LineSegment { @@ -87,7 +78,6 @@ class LineSegment return ss.str() ; } - }; double median(int array[], int arraySize); diff --git a/src/openalpr/verticalhistogram.cpp b/src/openalpr/verticalhistogram.cpp index a125fac..010531a 100644 --- a/src/openalpr/verticalhistogram.cpp +++ b/src/openalpr/verticalhistogram.cpp @@ -22,7 +22,6 @@ VerticalHistogram::VerticalHistogram(Mat inputImage, Mat mask) { analyzeImage(inputImage, mask); - } VerticalHistogram::~VerticalHistogram() @@ -46,7 +45,6 @@ void VerticalHistogram::analyzeImage(Mat inputImage, Mat mask) for (int row = 0; row < inputImage.rows; row++) { - if (inputImage.at(row, col) > 0 && mask.at(row, col) > 0) columnCount++; } @@ -60,9 +58,7 @@ void VerticalHistogram::analyzeImage(Mat inputImage, Mat mask) for (; columnCount > 0; columnCount--) histoImg.at(inputImage.rows - columnCount, col) = 255; - } - } int VerticalHistogram::getLocalMinimum(int leftX, int rightX) @@ -127,7 +123,6 @@ void VerticalHistogram::findValleys() relativePeakHeight = colHeights[i]; prevDirection = FLAT; - } else { @@ -137,14 +132,11 @@ void VerticalHistogram::findValleys() if ((prevDirection == FALLING || prevDirection == FLAT) && direction == RISING) { - } else if ((prevDirection == FALLING || prevDirection == FLAT) && direction == RISING) { - } } - } } diff --git a/src/openalpr/verticalhistogram.h b/src/openalpr/verticalhistogram.h index ce02962..17da429 100644 --- a/src/openalpr/verticalhistogram.h +++ b/src/openalpr/verticalhistogram.h @@ -17,7 +17,6 @@ * along with this program. If not, see . */ - #ifndef VERTICALHISTOGRAM_H #define VERTICALHISTOGRAM_H @@ -26,7 +25,6 @@ using namespace cv; using namespace std; - struct Valley { int startIndex; From 4934cf59d202af91b0d78af7d1758cdd7f4c4bb8 Mon Sep 17 00:00:00 2001 From: Philippe Vaucher Date: Mon, 24 Mar 2014 10:32:16 +0100 Subject: [PATCH 2/4] Simplify verbose return --- src/main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 692abf6..3704a2a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -234,7 +234,5 @@ bool detectandshow( Alpr* alpr, cv::Mat frame, std::string region, bool writeJso if (measureProcessingTime) std::cout << "Total Time to process image: " << diffclock(startTime, endTime) << "ms." << std::endl; - if (results.size() > 0) - return true; - return false; + return results.size() > 0; } From d24ed44f833512d780e97e0bf5bd4c8c2a389813 Mon Sep 17 00:00:00 2001 From: Philippe Vaucher Date: Mon, 24 Mar 2014 10:45:14 +0100 Subject: [PATCH 3/4] Add empty lines where it makes sense --- src/openalpr/alpr.cpp | 5 +++++ src/openalpr/alpr_impl.cpp | 3 +++ src/openalpr/charactersegmenter.cpp | 1 + src/openalpr/config.cpp | 7 +++++++ src/openalpr/postprocess.cpp | 1 + src/openalpr/support/timing.cpp | 2 ++ src/openalpr/utility.cpp | 1 + 7 files changed, 20 insertions(+) diff --git a/src/openalpr/alpr.cpp b/src/openalpr/alpr.cpp index 59f4e8a..715c53f 100644 --- a/src/openalpr/alpr.cpp +++ b/src/openalpr/alpr.cpp @@ -26,10 +26,12 @@ Alpr::Alpr(const std::string country, const std::string runtimeDir) { impl = new AlprImpl(country, runtimeDir); } + Alpr::~Alpr() { delete impl; } + std::vector Alpr::recognize(std::string filepath) { cv::Mat img = cv::imread(filepath, CV_LOAD_IMAGE_COLOR); @@ -53,10 +55,12 @@ void Alpr::setDetectRegion(bool detectRegion) { impl->setDetectRegion(detectRegion); } + void Alpr::setTopN(int topN) { impl->setTopN(topN); } + void Alpr::setDefaultRegion(std::string region) { impl->setDefaultRegion(region); @@ -72,6 +76,7 @@ bool Alpr::isLoaded() AlprResult::AlprResult() { } + AlprResult::~AlprResult() { } diff --git a/src/openalpr/alpr_impl.cpp b/src/openalpr/alpr_impl.cpp index cfd69b2..ecc3e8c 100644 --- a/src/openalpr/alpr_impl.cpp +++ b/src/openalpr/alpr_impl.cpp @@ -58,6 +58,7 @@ AlprImpl::AlprImpl(const std::string country, const std::string runtimeDir) } } } + AlprImpl::~AlprImpl() { delete config; @@ -245,10 +246,12 @@ void AlprImpl::setDetectRegion(bool detectRegion) { this->detectRegion = detectRegion; } + void AlprImpl::setTopN(int topn) { this->topN = topn; } + void AlprImpl::setDefaultRegion(string region) { this->defaultRegion = region; diff --git a/src/openalpr/charactersegmenter.cpp b/src/openalpr/charactersegmenter.cpp index 3b68037..b3d41d9 100644 --- a/src/openalpr/charactersegmenter.cpp +++ b/src/openalpr/charactersegmenter.cpp @@ -697,6 +697,7 @@ void CharacterSegmenter::cleanMostlyFullBoxes(vector thresholds, const vect } } } + vector CharacterSegmenter::filterMostlyEmptyBoxes(vector thresholds, const vector charRegions) { // Of the n thresholded images, if box 3 (for example) is empty in half (for example) of the thresholded images, diff --git a/src/openalpr/config.cpp b/src/openalpr/config.cpp index f90e4fb..5fe2168 100644 --- a/src/openalpr/config.cpp +++ b/src/openalpr/config.cpp @@ -61,6 +61,7 @@ Config::Config(const std::string country, const std::string runtimeBaseDir) loadValues(country); } + Config::~Config() { delete ini; @@ -148,14 +149,17 @@ string Config::getCascadeRuntimeDir() { return this->runtimeBaseDir + CASCADE_DIR; } + string Config::getKeypointsRuntimeDir() { return this->runtimeBaseDir + KEYPOINTS_DIR; } + string Config::getPostProcessRuntimeDir() { return this->runtimeBaseDir + POSTPROCESS_DIR; } + string Config::getTessdataPrefix() { return "TESSDATA_PREFIX=" + this->runtimeBaseDir + "/ocr/"; @@ -173,6 +177,7 @@ float Config::getFloat(string section, string key, float defaultValue) float val = atof(pszValue); return val; } + int Config::getInt(string section, string key, int defaultValue) { const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/); @@ -185,6 +190,7 @@ int Config::getInt(string section, string key, int defaultValue) int val = atoi(pszValue); return val; } + bool Config::getBoolean(string section, string key, bool defaultValue) { const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/); @@ -197,6 +203,7 @@ bool Config::getBoolean(string section, string key, bool defaultValue) int val = atoi(pszValue); return val != 0; } + string Config::getString(string section, string key, string defaultValue) { const char * pszValue = ini->GetValue(section.c_str(), key.c_str(), NULL /*default*/); diff --git a/src/openalpr/postprocess.cpp b/src/openalpr/postprocess.cpp index 204c6e0..9b23b73 100644 --- a/src/openalpr/postprocess.cpp +++ b/src/openalpr/postprocess.cpp @@ -142,6 +142,7 @@ void PostProcess::clear() bestChars = ""; matchesTemplate = false; } + void PostProcess::analyze(string templateregion, int topn) { timespec startTime; diff --git a/src/openalpr/support/timing.cpp b/src/openalpr/support/timing.cpp index 7d5e2a1..4cc7442 100644 --- a/src/openalpr/support/timing.cpp +++ b/src/openalpr/support/timing.cpp @@ -72,6 +72,7 @@ void getTime(timespec* time) { clock_gettime(0, time); } + double diffclock(timespec time1,timespec time2) { timespec delta = diff(time1,time2); @@ -112,6 +113,7 @@ void getTime(timespec* time) clock_gettime(CLOCK_PROCESS_CPUTIME_ID, time); #endif } + double diffclock(timespec time1,timespec time2) { timespec delta = diff(time1,time2); diff --git a/src/openalpr/utility.cpp b/src/openalpr/utility.cpp index f3ec573..700f735 100644 --- a/src/openalpr/utility.cpp +++ b/src/openalpr/utility.cpp @@ -262,6 +262,7 @@ LineSegment::LineSegment(Point p1, Point p2) { init(p1.x, p1.y, p2.x, p2.y); } + LineSegment::LineSegment(int x1, int y1, int x2, int y2) { init(x1, y1, x2, y2); From c406cc6e0bc16bc4f4d755d5a50ba6c783a0bb5f Mon Sep 17 00:00:00 2001 From: Philippe Vaucher Date: Mon, 24 Mar 2014 12:41:23 +0100 Subject: [PATCH 4/4] Fix weird boolean conditions --- src/main.cpp | 12 +++++------- src/misc_utilities/classifychars.cpp | 2 +- src/openalpr/characteranalysis.cpp | 2 +- src/openalpr/charactersegmenter.cpp | 6 ++---- src/openalpr/featurematcher.cpp | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3704a2a..4cc226b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -99,10 +99,8 @@ int main( int argc, const char** argv ) if (detectRegion) alpr.setDetectRegion(detectRegion); - if (strcmp(templateRegion.c_str(), "") != 0) - { + if (templateRegion.empty() == false) alpr.setDefaultRegion(templateRegion); - } if (alpr.isLoaded() == false) { @@ -110,7 +108,7 @@ int main( int argc, const char** argv ) return 1; } - if (strcmp(filename.c_str(), "webcam") == 0) + if (filename == "webcam") { int framenum = 0; cv::VideoCapture cap(0); @@ -120,7 +118,7 @@ int main( int argc, const char** argv ) return 1; } - while (cap.read(frame) == true) + while (cap.read(frame)) { detectandshow(&alpr, frame, "", outputJson); cv::waitKey(1); @@ -137,9 +135,9 @@ int main( int argc, const char** argv ) cap.open(filename); cap.set(CV_CAP_PROP_POS_MSEC, seektoms); - while (cap.read(frame) == true) + while (cap.read(frame)) { - if (SAVE_LAST_VIDEO_STILL == true) + if (SAVE_LAST_VIDEO_STILL) { cv::imwrite(LAST_VIDEO_STILL_LOCATION, frame); } diff --git a/src/misc_utilities/classifychars.cpp b/src/misc_utilities/classifychars.cpp index 8f6aea7..0f88431 100644 --- a/src/misc_utilities/classifychars.cpp +++ b/src/misc_utilities/classifychars.cpp @@ -279,7 +279,7 @@ void showDashboard(vector images, vector selectedImages, int selected { rectangle(imgCopy, Point(1,1), Point(imgCopy.size().width - 1, imgCopy.size().height -1), Scalar(0, 255, 0), 1); } - if (selectedImages[i] == true) + if (selectedImages[i]) { rectangle(imgCopy, Point(2,2), Point(imgCopy.size().width - 2, imgCopy.size().height -2), Scalar(255, 0, 0), 1); } diff --git a/src/openalpr/characteranalysis.cpp b/src/openalpr/characteranalysis.cpp index 3454ca3..fc61860 100644 --- a/src/openalpr/characteranalysis.cpp +++ b/src/openalpr/characteranalysis.cpp @@ -651,7 +651,7 @@ vector< bool > CharacterAnalysis::filterContourHoles(vector< vector< Point > > c int parentIndex = hierarchy[i][3]; - if (parentIndex >= 0 && goodIndices[parentIndex] == true) + if (parentIndex >= 0 && goodIndices[parentIndex]) { // this contour is a child of an already identified contour. REMOVE it if (this->config->debugCharAnalysis) diff --git a/src/openalpr/charactersegmenter.cpp b/src/openalpr/charactersegmenter.cpp index b3d41d9..688760b 100644 --- a/src/openalpr/charactersegmenter.cpp +++ b/src/openalpr/charactersegmenter.cpp @@ -424,8 +424,7 @@ vector CharacterSegmenter::get1DHits(Mat img, int yOffset) curSegmentLength++; } - if ((isOn == false && onSegment == true) || - (col == img.cols - 1 && onSegment == true)) + if (onSegment && (isOn == false || (col == img.cols - 1))) { // A segment just ended or we're at the very end of the row and we're on a segment Point topLeft = Point(col - curSegmentLength, top.getPointAt(col - curSegmentLength) - 1); @@ -1054,8 +1053,7 @@ int CharacterSegmenter::getLongestBlobLengthBetweenLines(Mat img, int col) wasbetweenLines = true; } - if ((isOn == false && onSegment == true) || - (row == img.rows - 1 && onSegment == true)) + if (onSegment && (isOn == false || (row == img.rows - 1))) { if (wasbetweenLines && curSegmentLength > longestBlobLength) longestBlobLength = curSegmentLength; diff --git a/src/openalpr/featurematcher.cpp b/src/openalpr/featurematcher.cpp index fa24e24..268410f 100644 --- a/src/openalpr/featurematcher.cpp +++ b/src/openalpr/featurematcher.cpp @@ -363,7 +363,7 @@ RecognitionResult FeatureMatcher::recognize( const Mat& queryImg, bool drawOnIma drawKeypoints( queryImg, queryKeypoints, tmpImg, CV_RGB(185, 0, 0), DrawMatchesFlags::DEFAULT ); drawKeypoints( tmpImg, positiveMatches, *outputImage, CV_RGB(0, 255, 0), DrawMatchesFlags::DEFAULT ); - if (result.haswinner == true) + if (result.haswinner) { std::ostringstream out; out << result.winner << " (" << result.confidence << "%)";