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 visualizzazioni (ultimi 30 giorni)
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 Commento
James Tursa
James Tursa il 22 Lug 2017
Modificato: James Tursa il 22 Lug 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?

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by