You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
EasyPR/test/chars.hpp

96 lines
2.1 KiB

#ifndef EASYPR_CHARS_HPP
#define EASYPR_CHARS_HPP
namespace easypr {
namespace demo {
int test_chars_segment() {
std::cout << "test_chars_segment" << std::endl;
cv::Mat src = cv::imread("resources/image/chars_segment.jpg");
std::vector<cv::Mat> resultVec;
CCharsSegment plate;
int result = plate.charsSegment(src, resultVec);
if (result == 0) {
size_t num = resultVec.size();
for (size_t j = 0; j < num; j++) {
cv::Mat resultMat = resultVec[j];
cv::imshow("chars_segment", resultMat);
cv::waitKey(0);
}
cv::destroyWindow("chars_segment");
}
return result;
}
int test_chars_identify() {
std::cout << "test_chars_identify" << std::endl;
cv::Mat src = cv::imread("resources/image/chars_identify.jpg");
std::vector<cv::Mat> resultVec;
CCharsSegment cs;
CCharsIdentify ci;
std::string plateIdentify = "";
int result = cs.charsSegment(src, resultVec);
if (result == 0) {
size_t num = resultVec.size();
for (size_t j = 0; j < num; j++) {
cv::Mat resultMat = resultVec[j];
bool isChinses = false;
bool isSpec = false;
//Ĭ<><C4AC><EFBFBD>׸<EFBFBD><D7B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
if (j == 0)
isChinses = true;
if (j == 1)
isSpec = true;
std::string charcater = ci.charsIdentify(resultMat, isChinses, isSpec);
plateIdentify = plateIdentify + charcater;
}
}
const std::string plateLicense = "<EFBFBD><EFBFBD>E771H6";
std::cout << "plateLicense: " << plateLicense << std::endl;
std::cout << "plateIdentify: " << plateIdentify << std::endl;
if (plateLicense != plateIdentify) {
std::cout << "Identify Not Correct!" << std::endl;
return -1;
}
std::cout << "Identify Correct!" << std::endl;
return result;
}
int test_chars_recognise() {
std::cout << "test_chars_recognise" << std::endl;
cv::Mat src = cv::imread("resources/image/chars_recognise.jpg");
CCharsRecognise cr;
std::string charsRecognise = "";
int result = cr.charsRecognise(src, charsRecognise);
if (result == 0) {
std::cout << "charsRecognise: " << charsRecognise << std::endl;
}
return result;
}
}
}
#endif //EASYPR_CHARS_HPP