Search in sources :

Example 41 with Mat

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

the class Video method calcOpticalFlowPyrLK.

// 
// C++:  void calcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, vector_Point2f prevPts, vector_Point2f& nextPts, vector_uchar& status, vector_float& err, Size winSize = Size(21,21), int maxLevel = 3, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), int flags = 0, double minEigThreshold = 1e-4)
// 
// javadoc: calcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts, status, err, winSize, maxLevel, criteria, flags, minEigThreshold)
public static void calcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, MatOfPoint2f prevPts, MatOfPoint2f nextPts, MatOfByte status, MatOfFloat err, Size winSize, int maxLevel, TermCriteria criteria, int flags, double minEigThreshold) {
    Mat prevPts_mat = prevPts;
    Mat nextPts_mat = nextPts;
    Mat status_mat = status;
    Mat err_mat = err;
    calcOpticalFlowPyrLK_0(prevImg.nativeObj, nextImg.nativeObj, prevPts_mat.nativeObj, nextPts_mat.nativeObj, status_mat.nativeObj, err_mat.nativeObj, winSize.width, winSize.height, maxLevel, criteria.type, criteria.maxCount, criteria.epsilon, flags, minEigThreshold);
    return;
}
Also used : Mat(org.opencv.core.Mat)

Example 42 with Mat

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

the class Video method buildOpticalFlowPyramid.

// javadoc: buildOpticalFlowPyramid(img, pyramid, winSize, maxLevel)
public static int buildOpticalFlowPyramid(Mat img, List<Mat> pyramid, Size winSize, int maxLevel) {
    Mat pyramid_mat = new Mat();
    int retVal = buildOpticalFlowPyramid_1(img.nativeObj, pyramid_mat.nativeObj, winSize.width, winSize.height, maxLevel);
    Converters.Mat_to_vector_Mat(pyramid_mat, pyramid);
    pyramid_mat.release();
    return retVal;
}
Also used : Mat(org.opencv.core.Mat)

Example 43 with Mat

use of org.opencv.core.Mat 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)

Example 44 with Mat

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

the class Calib3d method findFundamentalMat.

// javadoc: findFundamentalMat(points1, points2, method, param1, param2)
public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double param1, double param2) {
    Mat points1_mat = points1;
    Mat points2_mat = points2;
    Mat retVal = new Mat(findFundamentalMat_1(points1_mat.nativeObj, points2_mat.nativeObj, method, param1, param2));
    return retVal;
}
Also used : Mat(org.opencv.core.Mat)

Example 45 with Mat

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

the class Calib3d method calibrateCameraExtended.

// 
// C++:  double calibrateCamera(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& stdDeviationsIntrinsics, Mat& stdDeviationsExtrinsics, Mat& perViewErrors, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
// 
// javadoc: calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, stdDeviationsIntrinsics, stdDeviationsExtrinsics, perViewErrors, flags, criteria)
public static double calibrateCameraExtended(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat perViewErrors, int flags, TermCriteria criteria) {
    Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
    Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
    Mat rvecs_mat = new Mat();
    Mat tvecs_mat = new Mat();
    double retVal = calibrateCameraExtended_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, perViewErrors.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
    Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
    rvecs_mat.release();
    Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
    tvecs_mat.release();
    return retVal;
}
Also used : Mat(org.opencv.core.Mat)

Aggregations

Mat (org.opencv.core.Mat)285 Point (org.opencv.core.Point)50 ArrayList (java.util.ArrayList)45 MatOfPoint (org.opencv.core.MatOfPoint)43 MatOfKeyPoint (org.opencv.core.MatOfKeyPoint)20 Size (org.opencv.core.Size)20 KeyPoint (org.opencv.core.KeyPoint)18 Scalar (org.opencv.core.Scalar)17 Rect (org.opencv.core.Rect)16 File (java.io.File)8 RotatedRect (org.opencv.core.RotatedRect)6 BufferedImage (java.awt.image.BufferedImage)5 FilterContext (de.serviceflow.frankenstein.plugin.api.FilterContext)4 SegmentVideoFilter (de.serviceflow.frankenstein.plugin.api.SegmentVideoFilter)4 DefaultFilterContext (de.serviceflow.frankenstein.vf.DefaultFilterContext)4 VideoFilter (de.serviceflow.frankenstein.vf.VideoFilter)4 DataBufferByte (java.awt.image.DataBufferByte)4 IOException (java.io.IOException)4 FilterElement (de.serviceflow.frankenstein.vf.FilterElement)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3