Example usage for org.opencv.imgproc Imgproc goodFeaturesToTrack

List of usage examples for org.opencv.imgproc Imgproc goodFeaturesToTrack

Introduction

In this page you can find the example usage for org.opencv.imgproc Imgproc goodFeaturesToTrack.

Prototype

public static void goodFeaturesToTrack(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel,
            double minDistance, Mat mask, int blockSize, boolean useHarrisDetector, double k) 

Source Link

Usage

From source file:simeav.Utils.java

public static ArrayList<Point> detectarVertices(Mat original) {
    MatOfPoint corners = new MatOfPoint();
    Imgproc.goodFeaturesToTrack(original, corners, 100, 0.01, 0, new Mat(), 2, false, 0.04);
    Mat vertices = Mat.zeros(original.size(), CvType.CV_8UC3);
    for (int i = 0; i < corners.height(); i++) {
        Core.circle(vertices, new Point(corners.get(i, 0)), 8, new Scalar(180, 170, 5), -1);
    }//from  w ww  . j a va  2s.  co m

    Mat imGrises = new Mat();
    Mat bw = new Mat();
    Imgproc.cvtColor(vertices, imGrises, Imgproc.COLOR_BGR2GRAY);
    Imgproc.Canny(imGrises, bw, 100, 150, 5, true);

    Mat jerarquia = new Mat();
    ArrayList<MatOfPoint> contornos = new ArrayList<>();
    Imgproc.findContours(bw.clone(), contornos, jerarquia, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
    ArrayList<Point> mc = Utils.getCentros(contornos);
    Mat resultado = Mat.zeros(original.size(), CvType.CV_8UC3);
    for (int i = 0; i < contornos.size(); i++) {
        Scalar color = new Scalar(180, 170, 5);
        //            Imgproc.drawContours(resultado, contornos, i, color, 2, 8, jerarquia, 0, new Point());
        Core.circle(resultado, mc.get(i), 4, color, -1, 8, 0);
    }
    return mc;
}