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


Java Point2d类代码示例

本文整理汇总了Java中org.openimaj.math.geometry.point.Point2d的典型用法代码示例。如果您正苦于以下问题:Java Point2d类的具体用法?Java Point2d怎么用?Java Point2d使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Point2d类属于org.openimaj.math.geometry.point包,在下文中一共展示了Point2d类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findSubPixCorner

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
/**
 * Find the sub-pixel estimated position of a corner
 * 
 * @param src
 *            the image
 * @param corner
 *            the initial corner position
 * @return the updated corner position
 */
public Point2dImpl findSubPixCorner(FImage src, Point2d corner)
{
	final int windowWidth = halfWidth * 2 + 1;
	final int windowHeight = halfHeight * 2 + 1;

	final FImage weights = this.buildGaussianWeights(windowWidth, windowHeight);
	final FImage gx = new FImage(windowWidth, windowHeight);
	final FImage gy = new FImage(windowWidth, windowHeight);
	final float[] buffer = new float[windowWidth + 2];

	// note 2px padding as conv reduces size:
	final FImage roi = new FImage(windowWidth + 2, windowHeight + 2);

	return this.findCornerSubPix(src, corner, roi, gx, gy, weights, buffer);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:SubPixelCorners.java

示例2: getDistortedPoint

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
private Point2d getDistortedPoint(Point2d point) {
	// this pixel relative to the padding
	float paddingX = point.getX();
	float paddingY = point.getY();
	// Normalise x and y such that they are in a -1 to 1 range
	float normX = (paddingX - midX) / (image.getWidth() / 2.0f);
	float normY = (paddingY - midY) / (image.getHeight() / 2.0f);

	float radius2 = normX * normX + normY * normY;
	float radius4 = radius2 * radius2;

	float xRatio = normX / (1 - alphaX * radius2 - betaX * radius4);
	float yRatio = normY / (1 - alphaY * radius2 - betaY * radius4);

	float radiusRatio2 = xRatio * xRatio + yRatio * yRatio;
	float radiusRatio4 = radiusRatio2 * radiusRatio2;

	float normDistortedX = normX
			/ (1 - alphaX * radiusRatio2 - betaX * radiusRatio4);
	float normDistortedY = normY
			/ (1 - alphaY * radiusRatio2 - betaY * radiusRatio4);

	float distortedX = ((1 + normDistortedX) / 2) * image.getWidth();
	float distortedY = ((1 + normDistortedY) / 2) * image.getHeight();
	return new Point2dImpl(distortedX, distortedY);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:RadialDistortionCalibrator.java

示例3: getUndistortedPoint

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
/**
 * Compute the transformed point for a given point
 * @param point the input point
 * @return the transformed point
 */
public Point2d getUndistortedPoint(Point2d point) {
	// this pixel relative to the padding
	float x = point.getX();
	float y = point.getY();
	// Normalise x and y such that they are in a -1 to 1 range
	float normX = (x - origMidX) / (outImage.getWidth() / 2.0f);
	float normY = (y - origMidY) / (outImage.getHeight() / 2.0f);

	float radius2 = normX * normX + normY * normY;
	float radius4 = radius2 * radius2;

	float normundistortedX = normX - alphaX * normX * radius2 - betaX
			* normX * radius4;
	float normundistortedY = normY - alphaY * normY * radius2 - betaY
			* normY * radius4;

	float undistortedX = ((1 + normundistortedX) / 2) * outImage.getWidth();
	float undistortedY = ((1 + normundistortedY) / 2)
			* outImage.getHeight();
	return new Point2dImpl(undistortedX, undistortedY);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:RadialDistortionCalibrator.java

示例4: acceptTouch

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
@Override
public void acceptTouch(List<Touch> filtered) {
	final Point2d pixelToAdd = filtered.get(0).calculateCentroid();
	Point2d lastPointAdded = null;
	if (this.touchArray.size() != 0)
		lastPointAdded = this.touchArray.get(this.touchArray.size() - 1);
	if (lastPointAdded == null ||
			Line2d.distance(pixelToAdd, lastPointAdded) > TouchTableDemo.SMALLEST_POINT_DIAMETER)
	{
		this.touchArray.add(pixelToAdd);
	}

	if (this.touchArray.size() == this.gridxy) {
		calibrate();
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:TouchTableScreen.java

示例5: value

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
RealVector value(double[] params) {
	final double[] result = new double[data.size()];

	for (int i = 0; i < data.size(); i++) {
		final IndependentPair<? extends Point2d, ? extends Point2d> pair = data.get(i);
		final Point2d p1 = pair.firstObject();
		final Point2d p2 = pair.secondObject();
		final double x = p1.getX();
		final double y = p1.getY();
		final double X = p2.getX();
		final double Y = p2.getY();

		result[i] = computeValue(x, y, X, Y, params[0], params[1], params[2], params[3], params[4], params[5],
				params[6], params[7]);
	}

	return new ArrayRealVector(result, false);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:FundamentalRefinement.java

示例6: calibrate

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
private void calibrate() {
	final HomographyModel m = new HomographyModel();
	final List<IndependentPair<Point2d, Point2d>> matches = new ArrayList<IndependentPair<Point2d, Point2d>>();

	matches.add(IndependentPair.pair(TOP_LEFT, this.touchArray.get(0)));
	matches.add(IndependentPair.pair(TOP_RIGHT, this.touchArray.get(1)));
	matches.add(IndependentPair.pair(BOTTOM_LEFT, this.touchArray.get(2)));
	matches.add(IndependentPair.pair(BOTTOM_RIGHT, this.touchArray.get(3)));
	final HomographyCameraConfig cameraConfig = new HomographyCameraConfig(
			4.9736307741305950e+002f, 4.9705029823649602e+002f,
			touchScreen.inputArea.width / 2, touchScreen.inputArea.height / 2,
			5.8322574816106650e-002f, -1.7482068549377444e-001f,
			-3.1083477039117124e-003f, -4.3781939644044129e-003f
			);
	m.estimate(matches);
	cameraConfig.homography = m.getTransform().inverse();
	touchScreen.cameraConfig = cameraConfig;
	touchScreen.mode = new Mode.DRAWING(touchScreen);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:TouchTableScreen.java

示例7: render

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
protected FImage render(List<IndependentPair<String, Point2d>> pts, int sz) {
	FImage image = new FImage(sz, sz);
	FImageRenderer renderer = image.createRenderer(RenderHints.ANTI_ALIASED);


	for (IndependentPair<String, Point2d> pair : pts) {
		double x = pair.secondObject().getX();
		double y = pair.secondObject().getY();

		int ix = (int) Math.round((x + 0.5) * sz/2);
		int iy = (int) Math.round((y + 0.5) * sz/2);

		renderer.drawShapeFilled(new Circle(ix, iy, 2), 1f);
		renderer.drawText(pair.firstObject(), ix+5, iy, HersheyFont.TIMES_MEDIUM, 20, 1f);
	}
	
	return image;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:MDS.java

示例8: rotate

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
/**
 * Rotate the {@link Rectangle} about the given pivot with the given angle
 * (in radians)
 *
 * @param p
 *            the pivot of the rotation
 * @param angle
 *            the angle in radians
 * @return the rotated rectangle
 */
public RotatedRectangle rotate(Point2d p, double angle) {
	final Point2dImpl c = (Point2dImpl) this.calculateCentroid();
	final float sin = (float) Math.sin(angle);
	final float cos = (float) Math.cos(angle);

	c.translate(-p.getX(), -p.getY());

	final float xnew = c.x * cos - c.y * sin;
	final float ynew = c.x * sin + c.y * cos;

	c.x = xnew;
	c.y = ynew;

	c.translate(p);

	return new RotatedRectangle(c.x, c.y, width, height, angle);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:28,代码来源:Rectangle.java

示例9: applyDistortion

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
/**
 * Apply the radial and tangential distortion of this camera to the given
 * projected point (presumably computed by projecting a world point through
 * the homography defined by the extrinsic parameters of a camera). The
 * point is modified in-place.
 * 
 * @param p
 *            the projected point
 * @return the input point (with the distortion added)
 */
public Point2d applyDistortion(Point2d p) {
	final double dx = (p.getX() - getPrincipalPointX()) / getFocalLengthX();
	final double dy = (p.getY() - getPrincipalPointY()) / getFocalLengthY();
	final double r2 = dx * dx + dy * dy;
	final double r4 = r2 * r2;
	final double r6 = r2 * r2 * r2;

	// radial component
	double tx = dx * (k1 * r2 + k2 * r4 + k3 * r6);
	double ty = dy * (k1 * r2 + k2 * r4 + k3 * r6);

	// tangential component
	tx += 2 * p1 * dx * dy + p2 * (r2 + 2 * dx * dx);
	ty += p1 * (r2 + 2 * dy * dy) + 2 * p2 * dx * dy;

	p.translate((float) tx, (float) ty);
	return p;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:29,代码来源:CameraIntrinsics.java

示例10: findTips

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
private static List<Point2d> findTips(List<ConvexityDefect> defects) {
	final ArrayList<Point2d> fingerTips = new ArrayList<Point2d>();

	for (int i = 0; i < defects.size(); i++) {
		if (defects.get(i).depth < MIN_FINGER_DEPTH) // defect too shallow
			continue;

		// look at fold points on either side of a tip
		final int prevIdx = (i == 0) ? (defects.size() - 1) : (i - 1);
		final int nextIdx = (i == defects.size() - 1) ? 0 : (i + 1);

		final int angle = angleBetween(defects.get(i).start, defects.get(prevIdx).deepestPoint,
				defects.get(nextIdx).deepestPoint);
		if (angle >= MAX_FINGER_ANGLE)
			continue; // angle between finger and folds too wide

		// this point is probably a fingertip, so add to list
		fingerTips.add(defects.get(i).start);
	}

	return fingerTips;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:Fingers.java

示例11: distanceFromAxis

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
/**
 * 	calculate the distance from the gradient axis.
 *	@param lx A point on the gradient axis - x coordinate
 *	@param ly A point on the gradient axis - y coordinate
 *	@param angle The angle of the axis
 *	@param x The x position to find the distance
 *	@param y The y position to find the distance
 *	@param scalar The scalar for the final vector
 *	@return
 */
private double distanceFromAxis( final double lx, final double ly, final double angle,
                 final double x, final double y, final double scalar )
         {
	// See http://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
	final Line2d line = Line2d.lineFromRotation( (int)lx, (int)ly, angle, 1 );
	final Point2d A = line.begin;
	final Point2d B = line.end;
	final Point2dImpl P = new Point2dImpl( (float)x, (float)y );
	final double normalLength = Math.hypot(B.getX() - A.getX(), B.getY() - A.getY());
	double grad = Math.abs((P.x - A.getX()) * (B.getY() - A.getY()) - (P.y - A.getY()) *
			(B.getX() - A.getX())) / normalLength / scalar;
	if( grad < 0 ) grad = 0;
	if( grad > 1 ) grad = 1;
	return grad;
         }
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:MatteGenerator.java

示例12: runFortune

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
List<Line2d> runFortune(List<? extends Point2d> points) {
	for (final Point2d pt : points)
		sites.add(new ComparablePoint(pt));

	// Process the queues; select the top element with smaller x
	// coordinate.
	while (sites.size() > 0) {
		if ((events.size() > 0) && ((events.peek().xpos) <= (((ComparablePoint) sites.peek()).x))) {
			processCircleEvent(events.poll());
		} else {
			// process a site event by adding a curve to the parabolic
			// front
			frontInsert((ComparablePoint) sites.poll());
		}
	}

	// After all points are processed, do the remaining circle events.
	while (events.size() > 0) {
		processCircleEvent(events.poll());
	}

	// Clean up dangling edges.
	finishEdges();

	return output;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:Voronoi.java

示例13: drawMatches

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
/**
 * Draw matches between two images in the given colour.
 * Places the images side-by-side and draws a line
 * for each match.
 *
 * @param <T> Pixel type
 * @param <I> Image type
 * @param im1 first image
 * @param im2 second image
 * @param matches matched features between images
 * @param col the colour to draw in
 * @return image drawn on
 */
public static <T, I extends Image<T,I>> I drawMatches(I im1, I im2, List<? extends Pair<? extends Point2d>> matches, T col) {
	int newwidth = im1.getWidth() + im2.getWidth();
	int newheight = Math.max(im1.getHeight(), im2.getHeight());

	I out = im1.newInstance(newwidth, newheight);
	ImageRenderer<T, I> renderer = out.createRenderer();
	renderer.drawImage(im1, 0, 0);
	renderer.drawImage(im2, im1.getWidth(), 0);

	if (matches!=null) {
		for (Pair<? extends Point2d> p : matches) {
			renderer.drawLine(	(int)p.firstObject().getX() + im1.getWidth(),
							(int)p.firstObject().getY(),
							(int)p.secondObject().getX(),
							(int)p.secondObject().getY(),
							1,col);
		}
	}

	return out;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:35,代码来源:MatchingUtilities.java

示例14: alignPointsAndAverage

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
protected static PointList alignPointsAndAverage(List<PointList> shapes, PointList reference, double referenceScaling, Point2d referenceCog) {
	ProcrustesAnalysis pa = new ProcrustesAnalysis(reference);
	
	for (PointList shape : shapes) {
		pa.align(shape);
	}
	
	PointList mean = PointList.computeMean(shapes);
	
	//normalise translation to reference
	Point2d cog = mean.calculateCentroid();
	Matrix trans = TransformUtilities.translateToPointMatrix(cog, referenceCog);
	mean.translate((float)trans.get(0,2), (float)trans.get(1,2));
			
	//normalise scaling to reference
	double scale = ProcrustesAnalysis.computeScale(mean, referenceCog.getX(), referenceCog.getY());
	float sf = (float)(scale / referenceScaling);
	mean.scale(referenceCog, sf);
	
	return mean;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:GeneralisedProcrustesAnalysis.java

示例15: testScalingClosed

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
/**
 * Test polygon scaling
 */
@Test
public void testScalingClosed() {
	final float distance = 10.0f;
	final float factor = 1.5f;
	final Polygon polygon = new Polygon();
	polygon.addVertex(-distance, -distance);
	polygon.addVertex(-distance, distance);
	polygon.addVertex(distance, distance);
	polygon.addVertex(distance, -distance);
	polygon.close();
	polygon.scale(factor);
	final List<Point2d> vertices = polygon.getVertices();
	for (final Point2d vertex : vertices) {
		assertEquals(distance * factor, Math.abs(vertex.getX()), 0.1);
		assertEquals(distance * factor, Math.abs(vertex.getY()), 0.1);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:PolygonTest.java


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