Ask Your Question
0

OpenCV (Java): how to access coordinates returned by findNonZero()?

asked 2013-08-10 00:50:18 -0600

Mahm00d gravatar image

updated 2013-08-12 09:22:41 -0600

In my android app, I am using findNonZero() to find and access white points in a binary image.

I get the image (called binMat with size: 595*800) as the input to the method and then I have:

...
Mat wLocMat = Mat.zeros(binMat.size(), binMat.channels()); 
Core.findNonZero(binMat, wLocMat);

The problem is: I don't know how to access the white points' coordinates stored inside the wLocMat!

When I log the wLocMat.toString(), I get this:

[ 476000*1*CV_32SC2, isCont=true, isSubmat=false, nativeObj=0x74abd920, dataAddr=0x75bac010 ]

So, how exactly can I access the coordinates stored in wLocMat?!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-08-12 14:29:56 -0600

Andrey Pavlenko gravatar image

The returned Mat is of N*1 size (where N is a number of non-zero elements of input Mat) and each of its elements contains row & col of non-zero element of input Mat. Consider it as an array non-zero pixels indexes.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-08-10 00:50:18 -0600

Seen: 6,264 times

Last updated: Aug 12 '13