Print opencv matrix content with Java

I have opencv matrix in Java. I want to print its contents I tried the toString () function as follows: descriptor ToString (), so I can implement this form

"[[1,2,3,4],[4,5,6,7],[7,8,9,10]]"

Each of these arrays is row I of the matrix, but I get the following results I tried to delete toString, but it's still the same problem

Mat [ 3*4*CV_8UC1,isCont=true,isSubmat=false,nativeObj=0x5dc93a48,dataAddr=0x5d5d35f0]

Where 3 is the number of rows and 4 is the number of columns

Any help how can I get the matrix content?!

Solution

Code:

int[][] testArray = new int[][]{{1,4},{4,7},{7,10}};
    Mat matArray = new Mat(3,4,CvType.CV_8UC1);
    for(int row=0;row<3;row++){
        for(int col=0;col<4;coL++)
            matArray.put(row,col,testArray[row][col]);
    }
    System.out.println("Printing the matrix dump");
    System.out.println(matArray.dump());

Output: print matrix dump [1,4; 4,7; 7,10]

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>