Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

mask in FlannBasedMatcher::match doesn't work normally

I note the FlannBasedMatcher::match have a parameter mask, so I give a try with following code:

#include<opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
using namespace std;

int main() {
    Mat rightImg = imread("right.jpg", 0);
    Mat leanImg = imread("lean.jpg", 0);
    if (!rightImg.data || !leanImg.data) {
        cout << "Fail to read your image. Please check your path.\n";
        return -1;
    }
    resize(leanImg, leanImg, rightImg.size());
    int minHessian = 400;
    SurfFeatureDetector detector(minHessian);
    vector<KeyPoint> keypoints_right, keypoints_lean;

    detector.detect(rightImg, keypoints_right);
    detector.detect(leanImg, keypoints_lean);

    Mat med_right, med_lean;
    drawKeypoints(rightImg, keypoints_right, med_right);
    drawKeypoints(leanImg, keypoints_lean, med_lean);

    SurfDescriptorExtractor extractor;
    Mat descriptors_right, descriptors_lean;
    extractor.compute(rightImg, keypoints_right, descriptors_right);
    extractor.compute(leanImg, keypoints_lean, descriptors_lean);

    FlannBasedMatcher matcher;
    vector< DMatch > matches;

    Mat mask(rightImg.size(), CV_8UC1, Scalar(255));

    ellipse(mask, Point(rightImg.cols / 2, rightImg.rows / 2), Size(rightImg.cols / 2.5, rightImg.rows / 2.5), 0, 0, 360, Scalar(0), CV_FILLED);

    matcher.match(descriptors_right, descriptors_lean, matches/*, mask*/);// You can use the mask or not to test

    Mat img_matches;
    drawMatches(rightImg, keypoints_right, leanImg, keypoints_lean,
        matches, img_matches, Scalar::all(-1), Scalar::all(-1),
        vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
    return 0;
    }

And this is my right.jpg and lean.jpg. But I note I will get a same result whether I use the mask in the FlannBasedMatcher::match.You can use the mask or not to test. Is there I have missed something or the OpenCV have a bug in my 2.4.13?

mask in FlannBasedMatcher::match doesn't work normally

I note the FlannBasedMatcher::match have a parameter mask, so I give a try with following code:

#include<opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
using namespace std;

int main() {
    Mat rightImg = imread("right.jpg", 0);
    Mat leanImg = imread("lean.jpg", 0);
    if (!rightImg.data || !leanImg.data) {
        cout << "Fail to read your image. Please check your path.\n";
        return -1;
    }
    resize(leanImg, leanImg, rightImg.size());
    int minHessian = 400;
    SurfFeatureDetector detector(minHessian);
    vector<KeyPoint> keypoints_right, keypoints_lean;

    detector.detect(rightImg, keypoints_right);
    detector.detect(leanImg, keypoints_lean);

    Mat med_right, med_lean;
    drawKeypoints(rightImg, keypoints_right, med_right);
    drawKeypoints(leanImg, keypoints_lean, med_lean);

    SurfDescriptorExtractor extractor;
    Mat descriptors_right, descriptors_lean;
    extractor.compute(rightImg, keypoints_right, descriptors_right);
    extractor.compute(leanImg, keypoints_lean, descriptors_lean);

    FlannBasedMatcher matcher;
    vector< DMatch > matches;

    Mat mask(rightImg.size(), CV_8UC1, Scalar(255));

    ellipse(mask, Point(rightImg.cols / 2, rightImg.rows / 2), Size(rightImg.cols / 2.5, rightImg.rows / 2.5), 0, 0, 360, Scalar(0), CV_FILLED);

    matcher.match(descriptors_right, descriptors_lean, matches/*, mask*/);// You can use the mask or not to test

    Mat img_matches;
    drawMatches(rightImg, keypoints_right, leanImg, keypoints_lean,
        matches, img_matches, Scalar::all(-1), Scalar::all(-1),
        vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
    return 0;
    }

And this is my right.jpg and lean.jpg. But I note I will get a same result totally whether I use the mask in the FlannBasedMatcher::match.You can use the mask or not to test. Is there I have missed something or the OpenCV have a bug in my 2.4.13? ?

mask in FlannBasedMatcher::match doesn't work normally

I note the FlannBasedMatcher::match have a parameter mask, so I give a try with following code:

#include<opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
using namespace std;

int main() {
    Mat rightImg = imread("right.jpg", 0);
    Mat leanImg = imread("lean.jpg", 0);
    if (!rightImg.data || !leanImg.data) {
        cout << "Fail to read your image. Please check your path.\n";
        return -1;
    }
    resize(leanImg, leanImg, rightImg.size());
    int minHessian = 400;
    SurfFeatureDetector detector(minHessian);
    vector<KeyPoint> keypoints_right, keypoints_lean;

    detector.detect(rightImg, keypoints_right);
    detector.detect(leanImg, keypoints_lean);

    Mat med_right, med_lean;
    drawKeypoints(rightImg, keypoints_right, med_right);
    drawKeypoints(leanImg, keypoints_lean, med_lean);

    SurfDescriptorExtractor extractor;
    Mat descriptors_right, descriptors_lean;
    extractor.compute(rightImg, keypoints_right, descriptors_right);
    extractor.compute(leanImg, keypoints_lean, descriptors_lean);

    FlannBasedMatcher matcher;
    vector< DMatch > matches;

    Mat mask(rightImg.size(), CV_8UC1, Scalar(255));

    ellipse(mask, Point(rightImg.cols / 2, rightImg.rows / 2), Size(rightImg.cols / 2.5, rightImg.rows / 2.5), 0, 0, 360, Scalar(0), CV_FILLED);

    matcher.match(descriptors_right, descriptors_lean, matches/*, mask*/);// You can use the mask or not to test

    Mat img_matches;
    drawMatches(rightImg, keypoints_right, leanImg, keypoints_lean,
        matches, img_matches, Scalar::all(-1), Scalar::all(-1),
        vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
    return 0;
    }

And this is my right.jpg and lean.jpg. But I note I will get a same result totally whether I use the mask in the FlannBasedMatcher::match.You can use the mask or not to test. Is there I have missed something or the OpenCV have a bug in my 2.4.13?? Can anyone tell me how to use the mask in the FlannBasedMatcher::match? I even don't know its size should same with the query image or train image. But it is a usefull parameter..

mask in FlannBasedMatcher::match doesn't work normally

I note the FlannBasedMatcher::match have a parameter mask, so I give a try with following code:

#include<opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
using namespace std;

int main() {
    Mat rightImg = imread("right.jpg", 0);
    Mat leanImg = imread("lean.jpg", 0);
    if (!rightImg.data || !leanImg.data) {
        cout << "Fail to read your image. Please check your path.\n";
        return -1;
    }
    resize(leanImg, leanImg, rightImg.size());
    int minHessian = 400;
    SurfFeatureDetector detector(minHessian);
    vector<KeyPoint> keypoints_right, keypoints_lean;

    detector.detect(rightImg, keypoints_right);
    detector.detect(leanImg, keypoints_lean);

    Mat med_right, med_lean;
    drawKeypoints(rightImg, keypoints_right, med_right);
    drawKeypoints(leanImg, keypoints_lean, med_lean);

    SurfDescriptorExtractor extractor;
    Mat descriptors_right, descriptors_lean;
    extractor.compute(rightImg, keypoints_right, descriptors_right);
    extractor.compute(leanImg, keypoints_lean, descriptors_lean);

    FlannBasedMatcher matcher;
    vector< DMatch > matches;

    Mat mask(rightImg.size(), CV_8UC1, Scalar(255));

    ellipse(mask, Point(rightImg.cols / 2, rightImg.rows / 2), Size(rightImg.cols / 2.5, rightImg.rows / 2.5), 0, 0, 360, Scalar(0), CV_FILLED);

    matcher.match(descriptors_right, descriptors_lean, matches/*, mask*/);// You can use the mask or not to test

    Mat img_matches;
    drawMatches(rightImg, keypoints_right, leanImg, keypoints_lean,
        matches, img_matches, Scalar::all(-1), Scalar::all(-1),
        vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
    return 0;
    }

And this is my right.jpg and lean.jpg. But I note I will get a same result totally whether I use the mask in the function FlannBasedMatcher::match.You . You can use the mask or not to test. Is there reproduce it. Do I have missed something or the OpenCV have a bug in my 2.4.13? Can anyone tell me how to use the mask in the FlannBasedMatcher::match? I even don't know its size should same with the query image or train image. But I think it is a usefull parameter..

mask in FlannBasedMatcher::match doesn't work normally

Coross post here


I note the FlannBasedMatcher::match have a parameter mask, so I give a try with following code:

#include<opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
using namespace std;

int main() {
    Mat rightImg = imread("right.jpg", 0);
    Mat leanImg = imread("lean.jpg", 0);
    if (!rightImg.data || !leanImg.data) {
        cout << "Fail to read your image. Please check your path.\n";
        return -1;
    }
    resize(leanImg, leanImg, rightImg.size());
    int minHessian = 400;
    SurfFeatureDetector detector(minHessian);
    vector<KeyPoint> keypoints_right, keypoints_lean;

    detector.detect(rightImg, keypoints_right);
    detector.detect(leanImg, keypoints_lean);

    Mat med_right, med_lean;
    drawKeypoints(rightImg, keypoints_right, med_right);
    drawKeypoints(leanImg, keypoints_lean, med_lean);

    SurfDescriptorExtractor extractor;
    Mat descriptors_right, descriptors_lean;
    extractor.compute(rightImg, keypoints_right, descriptors_right);
    extractor.compute(leanImg, keypoints_lean, descriptors_lean);

    FlannBasedMatcher matcher;
    vector< DMatch > matches;

    Mat mask(rightImg.size(), CV_8UC1, Scalar(255));

    ellipse(mask, Point(rightImg.cols / 2, rightImg.rows / 2), Size(rightImg.cols / 2.5, rightImg.rows / 2.5), 0, 0, 360, Scalar(0), CV_FILLED);

    matcher.match(descriptors_right, descriptors_lean, matches/*, mask*/);// You can use the mask or not to test

    Mat img_matches;
    drawMatches(rightImg, keypoints_right, leanImg, keypoints_lean,
        matches, img_matches, Scalar::all(-1), Scalar::all(-1),
        vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
    return 0;
    }

And this is my right.jpg and lean.jpg. But I note I will get a same result totally whether I use the mask in the function FlannBasedMatcher::match. You can use the mask or not to reproduce it. Do I have missed something or the OpenCV have a bug in my 2.4.13? Can anyone tell me how to use the mask in the FlannBasedMatcher::match? I even don't know its size should same with the query image or train image. But I think it is a usefull parameter..

mask in FlannBasedMatcher::match doesn't work normally

Coross Cross post here


I note the FlannBasedMatcher::match have a parameter mask, so I give a try with following code:

#include<opencv.hpp>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
using namespace std;

int main() {
    Mat rightImg = imread("right.jpg", 0);
    Mat leanImg = imread("lean.jpg", 0);
    if (!rightImg.data || !leanImg.data) {
        cout << "Fail to read your image. Please check your path.\n";
        return -1;
    }
    resize(leanImg, leanImg, rightImg.size());
    int minHessian = 400;
    SurfFeatureDetector detector(minHessian);
    vector<KeyPoint> keypoints_right, keypoints_lean;

    detector.detect(rightImg, keypoints_right);
    detector.detect(leanImg, keypoints_lean);

    Mat med_right, med_lean;
    drawKeypoints(rightImg, keypoints_right, med_right);
    drawKeypoints(leanImg, keypoints_lean, med_lean);

    SurfDescriptorExtractor extractor;
    Mat descriptors_right, descriptors_lean;
    extractor.compute(rightImg, keypoints_right, descriptors_right);
    extractor.compute(leanImg, keypoints_lean, descriptors_lean);

    FlannBasedMatcher matcher;
    vector< DMatch > matches;

    Mat mask(rightImg.size(), CV_8UC1, Scalar(255));

    ellipse(mask, Point(rightImg.cols / 2, rightImg.rows / 2), Size(rightImg.cols / 2.5, rightImg.rows / 2.5), 0, 0, 360, Scalar(0), CV_FILLED);

    matcher.match(descriptors_right, descriptors_lean, matches/*, mask*/);// You can use the mask or not to test

    Mat img_matches;
    drawMatches(rightImg, keypoints_right, leanImg, keypoints_lean,
        matches, img_matches, Scalar::all(-1), Scalar::all(-1),
        vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
    return 0;
    }

And this is my right.jpg and lean.jpg. But I note I will get a same result totally whether I use the mask in the function FlannBasedMatcher::match. You can use the mask or not to reproduce it. Do I have missed something or the OpenCV have a bug in my 2.4.13? Can anyone tell me how to use the mask in the FlannBasedMatcher::match? I even don't know its size should same with the query image or train image. But I think it is a usefull parameter..