当前位置: 首页>>代码示例>>Java>>正文


Java MathUtils.round方法代码示例

本文整理汇总了Java中com.google.zxing.common.detector.MathUtils.round方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.round方法的具体用法?Java MathUtils.round怎么用?Java MathUtils.round使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.zxing.common.detector.MathUtils的用法示例。


在下文中一共展示了MathUtils.round方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeDimension

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
/**
 * <p>Computes the dimension (number of modules on a size) of the QR Code based on the position
 * of the finder patterns and estimated module size.</p>
 */
private static int computeDimension(ResultPoint topLeft,
                                    ResultPoint topRight,
                                    ResultPoint bottomLeft,
                                    float moduleSize) throws NotFoundException {
  int tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize);
  int tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize);
  int dimension = ((tltrCentersDimension + tlblCentersDimension) / 2) + 7;
  switch (dimension & 0x03) { // mod 4
    case 0:
      dimension++;
      break;
      // 1? do nothing
    case 2:
      dimension--;
      break;
    case 3:
      throw NotFoundException.getNotFoundInstance();
  }
  return dimension;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:25,代码来源:Detector.java

示例2: computeDimension

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
private static int computeDimension(ResultPoint topLeft, ResultPoint topRight, ResultPoint
        bottomLeft, float moduleSize) throws NotFoundException {
    int dimension = ((MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize) +
            MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize)) / 2) + 7;
    switch (dimension & 3) {
        case 0:
            return dimension + 1;
        case 2:
            return dimension - 1;
        case 3:
            throw NotFoundException.getNotFoundInstance();
        default:
            return dimension;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:Detector.java

示例3: getMatrixCornerPoints

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
/**
 *
 * <p>Gets the Aztec code corners from the bull's eye corners and the parameters </p>
 *
 * @param bullEyeCornerPoints the array of bull's eye corners
 * @return the array of aztec code corners
 * @throws NotFoundException if the corner points do not fit in the image
 */
private ResultPoint[] getMatrixCornerPoints(Point[] bullEyeCornerPoints) throws NotFoundException {

  float ratio = (2 * nbLayers + (nbLayers > 4 ? 1 : 0) + (nbLayers - 4) / 8)
      / (2.0f * nbCenterLayers);

  int dx = bullEyeCornerPoints[0].x-bullEyeCornerPoints[2].x;
  dx+=dx>0?1:-1;
  int dy = bullEyeCornerPoints[0].y-bullEyeCornerPoints[2].y;
  dy+=dy>0?1:-1;
  
  int targetcx = MathUtils.round(bullEyeCornerPoints[2].x - ratio * dx);
  int targetcy = MathUtils.round(bullEyeCornerPoints[2].y - ratio * dy);
  
  int targetax = MathUtils.round(bullEyeCornerPoints[0].x + ratio * dx);
  int targetay = MathUtils.round(bullEyeCornerPoints[0].y + ratio * dy);
  
  dx = bullEyeCornerPoints[1].x-bullEyeCornerPoints[3].x;
  dx+=dx>0?1:-1;
  dy = bullEyeCornerPoints[1].y-bullEyeCornerPoints[3].y;
  dy+=dy>0?1:-1;
  
  int targetdx = MathUtils.round(bullEyeCornerPoints[3].x - ratio * dx);
  int targetdy = MathUtils.round(bullEyeCornerPoints[3].y - ratio * dy);
  int targetbx = MathUtils.round(bullEyeCornerPoints[1].x + ratio * dx);
  int targetby = MathUtils.round(bullEyeCornerPoints[1].y+ratio*dy);
  
  if (!isValid(targetax, targetay) || !isValid(targetbx, targetby) || !isValid(targetcx, targetcy) || !isValid(targetdx, targetdy)) {
    throw NotFoundException.getNotFoundInstance();
  }
  
  return new ResultPoint[]{new ResultPoint(targetax, targetay), new ResultPoint(targetbx, targetby), new ResultPoint(targetcx, targetcy), new ResultPoint(targetdx, targetdy)}; 
}
 
开发者ID:atomsheep,项目名称:sres-app,代码行数:41,代码来源:Detector.java

示例4: isValid

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
private boolean isValid(ResultPoint point) {
  int x = MathUtils.round(point.getX());
  int y = MathUtils.round(point.getY());
  return isValid(x, y);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:6,代码来源:Detector.java

示例5: distance

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
private static int distance(ResultPoint a, ResultPoint b) {
  return MathUtils.round(ResultPoint.distance(a, b));
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:4,代码来源:Detector.java

示例6: getMatrixCenter

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
private Point getMatrixCenter() {
    ResultPoint pointA;
    ResultPoint pointB;
    ResultPoint pointC;
    ResultPoint pointD;
    int cx;
    int cy;
    try {
        ResultPoint[] cornerPoints = new WhiteRectangleDetector(this.image).detect();
        pointA = cornerPoints[0];
        pointB = cornerPoints[1];
        pointC = cornerPoints[2];
        pointD = cornerPoints[3];
    } catch (NotFoundException e) {
        cx = this.image.getWidth() / 2;
        cy = this.image.getHeight() / 2;
        pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint();
        pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint();
        pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint();
        pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint();
    }
    cx = MathUtils.round((((pointA.getX() + pointD.getX()) + pointB.getX()) + pointC.getX())
            / aj.hA);
    cy = MathUtils.round((((pointA.getY() + pointD.getY()) + pointB.getY()) + pointC.getY())
            / aj.hA);
    try {
        cornerPoints = new WhiteRectangleDetector(this.image, 15, cx, cy).detect();
        pointA = cornerPoints[0];
        pointB = cornerPoints[1];
        pointC = cornerPoints[2];
        pointD = cornerPoints[3];
    } catch (NotFoundException e2) {
        pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint();
        pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint();
        pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint();
        pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint();
    }
    return new Point(MathUtils.round((((pointA.getX() + pointD.getX()) + pointB.getX()) +
            pointC.getX()) / aj.hA), MathUtils.round((((pointA.getY() + pointD.getY()) +
            pointB.getY()) + pointC.getY()) / aj.hA));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:42,代码来源:Detector.java

示例7: distance

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
private static int distance(ResultPoint a, ResultPoint b) {
    return MathUtils.round(ResultPoint.distance(a, b));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:Detector.java

示例8: computeYDimension

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
/**
 * Computes the y dimension (number of modules in a column) of the PDF417 Code
 * based on vertices of the codeword area and estimated module size.
 *
 * @param topLeft     of codeword area
 * @param topRight    of codeword area
 * @param bottomLeft  of codeword area
 * @param bottomRight of codeword are
 * @param moduleWidth estimated module size
 * @return the number of modules in a row.
 */
private static int computeYDimension(ResultPoint topLeft,
                                    ResultPoint topRight,
                                    ResultPoint bottomLeft,
                                    ResultPoint bottomRight,
                                    float moduleWidth) {
  int leftColumnDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleWidth);
  int rightColumnDimension = MathUtils.round(ResultPoint.distance(topRight, bottomRight) / moduleWidth);
  return (leftColumnDimension + rightColumnDimension) >> 1;
}
 
开发者ID:atomsheep,项目名称:sres-app,代码行数:21,代码来源:Detector.java

示例9: computeDimension

import com.google.zxing.common.detector.MathUtils; //导入方法依赖的package包/类
/**
 * Computes the dimension (number of modules in a row) of the PDF417 Code
 * based on vertices of the codeword area and estimated module size.
 *
 * @param topLeft     of codeword area
 * @param topRight    of codeword area
 * @param bottomLeft  of codeword area
 * @param bottomRight of codeword are
 * @param moduleWidth estimated module size
 * @return the number of modules in a row.
 */
private static int computeDimension(ResultPoint topLeft,
                                    ResultPoint topRight,
                                    ResultPoint bottomLeft,
                                    ResultPoint bottomRight,
                                    float moduleWidth) {
  int topRowDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleWidth);
  int bottomRowDimension = MathUtils.round(ResultPoint.distance(bottomLeft, bottomRight) / moduleWidth);
  return ((((topRowDimension + bottomRowDimension) >> 1) + 8) / 17) * 17;
}
 
开发者ID:atomsheep,项目名称:sres-app,代码行数:21,代码来源:Detector.java


注:本文中的com.google.zxing.common.detector.MathUtils.round方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。