本文整理汇总了Java中org.openimaj.math.geometry.point.Point2d.getY方法的典型用法代码示例。如果您正苦于以下问题:Java Point2d.getY方法的具体用法?Java Point2d.getY怎么用?Java Point2d.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.math.geometry.point.Point2d
的用法示例。
在下文中一共展示了Point2d.getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: computeResidual
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public double computeResidual(IndependentPair<Point2d, Point2d> data) {
final Matrix F = model.fundamental;
final Point2d p1 = data.firstObject();
final Point2d p2 = data.secondObject();
final float x1_1 = p1.getX(); // u
final float x1_2 = p1.getY(); // v
final float x2_1 = p2.getX(); // u'
final float x2_2 = p2.getY(); // v'
double res = 0;
res += F.get(0, 0) * x2_1 * x1_1; // u' * u
res += F.get(0, 1) * x2_1 * x1_2; // u' * v
res += F.get(0, 2) * x2_1; // u'
res += F.get(1, 0) * x2_2 * x1_1; // v' * u
res += F.get(1, 1) * x2_2 * x1_2; // v' * v
res += F.get(1, 2) * x2_2; // v'
res += F.get(2, 0) * x1_1; // u
res += F.get(2, 1) * x1_2; // v
res += F.get(2, 2); // 1
return res * res;
}
示例3: buildDataMatrix
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
private Matrix buildDataMatrix(List<PointList> data) {
final int nData = data.size();
final int nPoints = data.get(0).size();
final Matrix m = new Matrix(nData, nPoints * 2);
final double[][] mData = m.getArray();
for (int i = 0; i < nData; i++) {
final PointList pts = data.get(i);
for (int j = 0, k = 0; k < nPoints; j += 2, k++) {
final Point2d pt = pts.points.get(k);
mData[i][j] = pt.getX();
mData[i][j + 1] = pt.getY();
}
}
return m;
}
示例4: isInside
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public boolean isInside(Point2d point) {
// Unrotate the point relative to the center of the ellipse
final double cosrot = Math.cos(-rotation);
final double sinrot = Math.sin(-rotation);
final double relx = (point.getX() - x);
final double rely = (point.getY() - y);
final double xt = cosrot * relx - sinrot * rely;
final double yt = sinrot * relx + cosrot * rely;
final double ratiox = xt / major;
final double ratioy = yt / minor;
return ratiox * ratiox + ratioy * ratioy <= 1;
}
示例5: computeResidual
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public double computeResidual(IndependentPair<Point2d, Point2d> data) {
final Point2d p2_est = model.predict(data.firstObject());
final float dx = data.secondObject().getX() - p2_est.getX();
final float dy = data.secondObject().getY() - p2_est.getY();
return (dx * dx + dy * dy);
}
示例6: fundamentalMatrix8Pt
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* The un-normalised 8-point algorithm for estimation of the Fundamental
* matrix. Only use with pre-normalised data!
*
* @param data
* @return the estimated Fundamental matrix
*/
public static Matrix fundamentalMatrix8Pt(List<? extends IndependentPair<Point2d, Point2d>> data) {
Matrix A;
A = new Matrix(data.size(), 9);
for (int i = 0; i < data.size(); i++) {
final Point2d p1 = data.get(i).firstObject();
final Point2d p2 = data.get(i).secondObject();
final float x1_1 = p1.getX(); // u
final float x1_2 = p1.getY(); // v
final float x2_1 = p2.getX(); // u'
final float x2_2 = p2.getY(); // v'
A.set(i, 0, x2_1 * x1_1); // u' * u
A.set(i, 1, x2_1 * x1_2); // u' * v
A.set(i, 2, x2_1); // u'
A.set(i, 3, x2_2 * x1_1); // v' * u
A.set(i, 4, x2_2 * x1_2); // v' * v
A.set(i, 5, x2_2); // v'
A.set(i, 6, x1_1); // u
A.set(i, 7, x1_2); // v
A.set(i, 8, 1); // 1
}
final double[] W = MatrixUtils.solveHomogeneousSystem(A);
Matrix fundamental = new Matrix(3, 3);
fundamental.set(0, 0, W[0]);
fundamental.set(0, 1, W[1]);
fundamental.set(0, 2, W[2]);
fundamental.set(1, 0, W[3]);
fundamental.set(1, 1, W[4]);
fundamental.set(1, 2, W[5]);
fundamental.set(2, 0, W[6]);
fundamental.set(2, 1, W[7]);
fundamental.set(2, 2, W[8]);
fundamental = MatrixUtils.reduceRank(fundamental, 2);
return fundamental;
}
示例7: drawCubicBezier
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* Draw a cubic Bezier curve into the image with 100 point accuracy.
*
* @param p1
* One end point of the line
* @param p2
* The other end point of the line
* @param c1
* The control point associated with p1
* @param c2
* The control point associated with p2
* @param thickness
* The thickness to draw the line
* @param col
* The colour to draw the line
* @return The points along the bezier curve
*/
public Point2d[] drawCubicBezier(final Point2d p1, final Point2d p2,
final Point2d c1, final Point2d c2, final int thickness, final Q col)
{
final List<Point2d> points = new ArrayList<Point2d>();
final CubicCurve2D c = new CubicCurve2D.Double(
p1.getX(), p1.getY(), c1.getX(), c1.getY(),
c2.getX(), c2.getY(), p2.getX(), p2.getY());
BezierUtils.adaptiveHalving(c, new SimpleConvexHullSubdivCriterion(),
new CubicSegmentConsumer()
{
@Override
public void processSegment(final CubicCurve2D segment,
final double startT, final double endT)
{
if (0.0 == startT)
points.add(new Point2dImpl(
(float) segment.getX1(), (float) segment.getY1()));
points.add(new Point2dImpl(
(float) segment.getX2(), (float) segment.getY2()));
}
});
Point2d last = null;
for (final Point2d p : points) {
if (last != null)
this.drawLine((int) last.getX(), (int) last.getY(),
(int) p.getX(), (int) p.getY(), thickness, col);
last = p;
}
return points.toArray(new Point2d[1]);
}
示例8: drawQuadBezier
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* Draw a Quadratic Bezier curve
*
* @param p1
* @param p2
* @param c1
* @param thickness
* @param colour
* @return a set of points on the curve
*/
public Point2d[] drawQuadBezier(final Point2d p1, final Point2d p2, final Point2d c1,
final int thickness, final Q colour)
{
final List<Point2d> points = new ArrayList<Point2d>();
final QuadCurve2D c = new QuadCurve2D.Double(
p1.getX(), p1.getY(), c1.getX(), c1.getY(), p2.getX(), p2.getY());
BezierUtils.adaptiveHalving(c, new SimpleConvexHullSubdivCriterion(),
new QuadSegmentConsumer()
{
@Override
public void processSegment(final QuadCurve2D segment, final double startT, final double endT) {
if (0.0 == startT)
points.add(new Point2dImpl(
(float) segment.getX1(), (float) segment.getY1()));
points.add(new Point2dImpl(
(float) segment.getX2(), (float) segment.getY2()));
}
});
Point2d last = null;
for (final Point2d p : points) {
if (last != null)
this.drawLine((int) last.getX(), (int) last.getY(),
(int) p.getX(), (int) p.getY(), thickness, colour);
last = p;
}
return points.toArray(new Point2d[1]);
}
示例9: computeScale
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
protected static double computeScale(PointList pl, double tx, double ty) {
double scale = 0;
for (Point2d pt : pl) {
double x = pt.getX() - tx;
double y = pt.getY() - ty;
scale += x*x + y*y;
}
scale = Math.sqrt(scale / pl.points.size());
return 1.0 / scale;
}
示例10: computeResidual
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public double computeResidual(IndependentPair<Point2d, Point2d> data) {
final Point2d p2_est = model.predict(data.firstObject()).transform(t1);
final Point2d so = data.secondObject().transform(t2);
final float dx = so.getX() - p2_est.getX();
final float dy = so.getY() - p2_est.getY();
return (dx * dx + dy * dy);
}
示例11: computeResiduals
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public void computeResiduals(List<? extends IndependentPair<Point2d, Point2d>> data, double[] errors) {
for (int i = 0; i < data.size(); i++) {
final Point2d p2_est = model.predict(data.get(i).firstObject()).transform(t1);
final Point2d so = data.get(i).secondObject().transform(t2);
final float dx = so.getX() - p2_est.getX();
final float dy = so.getY() - p2_est.getY();
errors[i] = (dx * dx + dy * dy);
}
}
示例12: minus
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public Point2d minus(Point2d a) {
final Keypoint kp = this.clone();
kp.x = this.x - (int) a.getX();
kp.y = this.y - (int) a.getY();
return null;
}
示例13: calculateHomography
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* Calculates the point pairing for a given distorted polygon into
* orthogonal space.
*
* @param p
* The polygon with 4 points
* @return A list of point pairs
*/
public List<IndependentPair<Point2d, Point2d>> calculateHomography(Polygon p)
{
// Our output list
final List<IndependentPair<Point2d, Point2d>> pointPairs = new
ArrayList<IndependentPair<Point2d, Point2d>>();
// Get the vertices
//
// p1----------p4
// | |
// p2----------p3
//
final List<Point2d> v = p.getVertices();
final Point2d p1 = v.get(0);
final Point2d p2 = v.get(1);
final Point2d p3 = v.get(2);
final Point2d p4 = v.get(3);
// Mapped vertices
final Point2d p1p = new Point2dImpl(p2.getX(), p1.getY()); // vertical
// above p2
final Point2d p2p = v.get(1); // don't move
final Point2d p3p = new Point2dImpl(p3.getX(), p2.getY()); // horizontal
// from p2
final Point2d p4p = new Point2dImpl(p3p.getX(), p1.getY()); // vertical
// above p3
pointPairs.add(new IndependentPair<Point2d, Point2d>(p1, p1p));
pointPairs.add(new IndependentPair<Point2d, Point2d>(p2, p2p));
pointPairs.add(new IndependentPair<Point2d, Point2d>(p3, p3p));
pointPairs.add(new IndependentPair<Point2d, Point2d>(p4, p4p));
return pointPairs;
}
示例14: toFloatArray
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
private void toFloatArray(Point2d pt, float[] arr) {
arr[0] = pt.getX();
arr[1] = pt.getY();
}
示例15: align
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* Align the given shape to the reference. The alignment
* happens inplace, so the input points are modified. The
* matrix used to transform the points is returned.
*
* @param toAlign transform matrix
* @return aligned points (reference to toAlign)
* @throws IllegalArgumentException if the input is null or has a
* different size to the reference.
*/
public Matrix align(PointList toAlign) {
if (toAlign.points.size() != reference.points.size())
throw new IllegalArgumentException("Point lists are different lengths");
//translation
Point2d cog = toAlign.calculateCentroid();
Matrix trans = TransformUtilities.translateToPointMatrix(cog, this.referenceCog);
toAlign.translate((float)trans.get(0,2), (float)trans.get(1,2));
//scaling
double scale = computeScale(toAlign, referenceCog.getX(), referenceCog.getY());
float sf = (float)(scale / this.scaling);
toAlign.scale(referenceCog, sf);
//rotation
double theta = 0;
if (rotate) {
float num = 0;
float den = 0;
final int count = reference.points.size();
for (int i=0; i<count; i++) {
Point2d p1 = reference.points.get(i);
Point2d p2 = toAlign.points.get(i);
float p1x = (float) (p1.getX());
float p1y = (float) (p1.getY());
float p2x = (float) (p2.getX());
float p2y = (float) (p2.getY());
num += p2x*p1y - p2y*p1x;
den += p2x*p1x + p2y*p1y;
}
theta = Math.atan2(num, den);
toAlign.rotate(this.referenceCog, theta);
}
//compute matrix
Matrix scaleMat = TransformUtilities.scaleMatrixAboutPoint(sf, sf, this.referenceCog);
Matrix rotMat = TransformUtilities.rotationMatrixAboutPoint(theta, this.referenceCog.getX(), this.referenceCog.getY());
return rotMat.times(scaleMat).times(trans);
}