use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.
the class Lines method getMeanPoint.
public static Point getMeanPoint(List<Line> lines) {
if (lines.size() == 0)
return null;
double x = 0;
double y = 0;
for (Line line : lines) {
x += line.center().x;
y += line.center().y;
}
return new Point(x / lines.size(), y / lines.size());
}
use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.
the class Points method getMeanPoint.
public static Point getMeanPoint(List<Point> points) {
if (points.size() == 0)
return null;
double x = 0;
double y = 0;
for (Point point : points) {
x += Math.pow(point.x, 2);
y += Math.pow(point.y, 2);
}
return new Point(Math.sqrt(x / points.size()), Math.sqrt(y / points.size()));
}
use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.
the class Subdiv2D method getVertex.
//
// C++: Point2f getVertex(int vertex, int* firstEdge = 0)
//
// javadoc: Subdiv2D::getVertex(vertex, firstEdge)
public Point getVertex(int vertex, int[] firstEdge) {
double[] firstEdge_out = new double[1];
Point retVal = new Point(getVertex_0(nativeObj, vertex, firstEdge_out));
if (firstEdge != null)
firstEdge[0] = (int) firstEdge_out[0];
return retVal;
}
use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.
the class Subdiv2D method findNearest.
//
// C++: int findNearest(Point2f pt, Point2f* nearestPt = 0)
//
// javadoc: Subdiv2D::findNearest(pt, nearestPt)
public int findNearest(Point pt, Point nearestPt) {
double[] nearestPt_out = new double[2];
int retVal = findNearest_0(nativeObj, pt.x, pt.y, nearestPt_out);
if (nearestPt != null) {
nearestPt.x = nearestPt_out[0];
nearestPt.y = nearestPt_out[1];
}
return retVal;
}
use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.
the class Converters method vector_Point_to_Mat.
public static Mat vector_Point_to_Mat(List<Point> pts, int typeDepth) {
Mat res;
int count = (pts != null) ? pts.size() : 0;
if (count > 0) {
switch(typeDepth) {
case CvType.CV_32S:
{
res = new Mat(count, 1, CvType.CV_32SC2);
int[] buff = new int[count * 2];
for (int i = 0; i < count; i++) {
Point p = pts.get(i);
buff[i * 2] = (int) p.x;
buff[i * 2 + 1] = (int) p.y;
}
res.put(0, 0, buff);
}
break;
case CvType.CV_32F:
{
res = new Mat(count, 1, CvType.CV_32FC2);
float[] buff = new float[count * 2];
for (int i = 0; i < count; i++) {
Point p = pts.get(i);
buff[i * 2] = (float) p.x;
buff[i * 2 + 1] = (float) p.y;
}
res.put(0, 0, buff);
}
break;
case CvType.CV_64F:
{
res = new Mat(count, 1, CvType.CV_64FC2);
double[] buff = new double[count * 2];
for (int i = 0; i < count; i++) {
Point p = pts.get(i);
buff[i * 2] = p.x;
buff[i * 2 + 1] = p.y;
}
res.put(0, 0, buff);
}
break;
default:
throw new IllegalArgumentException("'typeDepth' can be CV_32S, CV_32F or CV_64F");
}
} else {
res = new Mat();
}
return res;
}
Aggregations