本文整理汇总了C++中zxing::ReaderException方法的典型用法代码示例。如果您正苦于以下问题:C++ zxing::ReaderException方法的具体用法?C++ zxing::ReaderException怎么用?C++ zxing::ReaderException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zxing
的用法示例。
在下文中一共展示了zxing::ReaderException方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReaderException
vector<vector<Ref<FinderPattern> > > MultiFinderPatternFinder::selectBestPatterns(){
vector<Ref<FinderPattern> > possibleCenters = possibleCenters_;
int size = possibleCenters.size();
if (size < 3) {
// Couldn't find enough finder patterns
throw ReaderException("No code detected");
}
vector<vector<Ref<FinderPattern> > > results;
/*
* Begin HE modifications to safely detect multiple codes of equal size
*/
if (size == 3) {
results.push_back(possibleCenters_);
return results;
}
// Sort by estimated module size to speed up the upcoming checks
//TODO do a sort based on module size
sort(possibleCenters.begin(), possibleCenters.end(), compareModuleSize);
/*
* Now lets start: build a list of tuples of three finder locations that
* - feature similar module sizes
* - are placed in a distance so the estimated module count is within the QR specification
* - have similar distance between upper left/right and left top/bottom finder patterns
* - form a triangle with 90° angle (checked by comparing top right/bottom left distance
* with pythagoras)
*
* Note: we allow each point to be used for more than one code region: this might seem
* counterintuitive at first, but the performance penalty is not that big. At this point,
* we cannot make a good quality decision whether the three finders actually represent
* a QR code, or are just by chance layouted so it looks like there might be a QR code there.
* So, if the layout seems right, lets have the decoder try to decode.
*/
for (int i1 = 0; i1 < (size - 2); i1++) {
Ref<FinderPattern> p1 = possibleCenters[i1];
for (int i2 = i1 + 1; i2 < (size - 1); i2++) {
Ref<FinderPattern> p2 = possibleCenters[i2];
// Compare the expected module sizes; if they are really off, skip
float vModSize12 = (p1->getEstimatedModuleSize() - p2->getEstimatedModuleSize()) / min(p1->getEstimatedModuleSize(), p2->getEstimatedModuleSize());
float vModSize12A = abs(p1->getEstimatedModuleSize() - p2->getEstimatedModuleSize());
if (vModSize12A > DIFF_MODSIZE_CUTOFF && vModSize12 >= DIFF_MODSIZE_CUTOFF_PERCENT) {
// break, since elements are ordered by the module size deviation there cannot be
// any more interesting elements for the given p1.
break;
}
for (int i3 = i2 + 1; i3 < size; i3++) {
Ref<FinderPattern> p3 = possibleCenters[i3];
// Compare the expected module sizes; if they are really off, skip
float vModSize23 = (p2->getEstimatedModuleSize() - p3->getEstimatedModuleSize()) / min(p2->getEstimatedModuleSize(), p3->getEstimatedModuleSize());
float vModSize23A = abs(p2->getEstimatedModuleSize() - p3->getEstimatedModuleSize());
if (vModSize23A > DIFF_MODSIZE_CUTOFF && vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) {
// break, since elements are ordered by the module size deviation there cannot be
// any more interesting elements for the given p1.
break;
}
vector<Ref<FinderPattern> > test;
test.push_back(p1);
test.push_back(p2);
test.push_back(p3);
test = FinderPatternFinder::orderBestPatterns(test);
// Calculate the distances: a = topleft-bottomleft, b=topleft-topright, c = diagonal
Ref<FinderPatternInfo> info = Ref<FinderPatternInfo>(new FinderPatternInfo(test));
float dA = FinderPatternFinder::distance(info->getTopLeft(), info->getBottomLeft());
float dC = FinderPatternFinder::distance(info->getTopRight(), info->getBottomLeft());
float dB = FinderPatternFinder::distance(info->getTopLeft(), info->getTopRight());
// Check the sizes
float estimatedModuleCount = (dA + dB) / (p1->getEstimatedModuleSize() * 2.0f);
if (estimatedModuleCount > MAX_MODULE_COUNT_PER_EDGE || estimatedModuleCount < MIN_MODULE_COUNT_PER_EDGE) {
continue;
}
// Calculate the difference of the edge lengths in percent
float vABBC = abs((dA - dB) / min(dA, dB));
if (vABBC >= 0.1f) {
continue;
}
// Calculate the diagonal length by assuming a 90° angle at topleft
float dCpy = (float) sqrt(dA * dA + dB * dB);
// Compare to the real distance in %
float vPyC = abs((dC - dCpy) / min(dC, dCpy));
if (vPyC >= 0.1f) {
continue;
}
// All tests passed!
results.push_back(test);
} // end iterate p3
} // end iterate p2
} // end iterate p1
if (results.empty()){
// Nothing found!
throw ReaderException("No code detected");
}
return results;
}