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:

  1. compute features each image of training set
  2. cluster features
  3. label each cluster images have features in cluster

at point training done , can start testing follows:

  1. compute features of test image
  2. for each feature, find nearest cluster
  3. add tick each training image belong cluster
  4. repeat features of test image
  5. 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

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -