siftmask.cpp

run to reproduce bug - Julius Adorf, 2011-05-04 04:09 pm

Download (1.2 kB)

 
1
2
#include <cv.h>
3
#include <opencv2/highgui/highgui.hpp>
4
#include <vector>
5
#include <iostream>
6
#include <stdlib.h>
7
8
using namespace std;
9
using namespace cv;
10
11
// see http://opencv-users.1802565.n2.nabble.com/Problems-about-the-OpenCV-SIFT-feature-detector-td6084481.html
12
// see https://code.ros.org/trac/opencv/ticket/1029
13
// see http://opencv.willowgarage.com/documentation/cpp/features2d_common_interfaces_of_feature_detectors.html?highlight=siftfeaturedetector#SiftFeatureDetector
14
int main(int argc, char **argv) {
15
    if (argc != 3) {
16
        cerr << "Usage: siftmask <image> <mask>" << endl;
17
        return 1;
18
    }
19
20
    Mat image = imread(argv[1], 0);
21
    Mat mask = imread(argv[2], 0);
22
23
    assert(CV_8U == mask.type());
24
    vector<KeyPoint> keypoints;
25
    SiftFeatureDetector fd = SiftFeatureDetector(SIFT::DetectorParams::
26
                                         GET_DEFAULT_THRESHOLD(),
27
                                         SIFT::DetectorParams::
28
                                         GET_DEFAULT_EDGE_THRESHOLD());
29
    fd.detect(image, keypoints, mask);
30
    Mat outImg;
31
    drawKeypoints(image, keypoints, outImg);
32
    imshow("mask", mask);
33
    waitKey(-1);
34
    imshow("keypoints", outImg);
35
    waitKey(-1);
36
    return 0;
37
}
38