• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Point2d类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: processFaces

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
private void processFaces(MBFImage frame, MBFImage outframe) {
	try {
		final List<DetectedFace> faces = faceDetector.detectFaces(frame.flatten());

		if (faces == null || faces.size() == 0) {
			// move back towards center
			final int tiltPW = (TILT_CENTRE_PW - tilt.getPW()) / 5;
			tilt.changePWRelative(tiltPW);

			final int panPW = (PAN_CENTRE_PW - pan.getPW()) / 5;
			pan.changePWRelative(panPW);
		} else {
			outframe.drawShape(faces.get(0).getBounds(), RGBColour.RED);

			// move towards face
			final Point2d pt = faces.get(0).getBounds().calculateCentroid();

			final Point2d delta = pt.minus(frameCentre);

			final double damp = 0.3;

			pan.changePWRelative(-(int) (damp * delta.getX()));
			tilt.changePWRelative((int) (damp * delta.getY()));
		}
	} catch (final Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:jonhare,项目名称:ecs-summer-school-vision-lecture,代码行数:29,代码来源:InmoovDemo.java


示例17: kmeansAssignmentStep

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
private void kmeansAssignmentStep(boolean drawEvery) {
	for (int i = 0; i < points.size(); i++) {
		final Point2d pt = points.get(i);
		final int idx = assignPoint(pt);
		assignments[i] = idx;
		image.drawPoint(pt, colours[idx], 10);
		drawCentroids();

		if (drawEvery)
			updateImage();
	}
	if (!drawEvery)
		updateImage();
}
 
开发者ID:jonhare,项目名称:COMP6237,代码行数:15,代码来源:KMeansDemo.java


示例18: updateModel

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
@Override
public void updateModel(FImage image, Point2d point, PointList pointList) {
	float lineScale = normalLength * pointList.computeIntrinsicScale();
	Line2d line = connections.calculateNormalLine(point, pointList, lineScale);
	
	model.updateModel(image, line);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:8,代码来源:FNormalLandmarkModel.java


示例19: intersectionSides

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
/**
 * The intersection of this triangle with the line defined by y = mx + c.
 * The line crosses at either 0, 1 or 2 points.
 * 
 * @param line
 *            the line
 * 
 * @return the intersecting edges of the triangle and points of intersection
 */
public Map<Line2d, Point2d> intersectionSides(Line2d line) {
	final Map<Line2d, Point2d> ret = new HashMap<Line2d, Point2d>();
	final Line2d first = new Line2d(this.vertices[0], this.vertices[1]);
	final Line2d second = new Line2d(this.vertices[1], this.vertices[2]);
	final Line2d third = new Line2d(this.vertices[2], this.vertices[0]);

	addIntersect(ret, first, line);
	addIntersect(ret, second, line);
	addIntersect(ret, third, line);

	return ret;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:Triangle.java


示例20: drawPoints

import org.openimaj.math.geometry.point.Point2d; //导入依赖的package包/类
/**
 * Draw the polygon onto an image.
 * @param image the image to draw on.
 */
public void drawPoints(MBFImage image) {
	Polygon p = getPolygon();
	MBFImageRenderer renderer = image.createRenderer();

	if(p.getVertices().size() > 2) {
		renderer.drawPolygon(p, 3,RGBColour.RED);
	}

	for(Point2d point : p.getVertices()) {
		renderer.drawPoint(point, RGBColour.BLUE, 5);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:PolygonDrawingListener.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TestJEEDataFlowNodeLifeCycleControl类代码示例发布时间:2022-05-22
下一篇:
Java DragListView类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap