singleOperations.CalculateArea.java Source code

Java tutorial

Introduction

Here is the source code for singleOperations.CalculateArea.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 singleOperations;

import imageproccessingOpenCV.IPColorChannels;
import imageproccessingOpenCV.IPColorHSVChannels;
import imageproccessingOpenCV.IPColorRGBChannels;
import imageproccessingOpenCV.ImageProccessingFrame;
import imageproccessingOpenCV.ImageProccessingFrameTabs;
import java.util.ArrayList;
import java.util.List;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;
import values.MyStrings;

/**
 *
 * @author aldajo
 */
public class CalculateArea {
    public static void main(String[] args) {
        //cargamos los elementos de la libreria nativa
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        //Leemos un archivo de imagen
        Mat image = Highgui.imread("camera/imageCamera.png", Highgui.CV_LOAD_IMAGE_COLOR);
        Mat imageHSV = image.clone();
        //cargamos la imagen a una ventana
        ImageProccessingFrame pi = new ImageProccessingFrame("Example");
        pi.displayImageProccessed(image);

        //        //Algoritmo para preprocesar la imagen: formato HSV
        //        Imgproc.cvtColor(image, imageHSV, Imgproc.COLOR_RGB2HSV);

        IPColorHSVChannels colorHSVChannels = new IPColorHSVChannels("EXampleHSV", MyStrings.channelsHSVNames);
        colorHSVChannels.displayImageProccessed(imageHSV);

        IPColorRGBChannels colorRGBChannels = new IPColorRGBChannels("EcampleRGB", MyStrings.channelsNames);
        colorRGBChannels.displayImageProccessed(imageHSV);

        //        IPColorChannels colorChannels = new IPColorChannels("Example2", MyStrings.channelsNames);
        //        colorChannels.displayImageProccessed(image);
        //        
        //        List<Mat> hsvImageChannels;
        //        hsvImageChannels = new ArrayList<>();
        //        
        //        Core.split(imageHSV, hsvImageChannels);
        //        
        //        ImageProccessingFrameTabs hsvChannels = new IPColorChannels("Example2", MyStrings.channelsNames);
        //        Mat[] channels =  (Mat[]) hsvImageChannels.toArray();
        //        hsvChannels.displayImageProccessed(channels[0]);
    }
}