类com.google.zxing.common.PerspectiveTransform源码实例Demo

下面列出了怎么用com.google.zxing.common.PerspectiveTransform的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: MiBandDecompiled   文件: Detector.java
public static PerspectiveTransform createTransform(ResultPoint resultpoint, ResultPoint resultpoint1, ResultPoint resultpoint2, ResultPoint resultpoint3, int i)
{
    float f = (float)i - 3.5F;
    float f1;
    float f2;
    float f3;
    float f4;
    if (resultpoint3 != null)
    {
        f1 = resultpoint3.getX();
        f2 = resultpoint3.getY();
        f3 = f - 3F;
        f4 = f3;
    } else
    {
        f1 = (resultpoint1.getX() - resultpoint.getX()) + resultpoint2.getX();
        f2 = (resultpoint1.getY() - resultpoint.getY()) + resultpoint2.getY();
        f3 = f;
        f4 = f;
    }
    return PerspectiveTransform.quadrilateralToQuadrilateral(3.5F, 3.5F, f, 3.5F, f4, f3, 3.5F, f, resultpoint.getX(), resultpoint.getY(), resultpoint1.getX(), resultpoint1.getY(), f1, f2, resultpoint2.getX(), resultpoint2.getY());
}
 
源代码2 项目: RipplePower   文件: Detector.java
private static PerspectiveTransform createTransform(ResultPoint topLeft, ResultPoint topRight,
		ResultPoint bottomLeft, ResultPoint alignmentPattern, int dimension) {
	float dimMinusThree = (float) dimension - 3.5f;
	float bottomRightX;
	float bottomRightY;
	float sourceBottomRightX;
	float sourceBottomRightY;
	if (alignmentPattern != null) {
		bottomRightX = alignmentPattern.getX();
		bottomRightY = alignmentPattern.getY();
		sourceBottomRightX = dimMinusThree - 3.0f;
		sourceBottomRightY = sourceBottomRightX;
	} else {
		// Don't have an alignment pattern, just make up the bottom-right
		// point
		bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
		bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
		sourceBottomRightX = dimMinusThree;
		sourceBottomRightY = dimMinusThree;
	}

	return PerspectiveTransform.quadrilateralToQuadrilateral(3.5f, 3.5f, dimMinusThree, 3.5f, sourceBottomRightX,
			sourceBottomRightY, 3.5f, dimMinusThree, topLeft.getX(), topLeft.getY(), topRight.getX(),
			topRight.getY(), bottomRightX, bottomRightY, bottomLeft.getX(), bottomLeft.getY());
}
 
源代码3 项目: barterli_android   文件: Detector.java
public static PerspectiveTransform createTransform(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft, ResultPoint alignmentPattern,
        int dimension) {
    float dimMinusThree = (float) dimension - 3.5f;
    float bottomRightX;
    float bottomRightY;
    float sourceBottomRightX;
    float sourceBottomRightY;
    if (alignmentPattern != null) {
        bottomRightX = alignmentPattern.getX();
        bottomRightY = alignmentPattern.getY();
        sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f;
    } else {
        // Don't have an alignment pattern, just make up the bottom-right
        // point
        bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
        bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
        sourceBottomRightX = sourceBottomRightY = dimMinusThree;
    }

    return PerspectiveTransform.quadrilateralToQuadrilateral(3.5f, 3.5f, dimMinusThree, 3.5f, sourceBottomRightX, sourceBottomRightY, 3.5f, dimMinusThree,
            topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRightX, bottomRightY, bottomLeft.getX(), bottomLeft.getY());
}
 
源代码4 项目: android-quick-response-code   文件: Detector.java
public static PerspectiveTransform createTransform(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft, ResultPoint alignmentPattern, int dimension) {
    float dimMinusThree = dimension - 3.5f;
    float bottomRightX;
    float bottomRightY;
    float sourceBottomRightX;
    float sourceBottomRightY;
    if (alignmentPattern != null) {
        bottomRightX = alignmentPattern.getX();
        bottomRightY = alignmentPattern.getY();
        sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f;
    } else {
        // Don't have an alignment pattern, just make up the bottom-right
        // point
        bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
        bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
        sourceBottomRightX = sourceBottomRightY = dimMinusThree;
    }

    return PerspectiveTransform.quadrilateralToQuadrilateral(3.5f, 3.5f, dimMinusThree, 3.5f, sourceBottomRightX, sourceBottomRightY, 3.5f, dimMinusThree,
            topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRightX, bottomRightY, bottomLeft.getX(), bottomLeft.getY());
}
 
源代码5 项目: ScreenCapture   文件: Detector.java
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
源代码6 项目: Tesseract-OCR-Scanner   文件: Detector.java
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
源代码7 项目: QrCodeScanner   文件: Detector.java
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
源代码8 项目: ZXing-Orient   文件: Detector.java
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
源代码10 项目: weex   文件: Detector.java
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
源代码11 项目: barcodescanner-lib-aar   文件: Detector.java
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
源代码12 项目: reacteu-app   文件: Detector.java
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
源代码13 项目: Telegram-FOSS   文件: Detector.java
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
源代码14 项目: Telegram   文件: Detector.java
private static BitMatrix sampleGrid(BitMatrix image,
                                    PerspectiveTransform transform,
                                    int dimension) throws NotFoundException {

  GridSampler sampler = GridSampler.getInstance();
  return sampler.sampleGrid(image, dimension, dimension, transform);
}
 
源代码15 项目: ScreenCapture   文件: Detector.java
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 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 / 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,
            i);
        break;
      } catch (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
源代码16 项目: ScreenCapture   文件: Detector.java
private static PerspectiveTransform createTransform(ResultPoint topLeft,
                                                    ResultPoint topRight,
                                                    ResultPoint bottomLeft,
                                                    ResultPoint alignmentPattern,
                                                    int dimension) {
  float dimMinusThree = dimension - 3.5f;
  float bottomRightX;
  float bottomRightY;
  float sourceBottomRightX;
  float sourceBottomRightY;
  if (alignmentPattern != null) {
    bottomRightX = alignmentPattern.getX();
    bottomRightY = alignmentPattern.getY();
    sourceBottomRightX = dimMinusThree - 3.0f;
    sourceBottomRightY = sourceBottomRightX;
  } else {
    // Don't have an alignment pattern, just make up the bottom-right point
    bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
    bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
    sourceBottomRightX = dimMinusThree;
    sourceBottomRightY = dimMinusThree;
  }

  return PerspectiveTransform.quadrilateralToQuadrilateral(
      3.5f,
      3.5f,
      dimMinusThree,
      3.5f,
      sourceBottomRightX,
      sourceBottomRightY,
      3.5f,
      dimMinusThree,
      topLeft.getX(),
      topLeft.getY(),
      topRight.getX(),
      topRight.getY(),
      bottomRightX,
      bottomRightY,
      bottomLeft.getX(),
      bottomLeft.getY());
}
 
源代码17 项目: Tesseract-OCR-Scanner   文件: Detector.java
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 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 / 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,
            i);
        break;
      } catch (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
源代码18 项目: Tesseract-OCR-Scanner   文件: Detector.java
private static PerspectiveTransform createTransform(ResultPoint topLeft,
                                                    ResultPoint topRight,
                                                    ResultPoint bottomLeft,
                                                    ResultPoint alignmentPattern,
                                                    int dimension) {
  float dimMinusThree = dimension - 3.5f;
  float bottomRightX;
  float bottomRightY;
  float sourceBottomRightX;
  float sourceBottomRightY;
  if (alignmentPattern != null) {
    bottomRightX = alignmentPattern.getX();
    bottomRightY = alignmentPattern.getY();
    sourceBottomRightX = dimMinusThree - 3.0f;
    sourceBottomRightY = sourceBottomRightX;
  } else {
    // Don't have an alignment pattern, just make up the bottom-right point
    bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
    bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
    sourceBottomRightX = dimMinusThree;
    sourceBottomRightY = dimMinusThree;
  }

  return PerspectiveTransform.quadrilateralToQuadrilateral(
      3.5f,
      3.5f,
      dimMinusThree,
      3.5f,
      sourceBottomRightX,
      sourceBottomRightY,
      3.5f,
      dimMinusThree,
      topLeft.getX(),
      topLeft.getY(),
      topRight.getX(),
      topRight.getY(),
      bottomRightX,
      bottomRightY,
      bottomLeft.getX(),
      bottomLeft.getY());
}
 
源代码19 项目: QrCodeScanner   文件: Detector.java
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 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 / 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,
            i);
        break;
      } catch (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
源代码20 项目: QrCodeScanner   文件: Detector.java
private static PerspectiveTransform createTransform(ResultPoint topLeft,
                                                    ResultPoint topRight,
                                                    ResultPoint bottomLeft,
                                                    ResultPoint alignmentPattern,
                                                    int dimension) {
  float dimMinusThree = dimension - 3.5f;
  float bottomRightX;
  float bottomRightY;
  float sourceBottomRightX;
  float sourceBottomRightY;
  if (alignmentPattern != null) {
    bottomRightX = alignmentPattern.getX();
    bottomRightY = alignmentPattern.getY();
    sourceBottomRightX = dimMinusThree - 3.0f;
    sourceBottomRightY = sourceBottomRightX;
  } else {
    // Don't have an alignment pattern, just make up the bottom-right point
    bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
    bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
    sourceBottomRightX = dimMinusThree;
    sourceBottomRightY = dimMinusThree;
  }

  return PerspectiveTransform.quadrilateralToQuadrilateral(
      3.5f,
      3.5f,
      dimMinusThree,
      3.5f,
      sourceBottomRightX,
      sourceBottomRightY,
      3.5f,
      dimMinusThree,
      topLeft.getX(),
      topLeft.getY(),
      topRight.getX(),
      topRight.getY(),
      bottomRightX,
      bottomRightY,
      bottomLeft.getX(),
      bottomLeft.getY());
}
 
源代码21 项目: ZXing-Orient   文件: Detector.java
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 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 (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
源代码22 项目: ZXing-Orient   文件: Detector.java
private static PerspectiveTransform createTransform(ResultPoint topLeft,
                                                    ResultPoint topRight,
                                                    ResultPoint bottomLeft,
                                                    ResultPoint alignmentPattern,
                                                    int dimension) {
  float dimMinusThree = (float) dimension - 3.5f;
  float bottomRightX;
  float bottomRightY;
  float sourceBottomRightX;
  float sourceBottomRightY;
  if (alignmentPattern != null) {
    bottomRightX = alignmentPattern.getX();
    bottomRightY = alignmentPattern.getY();
    sourceBottomRightX = dimMinusThree - 3.0f;
    sourceBottomRightY = sourceBottomRightX;
  } else {
    // Don't have an alignment pattern, just make up the bottom-right point
    bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
    bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
    sourceBottomRightX = dimMinusThree;
    sourceBottomRightY = dimMinusThree;
  }

  return PerspectiveTransform.quadrilateralToQuadrilateral(
      3.5f,
      3.5f,
      dimMinusThree,
      3.5f,
      sourceBottomRightX,
      sourceBottomRightY,
      3.5f,
      dimMinusThree,
      topLeft.getX(),
      topLeft.getY(),
      topRight.getX(),
      topRight.getY(),
      bottomRightX,
      bottomRightY,
      bottomLeft.getX(),
      bottomLeft.getY());
}
 
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 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 (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
private static PerspectiveTransform createTransform(ResultPoint topLeft,
                                                    ResultPoint topRight,
                                                    ResultPoint bottomLeft,
                                                    ResultPoint alignmentPattern,
                                                    int dimension) {
  float dimMinusThree = (float) dimension - 3.5f;
  float bottomRightX;
  float bottomRightY;
  float sourceBottomRightX;
  float sourceBottomRightY;
  if (alignmentPattern != null) {
    bottomRightX = alignmentPattern.getX();
    bottomRightY = alignmentPattern.getY();
    sourceBottomRightX = dimMinusThree - 3.0f;
    sourceBottomRightY = sourceBottomRightX;
  } else {
    // Don't have an alignment pattern, just make up the bottom-right point
    bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
    bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
    sourceBottomRightX = dimMinusThree;
    sourceBottomRightY = dimMinusThree;
  }

  return PerspectiveTransform.quadrilateralToQuadrilateral(
      3.5f,
      3.5f,
      dimMinusThree,
      3.5f,
      sourceBottomRightX,
      sourceBottomRightY,
      3.5f,
      dimMinusThree,
      topLeft.getX(),
      topLeft.getY(),
      topRight.getX(),
      topRight.getY(),
      bottomRightX,
      bottomRightY,
      bottomLeft.getX(),
      bottomLeft.getY());
}
 
源代码25 项目: weex   文件: Detector.java
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 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 (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
源代码26 项目: weex   文件: Detector.java
private static PerspectiveTransform createTransform(ResultPoint topLeft,
                                                    ResultPoint topRight,
                                                    ResultPoint bottomLeft,
                                                    ResultPoint alignmentPattern,
                                                    int dimension) {
  float dimMinusThree = (float) dimension - 3.5f;
  float bottomRightX;
  float bottomRightY;
  float sourceBottomRightX;
  float sourceBottomRightY;
  if (alignmentPattern != null) {
    bottomRightX = alignmentPattern.getX();
    bottomRightY = alignmentPattern.getY();
    sourceBottomRightX = dimMinusThree - 3.0f;
    sourceBottomRightY = sourceBottomRightX;
  } else {
    // Don't have an alignment pattern, just make up the bottom-right point
    bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
    bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
    sourceBottomRightX = dimMinusThree;
    sourceBottomRightY = dimMinusThree;
  }

  return PerspectiveTransform.quadrilateralToQuadrilateral(
      3.5f,
      3.5f,
      dimMinusThree,
      3.5f,
      sourceBottomRightX,
      sourceBottomRightY,
      3.5f,
      dimMinusThree,
      topLeft.getX(),
      topLeft.getY(),
      topRight.getX(),
      topRight.getY(),
      bottomRightX,
      bottomRightY,
      bottomLeft.getX(),
      bottomLeft.getY());
}
 
源代码27 项目: barcodescanner-lib-aar   文件: Detector.java
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 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 / 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,
            i);
        break;
      } catch (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
源代码28 项目: barcodescanner-lib-aar   文件: Detector.java
private static PerspectiveTransform createTransform(ResultPoint topLeft,
                                                    ResultPoint topRight,
                                                    ResultPoint bottomLeft,
                                                    ResultPoint alignmentPattern,
                                                    int dimension) {
  float dimMinusThree = dimension - 3.5f;
  float bottomRightX;
  float bottomRightY;
  float sourceBottomRightX;
  float sourceBottomRightY;
  if (alignmentPattern != null) {
    bottomRightX = alignmentPattern.getX();
    bottomRightY = alignmentPattern.getY();
    sourceBottomRightX = dimMinusThree - 3.0f;
    sourceBottomRightY = sourceBottomRightX;
  } else {
    // Don't have an alignment pattern, just make up the bottom-right point
    bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
    bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
    sourceBottomRightX = dimMinusThree;
    sourceBottomRightY = dimMinusThree;
  }

  return PerspectiveTransform.quadrilateralToQuadrilateral(
      3.5f,
      3.5f,
      dimMinusThree,
      3.5f,
      sourceBottomRightX,
      sourceBottomRightY,
      3.5f,
      dimMinusThree,
      topLeft.getX(),
      topLeft.getY(),
      topRight.getX(),
      topRight.getY(),
      bottomRightX,
      bottomRightY,
      bottomLeft.getX(),
      bottomLeft.getY());
}
 
源代码29 项目: reacteu-app   文件: Detector.java
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info)
    throws NotFoundException, FormatException {

  FinderPattern topLeft = info.getTopLeft();
  FinderPattern topRight = info.getTopRight();
  FinderPattern bottomLeft = info.getBottomLeft();

  float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
  if (moduleSize < 1.0f) {
    throw NotFoundException.getNotFoundInstance();
  }
  int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
  Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
  int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

  AlignmentPattern alignmentPattern = null;
  // Anything above version 1 has an alignment pattern
  if (provisionalVersion.getAlignmentPatternCenters().length > 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 (NotFoundException re) {
        // try next round
      }
    }
    // If we didn't find alignment pattern... well try anyway without it
  }

  PerspectiveTransform transform =
      createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

  BitMatrix bits = sampleGrid(image, transform, dimension);

  ResultPoint[] points;
  if (alignmentPattern == null) {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight};
  } else {
    points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
  }
  return new DetectorResult(bits, points);
}
 
源代码30 项目: reacteu-app   文件: Detector.java
private static PerspectiveTransform createTransform(ResultPoint topLeft,
                                                    ResultPoint topRight,
                                                    ResultPoint bottomLeft,
                                                    ResultPoint alignmentPattern,
                                                    int dimension) {
  float dimMinusThree = (float) dimension - 3.5f;
  float bottomRightX;
  float bottomRightY;
  float sourceBottomRightX;
  float sourceBottomRightY;
  if (alignmentPattern != null) {
    bottomRightX = alignmentPattern.getX();
    bottomRightY = alignmentPattern.getY();
    sourceBottomRightX = dimMinusThree - 3.0f;
    sourceBottomRightY = sourceBottomRightX;
  } else {
    // Don't have an alignment pattern, just make up the bottom-right point
    bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
    bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
    sourceBottomRightX = dimMinusThree;
    sourceBottomRightY = dimMinusThree;
  }

  return PerspectiveTransform.quadrilateralToQuadrilateral(
      3.5f,
      3.5f,
      dimMinusThree,
      3.5f,
      sourceBottomRightX,
      sourceBottomRightY,
      3.5f,
      dimMinusThree,
      topLeft.getX(),
      topLeft.getY(),
      topRight.getX(),
      topRight.getY(),
      bottomRightX,
      bottomRightY,
      bottomLeft.getX(),
      bottomLeft.getY());
}
 
 类所在包
 同包方法