up e2e cpp
This commit is contained in:
@@ -12,25 +12,40 @@
|
||||
#include "FastDeskew.h"
|
||||
#include "FineMapping.h"
|
||||
#include "Recognizer.h"
|
||||
#include "SegmentationFreeRecognizer.h"
|
||||
|
||||
namespace pr{
|
||||
|
||||
const std::vector<std::string> CH_PLATE_CODE{"京", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", "桂",
|
||||
"琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
|
||||
"B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X",
|
||||
"Y", "Z","港","学","使","警","澳","挂","军","北","南","广","沈","兰","成","济","海","民","航","空"};
|
||||
|
||||
|
||||
|
||||
const int SEGMENTATION_FREE_METHOD = 0;
|
||||
const int SEGMENTATION_BASED_METHOD = 1;
|
||||
|
||||
class PipelinePR{
|
||||
public:
|
||||
GeneralRecognizer *generalRecognizer;
|
||||
PlateDetection *plateDetection;
|
||||
PlateSegmentation *plateSegmentation;
|
||||
FineMapping *fineMapping;
|
||||
SegmentationFreeRecognizer *segmentationFreeRecognizer;
|
||||
|
||||
PipelinePR(std::string detector_filename,
|
||||
std::string finemapping_prototxt,std::string finemapping_caffemodel,
|
||||
std::string segmentation_prototxt,std::string segmentation_caffemodel,
|
||||
std::string charRecognization_proto,std::string charRecognization_caffemodel
|
||||
std::string charRecognization_proto,std::string charRecognization_caffemodel,
|
||||
std::string segmentationfree_proto,std::string segmentationfree_caffemodel
|
||||
);
|
||||
~PipelinePR();
|
||||
|
||||
|
||||
|
||||
std::vector<std::string> plateRes;
|
||||
std::vector<PlateInfo> RunPiplineAsImage(cv::Mat plateImage);
|
||||
std::vector<PlateInfo> RunPiplineAsImage(cv::Mat plateImage,int method);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,17 +10,14 @@ namespace pr {
|
||||
typedef std::vector<cv::Mat> Character;
|
||||
|
||||
enum PlateColor { BLUE, YELLOW, WHITE, GREEN, BLACK,UNKNOWN};
|
||||
enum CharType {CHINESE,LETTER,LETTER_NUMS};
|
||||
enum CharType {CHINESE,LETTER,LETTER_NUMS,INVALID};
|
||||
|
||||
|
||||
class PlateInfo {
|
||||
public:
|
||||
std::vector<std::pair<CharType,cv::Mat>> plateChars;
|
||||
std::vector<std::pair<CharType,cv::Mat>> plateChars;
|
||||
std::vector<std::pair<CharType,cv::Mat>> plateCoding;
|
||||
|
||||
float confidence = 0;
|
||||
|
||||
|
||||
PlateInfo(const cv::Mat &plateData, std::string plateName, cv::Rect plateRect, PlateColor plateType) {
|
||||
licensePlate = plateData;
|
||||
name = plateName;
|
||||
@@ -93,17 +90,21 @@ namespace pr {
|
||||
|
||||
}
|
||||
|
||||
if(plate.first == LETTER) {
|
||||
else if(plate.first == LETTER) {
|
||||
decode += mappingTable[std::max_element(prob+41,prob+65)- prob];
|
||||
confidence+=*std::max_element(prob+41,prob+65);
|
||||
}
|
||||
|
||||
if(plate.first == LETTER_NUMS) {
|
||||
else if(plate.first == LETTER_NUMS) {
|
||||
decode += mappingTable[std::max_element(prob+31,prob+65)- prob];
|
||||
confidence+=*std::max_element(prob+31,prob+65);
|
||||
// std::cout<<*std::max_element(prob+31,prob+65)<<std::endl;
|
||||
|
||||
}
|
||||
else if(plate.first == INVALID)
|
||||
{
|
||||
decode+='*';
|
||||
}
|
||||
|
||||
}
|
||||
name = decode;
|
||||
@@ -113,12 +114,10 @@ namespace pr {
|
||||
return decode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
cv::Mat licensePlate;
|
||||
cv::Rect ROI;
|
||||
std::string name;
|
||||
std::string name ;
|
||||
PlateColor Type;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ namespace pr{
|
||||
class GeneralRecognizer{
|
||||
public:
|
||||
virtual label recognizeCharacter(cv::Mat character) = 0;
|
||||
// virtual cv::Mat SegmentationFreeForSinglePlate(cv::Mat plate) = 0;
|
||||
void SegmentBasedSequenceRecognition(PlateInfo &plateinfo);
|
||||
void SegmentationFreeSequenceRecognition(PlateInfo &plateInfo);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by 庾金科 on 28/11/2017.
|
||||
//
|
||||
|
||||
#ifndef SWIFTPR_SEGMENTATIONFREERECOGNIZER_H
|
||||
#define SWIFTPR_SEGMENTATIONFREERECOGNIZER_H
|
||||
|
||||
#include "Recognizer.h"
|
||||
namespace pr{
|
||||
|
||||
|
||||
class SegmentationFreeRecognizer{
|
||||
public:
|
||||
const int CHAR_INPUT_W = 14;
|
||||
const int CHAR_INPUT_H = 30;
|
||||
const int CHAR_LEN = 84;
|
||||
|
||||
SegmentationFreeRecognizer(std::string prototxt,std::string caffemodel);
|
||||
std::pair<std::string,float> SegmentationFreeForSinglePlate(cv::Mat plate,std::vector<std::string> mapping_table);
|
||||
|
||||
|
||||
private:
|
||||
cv::dnn::Net net;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif //SWIFTPR_SEGMENTATIONFREERECOGNIZER_H
|
||||
Reference in New Issue
Block a user