本文整理汇总了C++中Version::getAlignmentPatternCenters方法的典型用法代码示例。如果您正苦于以下问题:C++ Version::getAlignmentPatternCenters方法的具体用法?C++ Version::getAlignmentPatternCenters怎么用?C++ Version::getAlignmentPatternCenters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Version
的用法示例。
在下文中一共展示了Version::getAlignmentPatternCenters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReaderException
Ref<DetectorResult> Detector::processFinderPatternInfo(Ref<FinderPatternInfo> info){
Ref<FinderPattern> topLeft(info->getTopLeft());
Ref<FinderPattern> topRight(info->getTopRight());
Ref<FinderPattern> bottomLeft(info->getBottomLeft());
float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
if (moduleSize < 1.0f) {
throw zxing::ReaderException("bad module size");
}
int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
Version *provisionalVersion = Version::getProvisionalVersionForDimension(dimension);
int modulesBetweenFPCenters = provisionalVersion->getDimensionForVersion() - 7;
Ref<AlignmentPattern> alignmentPattern;
// Anything above version 1 has an alignment pattern
if (provisionalVersion->getAlignmentPatternCenters().size() > 0) {
// Guess where a "bottom right" finder pattern would have been
float bottomRightX = topRight->getX() - topLeft->getX() + bottomLeft->getX();
float bottomRightY = topRight->getY() - topLeft->getY() + bottomLeft->getY();
// Estimate that alignment pattern is closer by 3 modules
// from "bottom right" to known top left location
float correctionToTopLeft = 1.0f - 3.0f / (float)modulesBetweenFPCenters;
int estAlignmentX = (int)(topLeft->getX() + correctionToTopLeft * (bottomRightX - topLeft->getX()));
int estAlignmentY = (int)(topLeft->getY() + correctionToTopLeft * (bottomRightY - topLeft->getY()));
// Kind of arbitrary -- expand search radius before giving up
for (int i = 4; i <= 16; i <<= 1) {
try {
alignmentPattern = findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, (float)i);
break;
} catch (zxing::ReaderException const& re) {
(void)re;
// try next round
}
}
if (alignmentPattern == 0) {
// Try anyway
}
}
Ref<PerspectiveTransform> transform = createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);
Ref<BitMatrix> bits(sampleGrid(image_, dimension, transform));
ArrayRef< Ref<ResultPoint> > points(new Array< Ref<ResultPoint> >(alignmentPattern == 0 ? 3 : 4));
points[0].reset(bottomLeft);
points[1].reset(topLeft);
points[2].reset(topRight);
if (alignmentPattern != 0) {
points[3].reset(alignmentPattern);
}
Ref<DetectorResult> result(new DetectorResult(bits, points));
return result;
}