opencvimage-processingpanoramasimage-stitching

OpenCV detect and compute image features


Recently upgraded OpenCV from 3.4.5. to OpenCV 4.2.0.

Before I followed this stitching example: https://github.com/opencv/opencv/blob/5131619a1a4d1d3a860b5da431742cc6be945332/samples/cpp/stitching_detailed.cpp (particularly line 480). After upgrading, I altered the code to align more with this newer example: https://github.com/opencv/opencv/blob/master/samples/cpp/stitching_detailed.cpp (Note line 481).

Problem is with this new computeImageFeatures function, I am getting less detected features. Older code with same images gave me 1400+ features but computeImageFeatures gave me exactly 500 features per image. Any ideas how to "fix" this? I believe it also causes the "Bundle Adjuster" to fail later.


Solution

  • According to documentation of cv::ORB::create, default value of nfeatures argument is 500:

    The first argument is nfeatures, you may set the first argument to grater number like 2000.

    Here are the constructor arguments:

    static Ptr<ORB> cv::ORB::create (int     nfeatures = 500,
                                     float   scaleFactor = 1.2f,
                                     int     nlevels = 8,
                                     int     edgeThreshold = 31,
                                     int     firstLevel = 0,
                                     int     WTA_K = 2,
                                     int     scoreType = ORB::HARRIS_SCORE,
                                     int     patchSize = 31,
                                     int     fastThreshold = 20 
                                    )       
    

    Try modifying:

    if (features_type == "orb")
    {
        finder = ORB::create();
    }
    

    to

    if (features_type == "orb")
    {
        finder = ORB::create(2000);
    }
    

    In case you are not using ORB, but other type of features, read the documentation of the constructor.
    I assume all types has a limiter argument.