/*
* 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 .
*/
#ifndef OPENALPR_ALPRIMPL_H
#define OPENALPR_ALPRIMPL_H
#include
#include
#include
#include
#include "alpr.h"
#include "config.h"
#include "detection/detector.h"
#include "detection/detectorfactory.h"
#include "prewarp.h"
#include "licenseplatecandidate.h"
#include "../statedetection/state_detector.h"
#include "segmentation/charactersegmenter.h"
#include "ocr.h"
#include "constants.h"
#include "cjson.h"
#include "pipeline_data.h"
#include "prewarp.h"
#include
#include "support/platform.h"
#include "support/utf8.h"
#define DEFAULT_TOPN 25
#define DEFAULT_DETECT_REGION false
#define ALPR_NULL_PTR 0
namespace alpr
{
struct AlprFullDetails
{
std::vector plateRegions;
AlprResults results;
};
struct AlprRecognizers
{
Detector* plateDetector;
StateDetector* stateDetector;
OCR* ocr;
};
class AlprImpl
{
public:
AlprImpl(const std::string country, const std::string configFile = "", const std::string runtimeDir = "");
virtual ~AlprImpl();
AlprFullDetails recognizeFullDetails(cv::Mat img, std::vector regionsOfInterest);
AlprResults recognize( std::vector imageBytes );
AlprResults recognize( std::vector imageBytes, std::vector regionsOfInterest );
AlprResults recognize( unsigned char* pixelData, int bytesPerPixel, int imgWidth, int imgHeight, std::vector regionsOfInterest );
AlprResults recognize( cv::Mat img );
AlprResults recognize( cv::Mat img, std::vector regionsOfInterest );
AlprFullDetails analyzeSingleCountry(cv::Mat colorImg, cv::Mat grayImg, std::vector regionsOfInterest);
void setCountry(std::string country);
void setPrewarp(std::string prewarp_config);
void setDetectRegion(bool detectRegion);
void setTopN(int topn);
void setDefaultRegion(std::string region);
static std::string toJson( const AlprResults results );
static AlprResults fromJson(std::string json);
static std::string getVersion();
static cJSON* createJsonObj(const AlprPlateResult* result);
Config* config;
bool isLoaded();
private:
std::map recognizers;
PreWarp* prewarp;
int topN;
bool detectRegion;
std::string defaultRegion;
void loadRecognizers();
cv::Mat getCharacterTransformMatrix(PipelineData* pipeline_data );
std::vector getCharacterPoints(cv::Rect char_rect, cv::Mat transmtx);
std::vector convertRects(std::vector regionsOfInterest);
};
}
#endif // OPENALPR_ALPRIMPL_H