MSER slower in 3.0.0 than 2.4.X (Bug #4478)



描述

The below simple code can be built with either 2.4.X or 3.0.0 by uncommenting or commenting the #define respectively. It simply opens an image file (I'll let you provide your own) and runs MSER on it. On both my Linux box and my Windows box I see that its 3-4X slower in 3.0.0 than 2.4.X. I have built both versions of OpenCV from source using cmake and stuck with the defaults...I have verified that the build settings are as close as they can be.

 
  
 
  
参考:http://code.opencv.org/issues/4478?journal_id=126531
 
  
#include "opencv2/highgui/highgui.hpp" 
#include "opencv2\features2d\features2d.hpp" 
#include "opencv2\imgproc\imgproc.hpp" 
#include <iostream>
#include <chrono>
#include <ctime>

#define USE249
using namespace std;

int main(int argc, char** argv)
{
    std::cout << "OpenCV version: " 
            << CV_MAJOR_VERSION << "." 
            << CV_MINOR_VERSION << "." 
            << CV_SUBMINOR_VERSION
            << std::endl;
    cv::Mat im = cv::imread("C:/example.jpg", 1);
    if (im.empty())
    {
        cout << "Cannot open image!" << endl;
        return -1;
    }
    cv::Mat gray;
    cv::cvtColor(im, gray, cv::COLOR_BGR2GRAY);
    int mnArea = 40 * 40;
    int mxArea = im.rows*im.cols*0.4;
    std::vector< std::vector< cv::Point > > ptblobs;
    std::vector<cv::Rect> bboxes;
    std::chrono::time_point<std::chrono::system_clock> start, end;

    start = std::chrono::system_clock::now();
#ifndef USE249
    cv::Ptr<cv::MSER> mser = cv::MSER::create(1, mnArea, mxArea, 0.25, 0.2);
    mser->detectRegions(gray, ptblobs, bboxes);
#else
    cv::MserFeatureDetector mser(1, mnArea, mxArea, 0.25, 0.2);
    mser(gray, ptblobs);
#endif
    end = std::chrono::system_clock::now();

    std::chrono::duration<double> elapsed_seconds = end - start;
    std::time_t end_time = std::chrono::system_clock::to_time_t(end);

    std::cout << "finished computation at " << std::ctime(&end_time)
        << "elapsed time: " << elapsed_seconds.count() << "s\n";

    cv::namedWindow("image", cv::WINDOW_NORMAL);
    cv::imshow("image", im);
    cv::waitKey(0);

    return 0;
} 


你可能感兴趣的:(MSER)