I want to perform a very simple task, but cannot due to an error I cannot figure out. I want to save the contents of the features detected to a vector onto a txt file using the following piece of code
Ptr<FeatureDetector> feature_detector = FeatureDetector::create("SIFT");
vector<KeyPoint> keypoints;
feature_detector->detect(img, keypoints);
for(unsigned int i = 0; i < keypoints.size(); i++)
{
ofstream outf("vector.txt", ios::app);
outf<<"value at "<< i << " = " << keypoints.at<KeyPoint>(i)<<endl;
}
But I am presented with the following error:
std::vector<_Ty>::at’: function call missing argument list; use
‘&std::vector<_Ty>::at’ to create a pointer to member
I checked my syntax and cannot find anything wrong.
Edit: Before this I wanted to print out the contents of a matrix and this format worked perfectly for it, here is the code I used to print the contents of the matrix:
for(int x = 0;x < dst.rows ; x++)
{
for( int y = 0; y < dst.cols; y++)
{
ofstream outf("Sample.txt", ios::app);
outf<<"value at "<< x << " " << y << " = " << dst.at<float>(x,y)<<endl;
}
}
Where dst is a matrix consisting of float data type
Using the builtin FileStorage class this was as easy as adding two lines.. I printed the vector of KeyPoints using the following lines: