orb_bugreport.cpp

test case - Julius Adorf, 2012-05-29 06:29 pm

Download (1.1 kB)

 
1
#include <boost/foreach.hpp>
2
#include <iostream>
3
#include <opencv2/features2d/features2d.hpp>
4
#include <opencv2/highgui/highgui.hpp>
5
#include <opencv2/imgproc/imgproc.hpp>
6
#include <vector>
7
8
int main(int argc, char* argv[]) {
9
    cv::Ptr<cv::FeatureDetector> fd = cv::FeatureDetector::create("ORB");
10
    cv::Ptr<cv::DescriptorExtractor> de = cv::DescriptorExtractor::create("ORB");
11
12
    cv::Mat image = cv::imread("image.jpg");
13
    cv::Mat roi = cv::imread("roi.png", 0);
14
15
    std::vector<cv::KeyPoint> keypoints;
16
    fd->detect(image, keypoints, roi);
17
    cv::Mat descriptors;
18
    de->compute(image, keypoints, descriptors);
19
20
    cv::Mat out;
21
    cv::drawKeypoints(roi, keypoints, out);
22
23
    cv::imshow("orb_bugreport", out);
24
25
    cv::waitKey(-1);
26
27
    // Dilate
28
    cv::Mat se = cv::Mat::ones(3, 3, CV_8UC1);
29
    cv::Mat dilatedRoi;
30
    cv::dilate(roi, dilatedRoi, se);
31
32
    BOOST_FOREACH(const cv::KeyPoint& k, keypoints) {
33
       if (dilatedRoi.at<uint8_t > (k.pt) != 255) {
34
            std::cerr << "keypoint outside of region of interest" << std::endl;
35
       }
36
    }
37
38
    return 0;
39
}