Search in sources :

Example 16 with Point

use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.

the class Lines method constructLine.

public static Line constructLine(Point point, double angle, double length) {
    double dx = Math.cos(angle * Math.PI / 180);
    double dy = Math.sin(angle * Math.PI / 180);
    Point p1 = new Point(point.x + 0.5 * length * dx, point.y + 0.5 * length * dy);
    Point p2 = new Point(point.x - 0.5 * length * dx, point.y - 0.5 * length * dy);
    return new Line(p1, p2);
}
Also used : Line(com.disnodeteam.dogecv.math.Line) Point(org.opencv.core.Point)

Example 17 with Point

use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.

the class Lines method linearExtend.

public static Line linearExtend(Line line, double scale, Size size) {
    scale *= 2;
    double xN1 = line.x1 + (line.x1 - line.x2) / scale;
    double yN1 = line.y1 + (line.y1 - line.y2) / scale;
    double xN2 = line.x2 + (line.x2 - line.x1) / scale;
    double yN2 = line.y2 + (line.y2 - line.y1) / scale;
    Point p1 = new Point(MathFTC.clip((int) xN1, 0, size.width - 1), MathFTC.clip((int) yN1, 0, size.height - 1));
    Point p2 = new Point(MathFTC.clip((int) xN2, 0, size.width - 1), MathFTC.clip((int) yN2, 0, size.height - 1));
    return new Line(p1, p2);
}
Also used : Line(com.disnodeteam.dogecv.math.Line) Point(org.opencv.core.Point)

Example 18 with Point

use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.

the class Lines method getPerpindicularConnector.

public static Line getPerpindicularConnector(Line left, Line right, Size size) {
    double angle = Lines.getAngularDistance(left, new Line(new Point(0, 0), new Point(100, 0)));
    angle += 90;
    double dx = 3 * Math.cos(angle * Math.PI / 180);
    double dy = 3 * Math.sin(angle * Math.PI / 180);
    double x = left.center().x + dx;
    double y = left.center().y + dy;
    if (Lines.crossSign(left, new Point(x, y)) != Lines.crossSign(left, right.center())) {
        dx = -dx;
        dy = -dy;
        x -= 2 * dx;
        y -= 2 * dy;
    }
    while (Points.inBounds(new Point(x, y), size) && !Lines.intersect(new Line(left.center(), new Point(x, y)), right)) {
        x += dx;
        y += dy;
    }
    return new Line(left.center(), new Point(x, y));
}
Also used : Line(com.disnodeteam.dogecv.math.Line) Point(org.opencv.core.Point)

Example 19 with Point

use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.

the class Lines method getPerpindicular.

public static Line getPerpindicular(Line line, double sign) {
    double angle = Lines.getAngularDistance(line, new Line(new Point(0, 0), new Point(100, 0)));
    angle += 90;
    double x = line.center().x + 50 * Math.cos(angle * Math.PI / 180);
    double y = line.center().y + 50 * Math.sin(angle * Math.PI / 180);
    if (Lines.crossSign(line, new Point(x, y)) != sign) {
        x = line.center().x - 50 * Math.cos(angle * Math.PI / 180);
        y = line.center().y - 50 * Math.sin(angle * Math.PI / 180);
    }
    Line perp = new Line(line.center(), new Point(x, y));
    return perp;
}
Also used : Line(com.disnodeteam.dogecv.math.Line) Point(org.opencv.core.Point)

Example 20 with Point

use of org.opencv.core.Point in project Relic_Main by TeamOverdrive.

the class Lines method getOpenCvLines.

public static List<Line> getOpenCvLines(Mat original, int scale, double minLength) {
    Mat raw = new Mat();
    Imgproc.resize(original.clone(), raw, new Size((int) (original.size().width / scale), (int) (original.size().height / scale)));
    if (raw.channels() > 1) {
        Imgproc.cvtColor(raw, raw, Imgproc.COLOR_RGB2GRAY);
    }
    Imgproc.equalizeHist(raw, raw);
    Imgproc.blur(raw, raw, new Size(3, 3));
    // Line Segment Detection 2
    Mat linesM1 = new Mat();
    // LineSegmentDetector detector = Imgproc.createLineSegmentDetector(Imgproc.LSD_REFINE_ADV, 0.6, 0.3, 2.6, 22.5, 0, 0.3,256);
    // LineSegmentDetector detector = Imgproc.createLineSegmentDetector(Imgproc.LSD_REFINE_STD, 0.5, 0.4,2.0, 19.5, 0, 0.6, 32);
    // Reference for final glyph detection
    detector.detect(raw, linesM1);
    ArrayList<Line> lines = new ArrayList<Line>();
    for (int x = 0; x < linesM1.rows(); x++) {
        double[] vec = linesM1.get(x, 0);
        Point start = new Point(vec[0], vec[1]);
        Point end = new Point(vec[2], vec[3]);
        Line line = new Line(start, end);
        line = new Line(new Point((int) line.x1 * scale, (int) line.y1 * scale), new Point((int) line.x2 * scale, (int) line.y2 * scale));
        if (line.length() > minLength)
            lines.add(line);
    }
    raw.release();
    linesM1.release();
    return lines;
}
Also used : Line(com.disnodeteam.dogecv.math.Line) Mat(org.opencv.core.Mat) Size(org.opencv.core.Size) ArrayList(java.util.ArrayList) Point(org.opencv.core.Point) Point(org.opencv.core.Point)

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