本文整理匯總了Java中com.google.zxing.ResultPoint.getX方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultPoint.getX方法的具體用法?Java ResultPoint.getX怎麽用?Java ResultPoint.getX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.zxing.ResultPoint
的用法示例。
在下文中一共展示了ResultPoint.getX方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sampleLine
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
/**
* Samples a line.
*
* @param p1 start point (inclusive)
* @param p2 end point (exclusive)
* @param size number of bits
* @return the array of bits as an int (first bit is high-order bit of result)
*/
private int sampleLine(ResultPoint p1, ResultPoint p2, int size) {
int result = 0;
float d = distance(p1, p2);
float moduleSize = d / size;
float px = p1.getX();
float py = p1.getY();
float dx = moduleSize * (p2.getX() - p1.getX()) / d;
float dy = moduleSize * (p2.getY() - p1.getY()) / d;
for (int i = 0; i < size; i++) {
if (image.get(MathUtils.round(px + i * dx), MathUtils.round(py + i * dy))) {
result |= 1 << (size - i - 1);
}
}
return result;
}
示例2: correctTopRight
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
private ResultPoint correctTopRight(ResultPoint bottomLeft, ResultPoint bottomRight,
ResultPoint topLeft, ResultPoint topRight, int dimension) {
float corr = ((float) distance(bottomLeft, bottomRight)) / ((float) dimension);
int norm = distance(topLeft, topRight);
ResultPoint c1 = new ResultPoint(topRight.getX() + (corr * ((topRight.getX() - topLeft
.getX()) / ((float) norm))), topRight.getY() + (corr * ((topRight.getY() -
topLeft.getY()) / ((float) norm))));
corr = ((float) distance(bottomLeft, topLeft)) / ((float) dimension);
norm = distance(bottomRight, topRight);
ResultPoint c2 = new ResultPoint(topRight.getX() + (corr * ((topRight.getX() -
bottomRight.getX()) / ((float) norm))), topRight.getY() + (corr * ((topRight.getY
() - bottomRight.getY()) / ((float) norm))));
if (isValid(c1)) {
return (!isValid(c2) || Math.abs(transitionsBetween(topLeft, c1).getTransitions() -
transitionsBetween(bottomRight, c1).getTransitions()) <= Math.abs
(transitionsBetween(topLeft, c2).getTransitions() - transitionsBetween
(bottomRight, c2).getTransitions())) ? c1 : c2;
} else {
if (isValid(c2)) {
return c2;
}
return null;
}
}
示例3: centerEdges
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z, ResultPoint x, ResultPoint t) {
float yi = y.getX();
float yj = y.getY();
float zi = z.getX();
float zj = z.getY();
float xi = x.getX();
float xj = x.getY();
float ti = t.getX();
float tj = t.getY();
if (yi < ((float) this.width) / 2.0f) {
return new ResultPoint[]{new ResultPoint(ti - 1.0f, 1.0f + tj), new ResultPoint(1.0f
+ zi, 1.0f + zj), new ResultPoint(xi - 1.0f, xj - 1.0f), new ResultPoint(1.0f
+ yi, yj - 1.0f)};
}
return new ResultPoint[]{new ResultPoint(1.0f + ti, 1.0f + tj), new ResultPoint(1.0f +
zi, zj - 1.0f), new ResultPoint(xi - 1.0f, 1.0f + xj), new ResultPoint(yi - 1.0f,
yj - 1.0f)};
}
示例4: translateResultPoints
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
ResultPoint[] oldResultPoints = result.getResultPoints();
if (oldResultPoints == null) {
return result;
}
ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
for (int i = 0; i < oldResultPoints.length; i++) {
ResultPoint oldPoint = oldResultPoints[i];
if (oldPoint != null) {
newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
}
}
Result newResult = new Result(result.getText(),
result.getRawBytes(),
result.getNumBits(),
newResultPoints,
result.getBarcodeFormat(),
result.getTimestamp());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例5: createTransform
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
private static PerspectiveTransform createTransform(ResultPoint topLeft, ResultPoint
topRight, ResultPoint bottomLeft, ResultPoint alignmentPattern, int dimension) {
float bottomRightX;
float bottomRightY;
float sourceBottomRightX;
float sourceBottomRightY;
float dimMinusThree = ((float) dimension) - 3.5f;
if (alignmentPattern != null) {
bottomRightX = alignmentPattern.getX();
bottomRightY = alignmentPattern.getY();
sourceBottomRightX = dimMinusThree - IPhotoView.DEFAULT_MAX_SCALE;
sourceBottomRightY = sourceBottomRightX;
} else {
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());
}
示例6: getRowIndicatorColumn
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
private static DetectionResultRowIndicatorColumn getRowIndicatorColumn(BitMatrix image,
BoundingBox boundingBox,
ResultPoint startPoint,
boolean leftToRight,
int minCodewordWidth,
int maxCodewordWidth) {
DetectionResultRowIndicatorColumn rowIndicatorColumn = new DetectionResultRowIndicatorColumn(boundingBox,
leftToRight);
for (int i = 0; i < 2; i++) {
int increment = i == 0 ? 1 : -1;
int startColumn = (int) startPoint.getX();
for (int imageRow = (int) startPoint.getY(); imageRow <= boundingBox.getMaxY() &&
imageRow >= boundingBox.getMinY(); imageRow += increment) {
Codeword codeword = detectCodeword(image, 0, image.getWidth(), leftToRight, startColumn, imageRow,
minCodewordWidth, maxCodewordWidth);
if (codeword != null) {
rowIndicatorColumn.setCodeword(imageRow, codeword);
if (leftToRight) {
startColumn = codeword.getStartX();
} else {
startColumn = codeword.getEndX();
}
}
}
}
return rowIndicatorColumn;
}
示例7: detect
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
/**
* <p>Detects a rectangular region of black and white -- mostly black -- with a region of mostly
* white, in an image.</p>
*
* @return {@link ResultPoint}[] describing the corners of the rectangular region. The first and
* last points are opposed on the diagonal, as are the second and third. The first point will be
* the topmost point and the last, the bottommost. The second point will be leftmost and the
* third, the rightmost
* @throws NotFoundException if no Data Matrix Code can be found
*/
public ResultPoint[] detect() throws NotFoundException {
int height = image.getHeight();
int width = image.getWidth();
int halfHeight = height / 2;
int halfWidth = width / 2;
int deltaY = Math.max(1, height / (MAX_MODULES * 8));
int deltaX = Math.max(1, width / (MAX_MODULES * 8));
int top = 0;
int bottom = height;
int left = 0;
int right = width;
ResultPoint pointA = findCornerFromCenter(halfWidth, 0, left, right,
halfHeight, -deltaY, top, bottom, halfWidth / 2);
top = (int) pointA.getY() - 1;
ResultPoint pointB = findCornerFromCenter(halfWidth, -deltaX, left, right,
halfHeight, 0, top, bottom, halfHeight / 2);
left = (int) pointB.getX() - 1;
ResultPoint pointC = findCornerFromCenter(halfWidth, deltaX, left, right,
halfHeight, 0, top, bottom, halfHeight / 2);
right = (int) pointC.getX() + 1;
ResultPoint pointD = findCornerFromCenter(halfWidth, 0, left, right,
halfHeight, deltaY, top, bottom, halfWidth / 2);
bottom = (int) pointD.getY() + 1;
// Go try to find point A again with better information -- might have been off at first.
pointA = findCornerFromCenter(halfWidth, 0, left, right,
halfHeight, -deltaY, top, bottom, halfWidth / 4);
return new ResultPoint[] { pointA, pointB, pointC, pointD };
}
示例8: makeAbsolute
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
private static void makeAbsolute(ResultPoint[] points, int leftOffset, int topOffset) {
if (points != null) {
for (int i = 0; i < points.length; i++) {
ResultPoint relative = points[i];
points[i] = new ResultPoint(relative.getX() + ((float) leftOffset), relative.getY
() + ((float) topOffset));
}
}
}
示例9: centerEdges
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
/**
* recenters the points of a constant distance towards the center
*
* @param y bottom most point
* @param z left most point
* @param x right most point
* @param t top most point
* @return {@link ResultPoint}[] describing the corners of the rectangular
* region. The first and last points are opposed on the diagonal, as
* are the second and third. The first point will be the topmost
* point and the last, the bottommost. The second point will be
* leftmost and the third, the rightmost
*/
private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z,
ResultPoint x, ResultPoint t) {
//
// t t
// z x
// x OR z
// y y
//
float yi = y.getX();
float yj = y.getY();
float zi = z.getX();
float zj = z.getY();
float xi = x.getX();
float xj = x.getY();
float ti = t.getX();
float tj = t.getY();
if (yi < width / 2.0f) {
return new ResultPoint[]{
new ResultPoint(ti - CORR, tj + CORR),
new ResultPoint(zi + CORR, zj + CORR),
new ResultPoint(xi - CORR, xj - CORR),
new ResultPoint(yi + CORR, yj - CORR)};
} else {
return new ResultPoint[]{
new ResultPoint(ti + CORR, tj + CORR),
new ResultPoint(zi + CORR, zj - CORR),
new ResultPoint(xi - CORR, xj + CORR),
new ResultPoint(yi - CORR, yj - CORR)};
}
}
示例10: makeAbsolute
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
private static void makeAbsolute(ResultPoint[] points, int leftOffset, int topOffset) {
if (points != null) {
for (int i = 0; i < points.length; i++) {
ResultPoint relative = points[i];
points[i] = new ResultPoint(relative.getX() + leftOffset, relative.getY() + topOffset);
}
}
}
示例11: correctTopRightRectangular
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
private ResultPoint correctTopRightRectangular(ResultPoint bottomLeft, ResultPoint
bottomRight, ResultPoint topLeft, ResultPoint topRight, int dimensionTop, int
dimensionRight) {
float corr = ((float) distance(bottomLeft, bottomRight)) / ((float) dimensionTop);
int norm = distance(topLeft, topRight);
ResultPoint c1 = new ResultPoint(topRight.getX() + (corr * ((topRight.getX() - topLeft
.getX()) / ((float) norm))), topRight.getY() + (corr * ((topRight.getY() -
topLeft.getY()) / ((float) norm))));
corr = ((float) distance(bottomLeft, topLeft)) / ((float) dimensionRight);
norm = distance(bottomRight, topRight);
ResultPoint c2 = new ResultPoint(topRight.getX() + (corr * ((topRight.getX() -
bottomRight.getX()) / ((float) norm))), topRight.getY() + (corr * ((topRight.getY
() - bottomRight.getY()) / ((float) norm))));
if (isValid(c1)) {
if (!isValid(c2)) {
return c1;
}
if (Math.abs(dimensionTop - transitionsBetween(topLeft, c1).getTransitions()) + Math
.abs(dimensionRight - transitionsBetween(bottomRight, c1).getTransitions())
<= Math.abs(dimensionTop - transitionsBetween(topLeft, c2).getTransitions())
+ Math.abs(dimensionRight - transitionsBetween(bottomRight, c2)
.getTransitions())) {
return c1;
}
return c2;
} else if (isValid(c2)) {
return c2;
} else {
return null;
}
}
示例12: addMissingRows
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
BoundingBox addMissingRows(int missingStartRows, int missingEndRows, boolean isLeft) throws
NotFoundException {
ResultPoint newTopLeft = this.topLeft;
ResultPoint newBottomLeft = this.bottomLeft;
ResultPoint newTopRight = this.topRight;
ResultPoint newBottomRight = this.bottomRight;
if (missingStartRows > 0) {
ResultPoint top = isLeft ? this.topLeft : this.topRight;
int newMinY = ((int) top.getY()) - missingStartRows;
if (newMinY < 0) {
newMinY = 0;
}
ResultPoint newTop = new ResultPoint(top.getX(), (float) newMinY);
if (isLeft) {
newTopLeft = newTop;
} else {
newTopRight = newTop;
}
}
if (missingEndRows > 0) {
ResultPoint bottom = isLeft ? this.bottomLeft : this.bottomRight;
int newMaxY = ((int) bottom.getY()) + missingEndRows;
if (newMaxY >= this.image.getHeight()) {
newMaxY = this.image.getHeight() - 1;
}
ResultPoint newBottom = new ResultPoint(bottom.getX(), (float) newMaxY);
if (isLeft) {
newBottomLeft = newBottom;
} else {
newBottomRight = newBottom;
}
}
calculateMinMaxValues();
return new BoundingBox(this.image, newTopLeft, newBottomLeft, newTopRight, newBottomRight);
}
示例13: processFinderPatternInfo
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info) throws
NotFoundException, FormatException {
ResultPoint topLeft = info.getTopLeft();
ResultPoint 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;
if (provisionalVersion.getAlignmentPatternCenters().length > 0) {
float correctionToTopLeft = 1.0f - (IPhotoView.DEFAULT_MAX_SCALE / ((float)
modulesBetweenFPCenters));
int estAlignmentX = (int) (topLeft.getX() + ((((topRight.getX() - topLeft.getX()) +
bottomLeft.getX()) - topLeft.getX()) * correctionToTopLeft));
int estAlignmentY = (int) (topLeft.getY() + ((((topRight.getY() - topLeft.getY()) +
bottomLeft.getY()) - topLeft.getY()) * correctionToTopLeft));
int i = 4;
while (i <= 16) {
try {
alignmentPattern = findAlignmentInRegion(moduleSize, estAlignmentX,
estAlignmentY, (float) i);
break;
} catch (NotFoundException e) {
i <<= 1;
}
}
}
return new DetectorResult(sampleGrid(this.image, createTransform(topLeft, topRight,
bottomLeft, alignmentPattern, dimension), dimension), alignmentPattern == null ?
new ResultPoint[]{bottomLeft, topLeft, topRight} : new ResultPoint[]{bottomLeft,
topLeft, topRight, alignmentPattern});
}
示例14: correctTopRightRectangular
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
/**
* Calculates the position of the white top right module using the output of the rectangle detector
* for a rectangular matrix
*/
private ResultPoint correctTopRightRectangular(ResultPoint bottomLeft,
ResultPoint bottomRight,
ResultPoint topLeft,
ResultPoint topRight,
int dimensionTop,
int dimensionRight) {
float corr = distance(bottomLeft, bottomRight) / (float)dimensionTop;
int norm = distance(topLeft, topRight);
float cos = (topRight.getX() - topLeft.getX()) / norm;
float sin = (topRight.getY() - topLeft.getY()) / norm;
ResultPoint c1 = new ResultPoint(topRight.getX()+corr*cos, topRight.getY()+corr*sin);
corr = distance(bottomLeft, topLeft) / (float)dimensionRight;
norm = distance(bottomRight, topRight);
cos = (topRight.getX() - bottomRight.getX()) / norm;
sin = (topRight.getY() - bottomRight.getY()) / norm;
ResultPoint c2 = new ResultPoint(topRight.getX()+corr*cos, topRight.getY()+corr*sin);
if (!isValid(c1)) {
if (isValid(c2)) {
return c2;
}
return null;
}
if (!isValid(c2)){
return c1;
}
int l1 = Math.abs(dimensionTop - transitionsBetween(topLeft, c1).getTransitions()) +
Math.abs(dimensionRight - transitionsBetween(bottomRight, c1).getTransitions());
int l2 = Math.abs(dimensionTop - transitionsBetween(topLeft, c2).getTransitions()) +
Math.abs(dimensionRight - transitionsBetween(bottomRight, c2).getTransitions());
if (l1 <= l2){
return c1;
}
return c2;
}
示例15: doDecodeMultiple
import com.google.zxing.ResultPoint; //導入方法依賴的package包/類
private void doDecodeMultiple(BinaryBitmap image, Map<DecodeHintType, ?> hints, List<Result>
results, int xOffset, int yOffset, int currentDepth) {
if (currentDepth <= 4) {
try {
Result result = this.delegate.decode(image, hints);
boolean alreadyFound = false;
for (Result existingResult : results) {
if (existingResult.getText().equals(result.getText())) {
alreadyFound = true;
break;
}
}
if (!alreadyFound) {
results.add(translateResultPoints(result, xOffset, yOffset));
}
ResultPoint[] resultPoints = result.getResultPoints();
if (resultPoints != null && resultPoints.length != 0) {
int width = image.getWidth();
int height = image.getHeight();
float minX = (float) width;
float minY = (float) height;
float maxX = 0.0f;
float maxY = 0.0f;
for (ResultPoint point : resultPoints) {
if (point != null) {
float x = point.getX();
float y = point.getY();
if (x < minX) {
minX = x;
}
if (y < minY) {
minY = y;
}
if (x > maxX) {
maxX = x;
}
if (y > maxY) {
maxY = y;
}
}
}
if (minX > 100.0f) {
doDecodeMultiple(image.crop(0, 0, (int) minX, height), hints, results,
xOffset, yOffset, currentDepth + 1);
}
if (minY > 100.0f) {
doDecodeMultiple(image.crop(0, 0, width, (int) minY), hints, results,
xOffset, yOffset, currentDepth + 1);
}
if (maxX < ((float) (width - 100))) {
doDecodeMultiple(image.crop((int) maxX, 0, width - ((int) maxX), height),
hints, results, xOffset + ((int) maxX), yOffset, currentDepth + 1);
}
if (maxY < ((float) (height - 100))) {
doDecodeMultiple(image.crop(0, (int) maxY, width, height - ((int) maxY)),
hints, results, xOffset, yOffset + ((int) maxY), currentDepth + 1);
}
}
} catch (ReaderException e) {
}
}
}