Abhay Swami
Abhay Swami

Reputation: 21

How to display all values present in Mat variable in OpenCV?

I am working on Closed/open eye-detection project using OpenCV libraries in Eclipse for android latest version. I retrieve a part of detected face and then save it in a Mat variable.

I am getting problem in how to display all the values( gray-scale pixel values). These are the methods I tried:

How can I display all the values present in Mat_variable?

Plus, is there any way to see all the values of Mat variable in Matrix-format (because System.out.println() doesn't work, otherwise I could use System.out.println() to display values in Matrix-format)?

Upvotes: 0

Views: 1056

Answers (1)

pdresselhaus
pdresselhaus

Reputation: 699

What about writing the values to a file?

If that'd be a solution for you, you could try the following:

// Create access to the file
cv::FileStorage file("mat.yml", cv::FileStorage::WRITE);
cv::Mat myMat;

// Write myMat to file!
file << myMat;

If you're having troubles with write-permissions have a look at the answers over here


I'm very sorry to not have looked more closely at the tags you specified. There are two ways to proceed. The first way would be to write the Mat to a file by hand following this approach. The second approach is to use Android-NDK. As I am not familiar with Android-NDK I can just point out some code sample for you.

Upvotes: 2

Related Questions