Search in sources :

Example 46 with Point

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());
}
Also used : Line(com.disnodeteam.dogecv.math.Line) Point(org.opencv.core.Point)

Example 47 with Point

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()));
}
Also used : Point(org.opencv.core.Point)

Example 48 with Point

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;
}
Also used : Point(org.opencv.core.Point)

Example 49 with Point

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;
}
Also used : Point(org.opencv.core.Point)

Example 50 with Point

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;
}
Also used : Mat(org.opencv.core.Mat) Point(org.opencv.core.Point) MatOfKeyPoint(org.opencv.core.MatOfKeyPoint) KeyPoint(org.opencv.core.KeyPoint) MatOfPoint(org.opencv.core.MatOfPoint) Point(org.opencv.core.Point) MatOfKeyPoint(org.opencv.core.MatOfKeyPoint) KeyPoint(org.opencv.core.KeyPoint) MatOfPoint(org.opencv.core.MatOfPoint)

Aggregations

Point (org.opencv.core.Point)56 MatOfPoint (org.opencv.core.MatOfPoint)30 Mat (org.opencv.core.Mat)23 ArrayList (java.util.ArrayList)11 Scalar (org.opencv.core.Scalar)9 Line (com.disnodeteam.dogecv.math.Line)7 Rect (org.opencv.core.Rect)7 Size (org.opencv.core.Size)7 MatOfPoint2f (org.opencv.core.MatOfPoint2f)4 TimingLogger (android.util.TimingLogger)2 Ponto (br.edu.ifspsaocarlos.sdm.kifurecorder.processing.cornerDetector.Ponto)2 KeyPoint (org.opencv.core.KeyPoint)2 MatOfKeyPoint (org.opencv.core.MatOfKeyPoint)2 Pair (android.util.Pair)1 Corner (br.edu.ifspsaocarlos.sdm.kifurecorder.processing.cornerDetector.Corner)1 Rectangle (java.awt.Rectangle)1 List (java.util.List)1 ImageNotFoundException (org.getopentest.exceptions.ImageNotFoundException)1 Core (org.opencv.core.Core)1 MinMaxLocResult (org.opencv.core.Core.MinMaxLocResult)1