up e2e cpp

This commit is contained in:
jackyu
2018-01-31 02:27:23 +08:00
parent ad22f4fa57
commit e004f4e4e5
57 changed files with 505 additions and 27103 deletions
+17 -2
View File
@@ -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);
+9 -10
View File
@@ -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;
};
}
+2
View File
@@ -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