* add removeOutliers by distance.

v1.6alpha
liuruoze 9 years ago
parent 55ca237811
commit 8bbcf763a4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 53 KiB

@ -1354,8 +1354,9 @@ void removeRightOutliers(std::vector<CCharacter>& charGroup, std::vector<CCharac
float slope = line_btp[1] / line_btp[0]; float slope = line_btp[1] / line_btp[0];
slopeVec.push_back(slope); slopeVec.push_back(slope);
//std::cout << "slope:" << slope << std::endl; if (1) {
cv::line(result, leftChar.getCenterPoint(), rightChar.getCenterPoint(), Scalar(0, 0, 255)); cv::line(result, leftChar.getCenterPoint(), rightChar.getCenterPoint(), Scalar(0, 0, 255));
}
} }
int uniformity_count = 0; int uniformity_count = 0;
@ -1364,21 +1365,27 @@ void removeRightOutliers(std::vector<CCharacter>& charGroup, std::vector<CCharac
float slope_1 = slopeVec.at(slopeVec_i); float slope_1 = slopeVec.at(slopeVec_i);
float slope_2 = slopeVec.at(slopeVec_i+1); float slope_2 = slopeVec.at(slopeVec_i+1);
float slope_diff = abs(slope_1 - slope_2); float slope_diff = abs(slope_1 - slope_2);
std::cout << "slope_diff:" << slope_diff << std::endl; if (1) {
std::cout << "slope_diff:" << slope_diff << std::endl;
}
if (slope_diff <= thresh1) { if (slope_diff <= thresh1) {
uniformity_count++; uniformity_count++;
} }
std::cout << "slope_1:" << slope_1 << std::endl; if (1) {
std::cout << "slope_2:" << slope_2 << std::endl; std::cout << "slope_1:" << slope_1 << std::endl;
std::cout << "slope_2:" << slope_2 << std::endl;
}
if ((slope_1 <= 0 && slope_2 >= 0) || (slope_1 >= 0 && slope_2 <= 0)) { if ((slope_1 <= 0 && slope_2 >= 0) || (slope_1 >= 0 && slope_2 <= 0)) {
if (uniformity_count >= 2 && slope_diff > thresh2) { if (uniformity_count >= 2 && slope_diff >= thresh2) {
outlier_index = slopeVec_i + 2; outlier_index = slopeVec_i + 2;
break; break;
} }
} }
} }
std::cout << "uniformity_count:" << uniformity_count << std::endl; if (1) {
std::cout << "outlier_index:" << outlier_index << std::endl; std::cout << "uniformity_count:" << uniformity_count << std::endl;
std::cout << "outlier_index:" << outlier_index << std::endl;
}
for (int charGroup_i = 0; charGroup_i < (int)charGroup.size(); charGroup_i++) { for (int charGroup_i = 0; charGroup_i < (int)charGroup.size(); charGroup_i++) {
if (charGroup_i != outlier_index) { if (charGroup_i != outlier_index) {
@ -1387,7 +1394,9 @@ void removeRightOutliers(std::vector<CCharacter>& charGroup, std::vector<CCharac
} }
} }
std::cout << "end:" << std::endl; if (1) {
std::cout << "end:" << std::endl;
}
} }
@ -1418,7 +1427,7 @@ void removeOutliers(std::vector<CCharacter>& charGroup, double thresh, Mat resul
} }
float avgdistance = sumdistance / (float)charGroup.size(); float avgdistance = sumdistance / (float)charGroup.size();
/*std::vector<CCharacter>::iterator it = charGroup.begin(); std::vector<CCharacter>::iterator it = charGroup.begin();
for (; it != charGroup.end();) { for (; it != charGroup.end();) {
Point center = it->getCenterPoint(); Point center = it->getCenterPoint();
float distance = a * center.x + b * center.y + c; float distance = a * center.x + b * center.y + c;
@ -1430,7 +1439,7 @@ void removeOutliers(std::vector<CCharacter>& charGroup, double thresh, Mat resul
else { else {
++it; ++it;
} }
}*/ }
} }
//! use verify size to first generate char candidates //! use verify size to first generate char candidates
@ -1546,7 +1555,7 @@ Mat mserCharMatch(const Mat &src, Mat &match, std::vector<CPlate>& out_plateVec,
// remove outlier CharGroup // remove outlier CharGroup
std::vector<CCharacter> roCharGroup; std::vector<CCharacter> roCharGroup;
removeRightOutliers(charGroup, roCharGroup, 0.2, 0.6, result); removeRightOutliers(charGroup, roCharGroup, 0.2, 0.5, result);
for (auto character : roCharGroup) { for (auto character : roCharGroup) {
Rect charRect = character.getCharacterPos(); Rect charRect = character.getCharacterPos();

Loading…
Cancel
Save