I am writing a C++ Mex source file to perform matchingFeatures operation after extracting corner feature points. Please help me to convert index of matching features of 2 images (in vector<DMatch>) to mxArray .
3 views (last 30 days)
Show older comments
Here is my code-
#include "opencvmex.hpp"
using namespace cv;
void checkforInputs(int nrhs,const mxArray *prhs[])
{
if (nrhs != 2)
{
mexErrMsgTxt("Incorrect number of inputs. Function expects 2 inputs.");
}
if (!(mxIsUint8(prhs[0])&&mxIsUint8(prhs[0])))
{
mexErrMsgTxt("Input image must be uint8.");
}
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
checkforInputs(nrhs, prhs);// check wheteher inputs are correct.
cv::Ptr<cv::Mat> description1 = ocvMxArrayToImage_uint8(prhs[0], true);
cv::Ptr<cv::Mat> description2 = ocvMxArrayToImage_uint8(prhs[1], true);
Ptr<DescriptorMatcher> matcher= cv::DescriptorMatcher::create("BruteForce-Hamming");// pointer to DescriptorMatcher object
std::vector<DMatch> matches;
matcher->match(*description2, *description1, matches);
// how to get indexes of matches in 2 images get converted to mxArray
}
1 Comment
James Tursa
on 22 Jul 2017
Edited: James Tursa
on 22 Jul 2017
I am not familiar with OpenCV DMatch. Can you get at the field data directly? I.e., can you get at the distance, imgIdx, queryIdx, and trainIdx data directly?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!