I am attempting to learn OpenCV, and being a hard-head, I am trying to run the following algorithm:
cv::Mat cur_features;
cv::goodFeaturesToTrack(current_image, cur_features, 400, 0.01, 0.01);
Now, being the hard-headed individual, I am interested to see what cur_features is holding… I expected a 400×2 cv::Mat but instead I got a 400×1 cv::Mat
No biggy, I think maybe its a direct index. However, for the LIFE of me I CANNOT extract a value from cur_features.at(0) and print it out.
What am I doing wrong? I have seen the goodFeaturesToTrack_Demo.cpp. Some things to note on that demo that differ for mine. I tried the following calls given that example:
std::cout << cur_features.size() << std::endl; // This throws a compile time error even though its in the example
std::cout << cur_features.at<Point2f>(0).x << std::endl; //This throws a run time error.
Could anyone direct me to some documentation that explains how to achieve my goal? The goodFeaturesToTrack tells you it returns an OutputArray which is a vector of corners, but nowhere does it describe what the type of those corners are. Where in the documentation would I look for this answer in case I get it with other methods?
Edit: Also, whats the Point of Mat::type(). I cannot find where the returned value can be explained… I’m looking for an enumeration in the documentation but having trouble finding it.
std::cout << current_image.type() << std::endl; //This returns 0
std::cout << cur_features.type() << std::endl; //This returns 13
As a suggestion, try to initialize matrices with dimensions and type
To get a value of a Mat
And a handy debug technique for Visual Studio that helped me a lot
3- Write this:
(float*)cur_features.data,400
4- You will see all the values of the array