I have read a lot of articles about implementing bag of words after taking sift features of an image, but I'm still confused what to do next. What do i specifically do?
Thank you so much in advance for the guidance.
This is the code that i have so far.
cv::Mat mat_img = cropped.clone();
Mat grayForML;
cvtColor(mat_img, grayForML, CV_BGR2GRAY);
IplImage grayImageForML = grayForML.operator IplImage();
//create another copy of iplGray
IplImage *input = cvCloneImage(&grayImageForML);
Mat matInput = cvarrToMat(input);
// Mat matInput = copy_gray.clone();
cv::SiftFeatureDetector detector;
std::vector<cv::KeyPoint> keyPoints;
detector.detect(input, keyPoints);
//add results to image and save.
cv::Mat output;
cv::drawKeypoints(input, keyPoints, output); //SIFT OUTPUT RESULT
//resize and display
cv::Mat output_reduced;
cv::resize(output, output_reduced, cv::Size2i(output.cols / 2, output.rows / 2));
imshow("SIFT result", output_reduced);
Training a bag of words system goes as follows:
At this point the training is done and you can start with the testing as follows:
As you can notice, there is no restriction to using SIFT. You can try different feature extractors and descriptors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With