本文整理汇总了Java中com.google.zxing.ResultPoint.distance方法的典型用法代码示例。如果您正苦于以下问题:Java ResultPoint.distance方法的具体用法?Java ResultPoint.distance怎么用?Java ResultPoint.distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.ResultPoint
的用法示例。
在下文中一共展示了ResultPoint.distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectMutipleBestPatterns
import com.google.zxing.ResultPoint; //导入方法依赖的package包/类
private FinderPattern[][] selectMutipleBestPatterns() throws NotFoundException {
List<FinderPattern> possibleCenters = getPossibleCenters();
int size = possibleCenters.size();
if (size < 3) {
throw NotFoundException.getNotFoundInstance();
} else if (size == 3) {
FinderPattern[][] finderPatternArr = new FinderPattern[1][];
finderPatternArr[0] = new FinderPattern[]{(FinderPattern) possibleCenters.get(0),
(FinderPattern) possibleCenters.get(1), (FinderPattern) possibleCenters.get(2)};
return finderPatternArr;
} else {
Collections.sort(possibleCenters, new ModuleSizeComparator());
List<FinderPattern[]> results = new ArrayList();
for (int i1 = 0; i1 < size - 2; i1++) {
FinderPattern p1 = (FinderPattern) possibleCenters.get(i1);
if (p1 != null) {
for (int i2 = i1 + 1; i2 < size - 1; i2++) {
FinderPattern p2 = (FinderPattern) possibleCenters.get(i2);
if (p2 != null) {
float vModSize12 = (p1.getEstimatedModuleSize() - p2
.getEstimatedModuleSize()) / Math.min(p1
.getEstimatedModuleSize(), p2.getEstimatedModuleSize());
if (Math.abs(p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize
()) > DIFF_MODSIZE_CUTOFF && vModSize12 >=
DIFF_MODSIZE_CUTOFF_PERCENT) {
break;
}
for (int i3 = i2 + 1; i3 < size; i3++) {
FinderPattern p3 = (FinderPattern) possibleCenters.get(i3);
if (p3 != null) {
float vModSize23 = (p2.getEstimatedModuleSize() - p3
.getEstimatedModuleSize()) / Math.min(p2
.getEstimatedModuleSize(), p3.getEstimatedModuleSize());
if (Math.abs(p2.getEstimatedModuleSize() - p3
.getEstimatedModuleSize()) > DIFF_MODSIZE_CUTOFF &&
vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) {
break;
}
Object test = new FinderPattern[]{p1, p2, p3};
ResultPoint.orderBestPatterns(test);
FinderPatternInfo info = new FinderPatternInfo(test);
float dA = ResultPoint.distance(info.getTopLeft(), info
.getBottomLeft());
float dC = ResultPoint.distance(info.getTopRight(), info
.getBottomLeft());
float dB = ResultPoint.distance(info.getTopLeft(), info
.getTopRight());
float estimatedModuleCount = (dA + dB) / (p1
.getEstimatedModuleSize() * 2.0f);
if (estimatedModuleCount <= MAX_MODULE_COUNT_PER_EDGE &&
estimatedModuleCount >= MIN_MODULE_COUNT_PER_EDGE &&
Math.abs((dA - dB) / Math.min(dA, dB)) < 0.1f) {
float dCpy = (float) Math.sqrt((double) ((dA * dA) + (dB
* dB)));
if (Math.abs((dC - dCpy) / Math.min(dC, dCpy)) < 0.1f) {
results.add(test);
}
}
}
}
}
}
}
}
if (!results.isEmpty()) {
return (FinderPattern[][]) results.toArray(new FinderPattern[results.size()][]);
}
throw NotFoundException.getNotFoundInstance();
}
}