Example usage for org.opencv.core Mat col

List of usage examples for org.opencv.core Mat col

Introduction

In this page you can find the example usage for org.opencv.core Mat col.

Prototype

public Mat col(int x) 

Source Link

Usage

From source file:javaapplication1.JavaApplication1.java

public static void main(String[] args) {
    // you must load the OpenCV library like this before trying to do
    // anything with OpenCV!
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    // Print OpenCV version
    System.out.println("Welcome to OpenCV " + Core.VERSION);

    // In OpenCV, the most important data type is the Matrix, Mat.
    ////from  ww  w  .  java2 s . c o  m
    // Here, we create a matrix that has 5 rows and 10 columns.  It
    // stores an 8-bit type with a single channel.  In other words, a
    // matrix of bytes.  We'll initialize every element to 0.
    Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));

    // Dump information about the matrix
    System.out.println("OpenCV Mat: " + m);

    // set row 1 to be all 1s, and then column 5 to be all 5s
    Mat mr1 = m.row(1);
    mr1.setTo(new Scalar(1));
    Mat mc5 = m.col(5);
    mc5.setTo(new Scalar(5));

    // Dump the actual matrix contents
    System.out.println("OpenCV Mat data:\n" + m.dump());

    Ocv ocv = new Ocv();
    ocv.getFilePath();

    /**
     * Find faces in an image.
     *
     * @param filter Path to the xml face finding filter to use
     * @param input Path to the input image file
     * @param output Path to the output image file
     */
    //ocv.findFaces("lbpcascade_frontalface.xml", "C:\\Users\\Wellesley\\Documents\\GitHub\\CSE398\\opencvTutorial\\JavaApplication1\\src\\javaapplication1\\lena.png", "../javaapplication1");
    ocv.setOutput("step2.png");
    ocv.findFaces("", "", "");
    ocv.setOutput("step3.png");
    ocv.cropEachFace("", "");
    ocv.setOutput("step4.png");
    ocv.resizeEachFace("", "");
    ocv.setOutput("step6.png");
    ocv.makeFacesGray("", "", "");
    ocv.setOutput("step8.png");
    ocv.blendWithGray50("", "");
    ocv.setOutput("step10.png");
    ocv.doSobel("", "");
    ocv.setOutput("step11.png");
    ocv.directManip("", "");
}

From source file:qupath.opencv.processing.OpenCVTools.java

License:Open Source License

public static void labelImage(Mat matBinary, Mat matLabels, int contourType) {
    List<MatOfPoint> contours = new ArrayList<>();
    Mat hierarchy = new Mat();
    Imgproc.findContours(matBinary, contours, hierarchy, contourType, Imgproc.CHAIN_APPROX_SIMPLE);
    // It's convoluted, but drawing contours this way is *much* faster than passing the full list (which is copied by the OpenCV 2.4.9 Java code)
    List<MatOfPoint> temp = new ArrayList<>(1);
    int i = 2;/* w ww.jav a2 s.  com*/
    int ind = 0;
    for (MatOfPoint contour : contours) {
        temp.clear();
        temp.add(contour);
        Imgproc.drawContours(matLabels, temp, 0, new Scalar(i++), -1, 8, hierarchy.col(ind), 2,
                new Point(0, 0));
        //         Imgproc.drawContours(matLabels, temp, 0, new Scalar(i++), -1);
        ind++;
    }
}

From source file:samples.SimpleSample.java

public static void main(String[] args) {

    System.load("C:\\opencv\\build\\java\\x64\\opencv_java310.dll");
    System.out.println(System.getProperty("java.library.path"));
    System.out.println("Welcome to OpenCV " + Core.VERSION);
    Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));
    System.out.println("OpenCV Mat: " + m);
    Mat mr1 = m.row(1);//from w  w w.  j  a va2s.c o  m
    mr1.setTo(new Scalar(1));
    Mat mc5 = m.col(5);
    mc5.setTo(new Scalar(5));
    System.out.println("OpenCV Mat data:\n" + m.dump());
}