當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultPoint.distance方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:71,代碼來源:MultiFinderPatternFinder.java


注:本文中的com.google.zxing.ResultPoint.distance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。