본문 바로가기

Programming

OpenCv, How to create/initialize mat in CV for Java, 매트릭스 생성/초기화, 자바, c++, JavaCv


OpenCv, How to create/initialize mat in CV for Java, 매트릭스 생성/초기화, 자바, c++, JavaCv




Imma post basic 3 way to initialize Mat in javaCv


openCv 자바에서 자주 쓰이는 3가지 생성자 겸 초기화 함수




Example code

예제코드



public static void main(String[] args)

{

// load the OpenCV native library

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

// create and print on screen a 3x3 identity matrix

System.out.println("Create a 3x3 identity matrix...");

Mat mat1 = Mat.eye(3, 3, CvType.CV_8U);

Mat mat2 = Mat.ones(3, 3, CvType.CV_8U);

Mat mat3 = Mat.zeros(3, 3, CvType.CV_8U);

System.out.println("mat1 = " + mat1.dump());

System.out.println("mat2 = " + mat2.dump());

System.out.println("mat3 = " + mat3.dump());

}



-> Result


mat1 = [  1,   0,   0;

             0,   1,   0;

             0,   0,   1]


mat2 = [  1,   1,   1;

             1,   1,   1;

             1,   1,   1]


mat3 = [  0,   0,   0;

             0,   0,   0;

             0,   0,   0]




Something else you might like..




2018/11/18 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #30 circleOfNumbers. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar

2018/11/17 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #29 chessBoardCellColor. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar

2018/11/15 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #28 alphabeticShift. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar

2018/11/15 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #27 variableName. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar

2018/11/14 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #26 evenDigitsOnly. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar



2018/11/13 - [Programming/Java] - JavaFx Drag N Drop event / 자바Fx 드래그앤드롭 이벤트 처리 / Java, C++, example



2018/10/26 - [Programming/Java] - Difference between String, StringBuilder, and StringBuffer Class 차이점 / Java c++ 문자열, example 예제



2018/10/25 - [Programming/Image Processing] - Complex number matrix division, multiply in OpenCv like Matlab (실수부와 복소수허수부 포함된 매트릭스 곱셈, 나눗셈)



2018/10/16 - [Programming/Java] - Java enum class 자바 이넘 클래스 (Singleton design pattern 처럼 사용방법)