Ask Your Question

huckw's profile - activity

2019-08-20 12:26:36 -0600 commented question Quickly draw MSER region (in Java)

I've found another oddity in Java version of OpenCV MSER...the mindiversity parameter seems to have no effect. I would

2019-07-30 12:43:02 -0600 commented question Quickly draw MSER region (in Java)

Both the python and Java implementations work. The Python one is wicked fast, the Java one is painfully slow (even when

2019-07-30 09:05:35 -0600 commented question Quickly draw MSER region (in Java)

Sorry about that....I've edited my question to include the relevant snippet of Java code

2019-07-30 09:05:06 -0600 edited question Quickly draw MSER region (in Java)

Quickly draw MSER region (in Java) I have several MSER regions detected and for each one I'd like to convert them into a

2019-07-29 18:10:15 -0600 asked a question Quickly draw MSER region (in Java)

Quickly draw MSER region (in Java) I have several MSER regions detected and for each one I'd like to convert them into a

2015-07-14 11:39:16 -0600 received badge  Enthusiast
2015-07-07 11:11:43 -0600 commented question MSER slower in 3.0.0 than 2.4.9

Do I have to do anything to specify I want the greyscale version of MSER rather than the color version? The image I run detectRegions on is greyscale.

2015-07-07 11:10:32 -0600 received badge  Editor (source)
2015-07-07 10:40:07 -0600 commented question MSER slower in 3.0.0 than 2.4.9

Thats a good question....I used defaults in cmake (the gui version) for both builds. But I went back and checked and as near as I can tell they are essentially the same. I did notice that in 3.0.0 "with IPP" is checked (enabled) by default as I hear there is a subset of IPP for free....in my 2.4.9 build it was disabled completely. Just for giggles I rebuilt 3.0.0 with IPP disabled but it did not change the performance at all. I also tried using a UMat instead of a Mat but it too had no effect.

2015-07-07 01:33:43 -0600 asked a question MSER slower in 3.0.0 than 2.4.9

I have a project that I originally developed with opencv2.4.9 that used mser like so...

cv::MserFeatureDetector mser(delta, mnArea, mxArea, maxVariation, minDiversity);
std::vector< std::vector< cv::Point > > ptblobs;
mser(img, ptblobs);

It works just like I expect. I switched to opencv3.0.0 and so had to change the above to this...

cv::Ptr<cv::MSER> mser = cv::MSER::create(delta, mnArea, mxArea, maxVariation, minDiversity);
std::vector< std::vector< cv::Point > > ptblobs;
std::vector<cv::Rect> bboxes;
mser->detectRegions(img, ptblobs, bboxes);

It is MUCH MUCH slower in version 3.0.0 than 2.4.9. If I comment out the detectRegions() line everything else runs same speed as before...so I know its the detectRegions() call and not some other thing or things. What am I doing wrong?

Thanks in advance for your help

EDIT/ADDITION I've come up with an uber simple project that isolates and exhibits the issue. With 2.4.9 I get 1.5sec and with 3.0.0 its 4.4sec. I'm posting the code here just in case its useful...

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