Ask Your Question
0

How can I add my own feature code into sticther pipeline of OpenCV?

asked 2014-07-01 05:47:50 -0600

erogol gravatar image

I have a hard stitching problem therfore I need to define my own feature extraction routine instead of native SURF or other.

The main problem is, my images are symmetric to each other. Therefore, matching features are also symmetric that skwed the expected homography estimation. Hence I need to define the region that suposedly used in feature extraction. I also believe Lowe's SIFT is better than the SURF so I need to define my feature extraction routine using SIFT on a given area of the images.

How can I inject my own feature extraction routine, for instance well-known SIFT implementation of DAVID LOWE, instead of SURF at the below code that I work on ?

vector<Mat> images;
images.push_back(imread("images/isvec_left.jpg"));
images.push_back(imread("images/iscev_right.jpg"));

Mat pano;
Stitcher stitcher = Stitcher::createDefault(true);

stitcher.setWarper(new PlaneWarper());
stitcher.setFeaturesFinder(new detail::SurfFeaturesFinder(1000,4,4,4,4));
stitcher.setRegistrationResol(0.1);
stitcher.setSeamEstimationResol(0.1);
stitcher.setCompositingResol(1);
stitcher.setPanoConfidenceThresh(1);
stitcher.setWaveCorrection(true);
stitcher.setWaveCorrectKind(detail::WAVE_CORRECT_HORIZ);
stitcher.setFeaturesMatcher(new detail::BestOf2NearestMatcher(false,0.3));
stitcher.setBundleAdjuster(new detail::BundleAdjusterRay());
Stitcher::Status status = Stitcher::ERR_NEED_MORE_IMGS;
try{
    status = stitcher.stitch(images, pano);
    cout << status << endl;
}
catch(cv::Exception e){
    cout << "Stitching is not successfull!!" << endl;
}
imwrite("RESULT.jpg", pano);
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-07-01 09:23:01 -0600

Melgor gravatar image

Hi, There is no easy way to use SIFT features in stitching module. You have to create separate class like "detail::SiftFeaturesFinder" to do it. New class should be added in "opencv/modules/stitching/src/matchers.cpp" and "opencv/modules/stitching/include/opencv2/stitching/detail/matchers.hpp"

This should be rather easy, because all process relay on extracting features. If you need to set only specific region for keypoint extraction, you need to build black-white mask -> your new class should take it too.

All work need changes in OpenCV, so after all you need to recompile it.

edit flag offensive delete link more
0

answered 2014-07-21 11:01:58 -0600

Duffycola gravatar image

If you stick to the stitching_detailed example you can actually replace the FeaturesFinder part with a detector + descriptor combination of your choice. Here's an excerpt:

Ptr<FeatureDetector> detector = 
    new PyramidAdaptedFeatureDetector(
        new DynamicAdaptedFeatureDetector(
            new FastAdjuster(20, true), 40, 60, 4),
        8
    );
Ptr<DescriptorExtractor> descriptor = DescriptorExtractor::create("ORB");

....

    (*detector).detect(img, features[i].keypoints);
    (*descriptor).compute(img, features[i].keypoints, features[i].descriptors);
    features[i].img_size = img.size();
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-07-01 05:47:50 -0600

Seen: 1,745 times

Last updated: Jul 21 '14