javaapplication1.JavaApplication1.java Source code

Java tutorial

Introduction

Here is the source code for javaapplication1.JavaApplication1.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.CvType;
import org.opencv.core.Scalar;

/**
 *
 * @author wra216
 */

public class JavaApplication1 {

    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.
        //
        // 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("", "");
    }

}