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;
} 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值