问题
How do I create a descriptor in OpenCV that can be used with one of the DescriptorMatchers in OpenCV, in the following manner.
cv::BFMatcher matcher( cv::NORM_L2, false );
std::vector< cv::DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches );
I already have the following descriptor class. How do I convert or create a new matrix that can be used with a DescriptorMatcher. Preferably BFMatcher.
class Descriptor
{
public:
float lxi, lyi; // Location of descriptor
vector<double> feature;
Descriptor()
{
}
Descriptor(float x, float y, vector<double> const& f)
{
lxi = x;
lyi = y;
feature = f;
}
};
回答1:
I just visit here when looking for the answers about the same question. But soon I found the answer is so simple, all you need is to make a Mat.
For example , below is a some SIFT-LIKE descriptor.
cv::Mat descriptors_1(nQueries, dimemsion, CV_32F,(void*)pQueries);
cv::Mat descriptors_2(m_nDataSets, dimemsion, CV_32F,(void*)m_pData);
cv::FlannBasedMatcher matcher;
std::vector< cv::DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches );
来源:https://stackoverflow.com/questions/22506500/how-to-create-a-descriptor-matrix-in-opencv