how to use SIFT features for bag of words in opencv? -
i have read lot of articles implementing bag of words after taking sift features of image, i'm still confused next. do?
thank in advance guidance.
this code have far.
cv::mat mat_img = cropped.clone(); mat grayforml; cvtcolor(mat_img, grayforml, cv_bgr2gray); iplimage grayimageforml = grayforml.operator iplimage(); //create 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 image , save. cv::mat output; cv::drawkeypoints(input, keypoints, output); //sift output result //resize , display cv::mat output_reduced; cv::resize(output, output_reduced, cv::size2i(output.cols / 2, output.rows / 2)); imshow("sift result", output_reduced);
training bag of words system goes follows:
- compute features each image of training set
- cluster features
- label each cluster images have features in cluster
at point training done , can start testing follows:
- compute features of test image
- for each feature, find nearest cluster
- add tick each training image belong cluster
- repeat features of test image
- the image has highest number of ticks best match , image second highest number of ticks second best match , on
as can notice, there no restriction using sift. can try different feature extractors , descriptors.
Comments
Post a Comment