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

Java Point2dImpl类代码示例

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

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



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

示例1: drawTernaryPlot

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
private void drawTernaryPlot(MBFImage ret, TernaryParams params) {
	final ColourMap cm = params.getTyped(TernaryParams.COLOUR_MAP);
	final int padding = (Integer) params.getTyped(TernaryParams.PADDING);
	final Float[] bgColour = params.getTyped(TernaryParams.BG_COLOUR);
	for (int y = 0; y < height + padding; y++) {
		for (int x = 0; x < width + padding; x++) {
			final int xp = x - padding;
			final int yp = y - padding;
			final Point2dImpl point = new Point2dImpl(xp, yp);
			if (this.tri.isInside(point)) {
				final TernaryData closest = weightThreeClosest(point);
				Float[] apply = null;
				if (cm != null)
					apply = cm.apply(1 - closest.value);
				else {
					apply = new Float[] { closest.value, closest.value, closest.value };
				}

				ret.setPixel(x, y, apply);
			}
			else {
				ret.setPixel(x, y, bgColour);
			}
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:TernaryPlot.java


示例2: rotate

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的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


示例3: orientedBoundingBoxProjection

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
private FImage orientedBoundingBoxProjection(final FImage image) {
	final ProjectionProcessor<Float, FImage> pp = new ProjectionProcessor<Float,FImage>();
	Matrix trans = Matrix.identity(3, 3);
	trans = trans.times(TransformUtilities.rotationMatrix(-this.polygonEllipse.getRotation()));
	trans = trans.times(
		TransformUtilities.translateToPointMatrix(
				this.polygonEllipse.calculateCentroid(),
				new Point2dImpl(0,0))
	);
	pp.setMatrix(trans);
	pp.accumulate(image);
	return pp.performProjection(
			(int)-this.polygonEllipse.getMajor(),(int)this.polygonEllipse.getMajor(),
			(int)-this.polygonEllipse.getMinor(),(int)this.polygonEllipse.getMinor(),
			this.background
	);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:18,代码来源:OrientedPolygonExtractionProcessor.java


示例4: asPolygon

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
@Override
public Polygon asPolygon() {
	final float b = (float) Math.cos(rotation) * 0.5f;
	final float a = (float) Math.sin(rotation) * 0.5f;

	final Point2dImpl[] pts = new Point2dImpl[4];
	pts[0] = new Point2dImpl();
	pts[0].x = cx - a * height - b * width;
	pts[0].y = cy + b * height - a * width;

	pts[1] = new Point2dImpl();
	pts[1].x = cx + a * height - b * width;
	pts[1].y = cy - b * height - a * width;

	pts[2] = new Point2dImpl();
	pts[2].x = 2 * cx - pts[0].x;
	pts[2].y = 2 * cy - pts[0].y;

	pts[3] = new Point2dImpl();
	pts[3].x = 2 * cx - pts[1].x;
	pts[3].y = 2 * cy - pts[1].y;

	return new Polygon(pts);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:RotatedRectangle.java


示例5: testPolygonSecondMomentCentralised

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
/**
 * Tests for the polygon's second moments
 */
@Test
public void testPolygonSecondMomentCentralised() {
	final Polygon p = new Polygon(new Point2dImpl[] {
			new Point2dImpl(2, 0),
			new Point2dImpl(0, 4),
			new Point2dImpl(8, 8),
			new Point2dImpl(10, 4),
	});

	final double[] secondMoment = p.calculateSecondMomentCentralised();
	assertEquals(secondMoment[0], 17f / 3f, 0.0001);
	assertEquals(secondMoment[1], 2, 0.0001);
	assertEquals(secondMoment[2], 8f / 3f, 0.0001);

}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:PolygonTest.java


示例6: findSubPixCorner

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的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


示例7: computeNewBest

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
@Override
public Point2d computeNewBest(FImage image, Line2d line, int numSamples) {
	final float[] resp = computeMahalanobisWindowed(image, line, numSamples);

	final int minIdx = ArrayUtils.minIndex(resp);
	final int offset = (numSamples - nsamples) / 2;

	if (resp[offset] == resp[minIdx]) // prefer the centre over another
										// value if same response
		return line.calculateCentroid();

	// the sample line might be different, so we need to measure relative to
	// it...
	line = this.sampler.getSampleLine(line, image, numSamples);

	final float x = line.begin.getX();
	final float y = line.begin.getY();
	final float dxStep = (line.end.getX() - x) / (numSamples - 1);
	final float dyStep = (line.end.getY() - y) / (numSamples - 1);

	return new Point2dImpl(x + (minIdx + offset) * dxStep, y + (minIdx + offset) * dyStep);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:FStatisticalPixelProfileModel.java


示例8: getDistortedPoint

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的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


示例9: getUndistortedPoint

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的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


示例10: intersectionArea

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
@Override
public double intersectionArea(Shape that, int nStepsPerDimension) {
	final Rectangle overlapping = this.calculateRegularBoundingBox().overlapping(that.calculateRegularBoundingBox());
	if (overlapping == null)
		return 0;
	if (that instanceof Rectangle) {
		// Special case
		return overlapping.calculateArea();
	} else {
		double intersection = 0;
		final double step = Math.max(overlapping.width, overlapping.height) / (double) nStepsPerDimension;
		double nReads = 0;
		for (float x = overlapping.x; x < overlapping.x + overlapping.width; x += step) {
			for (float y = overlapping.y; y < overlapping.y + overlapping.height; y += step) {
				final boolean insideThis = this.isInside(new Point2dImpl(x, y));
				final boolean insideThat = that.isInside(new Point2dImpl(x, y));
				nReads++;
				if (insideThis && insideThat) {
					intersection++;
				}
			}
		}

		return (intersection / nReads) * (overlapping.width * overlapping.height);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:Rectangle.java


示例11: asPolygon

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
@Override
public Polygon asPolygon() {
	final Polygon poly = new Polygon();
	final Point2dImpl[] v = new Point2dImpl[360];
	for (int i = 0; i < 90; i++) {
		final double theta = Math.toRadians(i);
		final float xx = (float) (radius * Math.cos(theta));
		final float yy = (float) (radius * Math.sin(theta));
		v[i] = new Point2dImpl(xx, yy);
		v[i + 90] = new Point2dImpl(-yy, xx);
		v[i + 180] = new Point2dImpl(-xx, -yy);
		v[i + 270] = new Point2dImpl(yy, -xx);
	}

	for (int i = 0; i < 360; i++)
		poly.points.add(v[i]);

	poly.translate(centre.getX(), centre.getY());

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


示例12: doTutorial

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
@Override
public void doTutorial(MBFImage toDraw) {
	List<KEDetectedFace> faces = this.detector.detectFaces(toDraw.flatten());
	
	for (KEDetectedFace detectedFace : faces) {
		Rectangle b = detectedFace.getBounds();
		Point2dImpl bp = new Point2dImpl(b.x,b.y);
		toDraw.drawShape(b, RGBColour.RED);
		FacialKeypoint[] kpts = detectedFace.getKeypoints();
		List<Point2d> fpts = new ArrayList<Point2d>();
		for(FacialKeypoint kpt : kpts){
			Point2dImpl p = kpt.position;
			p.translate(bp);
			fpts.add(p);
		}
		toDraw.drawPoints(fpts, RGBColour.GREEN, 3);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:FaceKETrackingTutorial.java


示例13: intersectionArea

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
@Override
public double intersectionArea(Shape that, int nStepsPerDimention) {
	final Rectangle overlapping = this.calculateRegularBoundingBox().overlapping(that.calculateRegularBoundingBox());
	if (overlapping == null)
		return 0;
	double intersection = 0;
	final double step = Math.max(overlapping.width, overlapping.height) / (double) nStepsPerDimention;
	double nReads = 0;
	for (float x = overlapping.x; x < overlapping.x + overlapping.width; x += step) {
		for (float y = overlapping.y; y < overlapping.y + overlapping.height; y += step) {
			final boolean insideThis = this.isInside(new Point2dImpl(x, y));
			final boolean insideThat = that.isInside(new Point2dImpl(x, y));
			nReads++;
			if (insideThis && insideThat) {
				intersection++;
			}
		}
	}

	return (intersection / nReads) * (overlapping.width * overlapping.height);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:Circle.java


示例14: difference

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
/**
 * Calculates the difference between two polygons and returns a new polygon.
 * It assumes that the given polygon and this polygon have the same number
 * of vertices.
 *
 * @param p
 *            the polygon to subtract.
 * @return the difference polygon
 */
public Polygon difference(Polygon p) {
	final List<Point2d> v = new ArrayList<Point2d>();

	for (int i = 0; i < nVertices(); i++)
		v.add(new Point2dImpl(
				points.get(i).getX() - p.points.get(i).getX(),
				points.get(i).getY() - p.points.get(i).getY()));

	final Polygon p2 = new Polygon(v);
	for (int i = 0; i < innerPolygons.size(); i++)
		p2.addInnerPolygon(innerPolygons.get(i).difference(
				p2.getInnerPoly(i + 1)));

	return p2;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:Polygon.java


示例15: readASCII

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
@Override
public void readASCII(Scanner in) throws IOException {
	this.gridWidth = in.nextInt();
	this.gridHeight = in.nextInt();
	this.visibleArea = new Rectangle(in.nextFloat(),in.nextFloat(),in.nextFloat(),in.nextFloat());
	this.touchArray = new ArrayList<Point2d>();
	while(in.hasNext()){
		this.touchArray.add(
				new Point2dImpl(in.nextFloat(),in.nextFloat())
		);
	}
	this.createScreenArray();
	this.createTriangles();
	this.createNonLinearWarp();
	
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:TriangleCameraConfig.java


示例16: iterate

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
public void iterate() {
		PointList newCurve = nextHalfCurve();
		Collections.reverse(newCurve.points);
		for (Point2d point2d : this.currentCurve) {
			if(!point2d.equals(this.startOfDragon))
				newCurve.points.add(point2d);
		}
		Point2dImpl minXY = minXY(newCurve);
		Point2dImpl maxXY = maxXY(newCurve);
		double bbScalar = Math.max(maxXY.x - minXY.x,maxXY.y - minXY.y);
		Matrix translateToPointMatrix = TransformUtilities.translateToPointMatrix(
				minXY,
				new Point2dImpl(1/3f,1/3f)
		);
		Matrix translate = translateToPointMatrix;
		float d = (float) ((1/3f)/bbScalar);
		Matrix scale = TransformUtilities.scaleMatrix(d, d);
		Matrix transform = translate.times(scale);
//		Matrix transform = translate;
		newCurve = newCurve.transform(transform);
		this.currentCurve = newCurve;
		this.startOfDragon = newCurve.points.get(0);
		this.endOfDragon = newCurve.points.get(newCurve.points.size()-1);
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:DragonCurve.java


示例17: readPts

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
static PointList readPts(File file) throws IOException {
	PointList pl = new PointList();
	BufferedReader br = new BufferedReader(new FileReader(file));

	br.readLine();
	br.readLine();
	br.readLine();

	String line;
	while ((line = br.readLine()) != null) {
		if (!line.startsWith("}") && line.trim().length() > 0) {
			String[] parts = line.split("\\s+");

			float x = Float.parseFloat(parts[0].trim());
			float y = Float.parseFloat(parts[1].trim());

			pl.points.add(new Point2dImpl(x, y));
		}
	}
	br.close();

	return pl;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:PDMPlayground3.java


示例18: readAMPTSPts

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
private PointList readAMPTSPts(File file) throws IOException {
	final PointList pl = new PointList();
	final BufferedReader br = new BufferedReader(new FileReader(file));

	br.readLine();
	br.readLine();
	br.readLine();

	String line;
	while ((line = br.readLine()) != null) {
		if (!line.startsWith("}") && line.trim().length() > 0) {
			final String[] parts = line.split("\\s+");

			final float x = Float.parseFloat(parts[0].trim());
			final float y = Float.parseFloat(parts[1].trim());

			pl.points.add(new Point2dImpl(x, y));
		}
	}
	br.close();

	return pl;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:AMPTSDataset.java


示例19: TernaryPlot

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
/**
 * @param width
 * @param data
 */
public TernaryPlot(float width, List<TernaryData> data) {
	this.width = width;
	this.height = (float) Math.sqrt((width * width) - ((width * width) / 4));
	pointA = new Point2dImpl(0, height);
	pointB = new Point2dImpl(width, height);
	pointC = new Point2dImpl(width / 2, 0);

	this.tri = new Triangle(new Point2d[] {
			pointA,
			pointB,
			pointC,
	});

	this.data = data;
	if (data.size() > 2) {
		this.dataTriangles = new TrenaryDataTriangles(data);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:TernaryPlot.java


示例20: testDataGenerator

import org.openimaj.math.geometry.point.Point2dImpl; //导入依赖的package包/类
/**
 *
 */
@Test
public void testDataGenerator() {
	final LinearPerceptronDataGenerator dg = new LinearPerceptronDataGenerator(100, 10, 0.3, 1);
	final Vector origin = dg.getOrigin();
	final Vector dir = dg.getNormDirection();
	// Point2d lineStart =
	start(origin, dir);
	// Point2d lineEnd =
	end(origin, dir);

	for (int i = 0; i < 100; i++) {
		final IndependentPair<double[], PerceptronClass> pointClass = dg.generate();

		final double[] pc = pointClass.firstObject();
		final Point2dImpl point = new Point2dImpl((float) pc[0], (float) pc[1]);
		final PerceptronClass cls = pointClass.getSecondObject();
		System.out.println(String.format("%s: %s", point, cls));
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:TestLinearPerceptronDataGenerator.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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