Example usage for org.opencv.core Core NATIVE_LIBRARY_NAME

List of usage examples for org.opencv.core Core NATIVE_LIBRARY_NAME

Introduction

In this page you can find the example usage for org.opencv.core Core NATIVE_LIBRARY_NAME.

Prototype

String NATIVE_LIBRARY_NAME

To view the source code for org.opencv.core Core NATIVE_LIBRARY_NAME.

Click Source Link

Usage

From source file:Questao1.java

public Questao1() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    this.img1 = "lena.jpg";
    this.img2 = "baboon.jpg";

    this.image2 = Imgcodecs.imread(img2);
    this.image1 = Imgcodecs.imread(img1);

    this.image1bin = new Mat();
    this.image2bin = new Mat();

    this.output = new Mat(256, 256, CvType.CV_8UC3);

    showResult(img1);//from  ww  w  .  j  a  va 2s .c o m
    showResult(img2);

    in = new Scanner(System.in);
    do {
        System.out.println("Escolha a operao: ");
        System.out.println("1 - AND");
        System.out.println("2 - OR");
        System.out.println("3 - XOR");
        System.out.println("4 - NOT");
        System.out.println("5 - SOMA");
        System.out.println("6 - SUBTRAO");
        System.out.println("7 - MULTIPLICAO");
        System.out.println("8 - DIVISO");
        System.out.println("0 - SAIR");

        while ((op = in.nextInt()) != 0) {
            realizarOperacoes();
        }
        if (op == 0) {
            return;
        }
    } while (op < 0 || op > 8);
}

From source file:Questao1.java

void and() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    imagemBinaria();/*from   ww  w . j a v  a  2s .  co  m*/
    Core.bitwise_and(image1bin, image2bin, output);
    normalizarBinario();

    Imgcodecs.imwrite("and.jpg", output);
    showResult("and.jpg");
}

From source file:Questao1.java

void or() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    imagemBinaria();/*from w w w. java2  s  .co  m*/
    Core.bitwise_or(image1bin, image2bin, output);
    normalizarBinario();

    Imgcodecs.imwrite("or.jpg", output);
    showResult("or.jpg");
}

From source file:Questao1.java

void xor() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    imagemBinaria();//from   w ww.j av a2  s.c  om
    Core.bitwise_xor(image1bin, image2bin, output);
    normalizarBinario();

    Imgcodecs.imwrite("xor.jpg", output);
    showResult("xor.jpg");
}

From source file:Questao1.java

void not() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    imagemBinaria();/*from w  ww  . ja  va 2s.com*/
    Core.bitwise_not(image2bin, output);
    normalizarBinario();

    Imgcodecs.imwrite("not.jpg", output);
    showResult("not.jpg");
}

From source file:Questao1.java

void soma() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    Core.add(image1, image2, output);
    Imgcodecs.imwrite("soma.jpg", output);
    showResult("soma.jpg");
}

From source file:Questao1.java

void subtracao() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    Core.subtract(image1, image2, output);
    Imgcodecs.imwrite("subtracao.jpg", output);
    showResult("subtracao.jpg");
}

From source file:Questao1.java

void multiplicacao() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    Core.multiply(image1, image2, output);
    Imgcodecs.imwrite("multiplicacao.jpg", output);
    showResult("multiplicacao.jpg");
}

From source file:Questao1.java

void divisao() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    Core.divide(image1, image2, output);
    Imgcodecs.imwrite("divisao.jpg", output);
    showResult("divisao.jpg");
}

From source file:MainBorder.java

public static void main(String[] args) {

    try {/*from   ww  w .j  av  a2 s  .  c o  m*/

        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        Mat source = Highgui.imread("D:\\teste.png", Highgui.CV_LOAD_IMAGE_COLOR);

        Mat destination = new Mat(source.rows(), source.cols(), source.type());

        int top, bottom, left, right;

        int borderType;

        //initialize arguments for the filter border

        top = (int) (0.05 * source.rows());
        bottom = (int) (0.05 * source.rows());

        left = (int) (0.15 * source.cols());
        right = (int) (0.15 * source.cols());

        destination = source;

        //Imgproc.copyMakeBorder(source, destination, top, bottom, left, right, Imgproc.BORDER_WRAP); //borda com a imagem
        //Imgproc.copyMakeBorder(source, destination, top, bottom, left, right, Imgproc.BORDER_CONSTANT); //borda preta
        Imgproc.copyMakeBorder(source, destination, top, bottom, left, right, Imgproc.BORDER_DEFAULT); //borda transparente
        //Imgproc.copyMakeBorder(source, destination, top, bottom, left, right, Imgproc.BORDER_ISOLATED); // borda escura??
        //Imgproc.copyMakeBorder(source, destination, top, bottom, left, right, Imgproc.BORDER_REFLECT); //borda com reflexo da prpria imagem
        //Imgproc.copyMakeBorder(source, destination, top, bottom, left, right, Imgproc.BORDER_REFLECT101);
        //Imgproc.copyMakeBorder(source, destination, top, bottom, left, right, Imgproc.BORDER_REFLECT_101);
        //Imgproc.copyMakeBorder(source, destination, top, bottom, left, right, Imgproc.BORDER_REPLICATE); //borda efeito movimento
        //Imgproc.copyMakeBorder(source, destination, top, bottom, left, right, Imgproc.BORDER_TRANSPARENT); //borda no funciona

        Highgui.imwrite("D:\\borderWrap.jpg", destination);

    } catch (Exception e) {
        System.out.println("Exception: " + e.getMessage());
    }

}