c++ - BoW in OpenCV using precomputed features -


i need bow (bag of words) have described keypoints of images. moment, have obtained vocabulary using:

cv::bowkmeanstrainer bowtrainercn(numcenters); //num clusters bowtrainercn.add(alldescriptors); cv::mat vocabularycn = bowtrainercn.cluster(); 

so need assignment can't use compute function because calculates descriptors of images , have that. there function assignment or have compute manually?

once have built vocabulary (codebook) using cv::bowkmeanstrainer::cluster() method, can match descriptor (with suitable size , type) codebook. first have choose type of matcher need norm use. (see opencv doc)

for example, cv::bfmatcher , l2 norm

// init matcher pre-trained codebook cv::ptr<cv::descriptormatcher > matcher = new cv::bfmatcher(cv::norm_l2); matcher->add(std::vector<cv::mat>(1, vocabulary)); // matches std::vector<cv::dmatch> matches; matcher->match(new_descriptors,matches); 

then index of closest codeword in codebook new_descriptors[i] be

matches[i].trainidx;  

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -