Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not as good as you said #1

Open
gz-happy opened this issue Nov 5, 2020 · 3 comments
Open

Not as good as you said #1

gz-happy opened this issue Nov 5, 2020 · 3 comments

Comments

@gz-happy
Copy link

gz-happy commented Nov 5, 2020

I used gray image, channel: 1, size: 1920 x 1080.
1. These are some my OpenCV code:

 cv::Ptr<cv::MSER> mser_opencv = cv::MSER::create(5, 25, 1500, 0.5);
 timer->Tic();
 mser_opencv->detectRegions(grayimg, contours, bboxes);
 timer->Toc();
 std::cout << "[opencv] detect time: " << timer->Elapsed() << "ms" << std::endl;

2. These are some you methods code:
(1). config:

 alg->set_duplicated_variation(0.2f);
 alg->set_stable_max_variation(0.5f);
 alg->set_stable_delta(5);
 alg->set_min_max_point(25, 0.000723f);

(2). Four algorithms were tested separately:

 timer->Tic();
 mser->extract(mser_res, gray_image);
 timer->Toc();
 std::cout << "[FastMser] detect time: " << timer->Elapsed() << "ms" << std::endl; 

3. Results:
(1). OpenCV: 227ms
(2). img_ms_mser: 158ms
(3). img_linked_linear_mser: 183ms
(4). img_fast_mser_v1: 188ms
(5). img_fast_mser_v2: 160ms

4. So is there a problem with where I set it up? How can we achieve the speed you said.
Thank you very much!

@mmmn143
Copy link
Owner

mmmn143 commented Nov 8, 2020

Hi, thank you for interest in our work.

With the configuration of TextDetection used in paper:

alg->set_duplicated_variation(0.1f);
alg->set_stable_max_variation(0.5f);
alg->set_min_max_point(20, 0.25f);
alg->set_stable_delta(1);

For a grayscale image with the size of 200M:
In visual studio 2012 (used in paper):

  • img_fast_mser_v1 thread-1: 241ms
  • img_fast_mser_v1 thread-4: 90ms
  • cv_mser thread-1: 5820ms
  • cv_mser (comment code in img_opencv3_mser.cpp from 84 to 108) thread-1: 220ms

In visual studio 2019:

  • img_fast_mser_v1 thread-1: 250ms
  • img_fast_mser_v1 thread-4: 98ms
  • cv_mser thread-1: 706ms
  • cv_mser (comment code in img_opencv3_mser.cpp from 84 to 108) thread-1: 230ms

With your configuration:

alg->set_duplicated_variation(0.2f);
alg->set_stable_max_variation(0.5f);
alg->set_stable_delta(5);
alg->set_min_max_point(25, 0.000723f);

For a grayscale image with the size of 200M:
In visual studio 2012 (used in paper):

  • img_fast_mser_v1 thread-1: 211ms
  • img_fast_mser_v1 thread-4: 81ms
  • cv_mser thread-1: 668ms
  • cv_mser (comment code in img_opencv3_mser.cpp from 84 to 108) thread-1: 224ms

In visual studio 2019:

  • img_fast_mser_v1 thread-1: 228ms
  • img_fast_mser_v1 thread-4: 91ms
  • cv_mser thread-1: 256ms
  • cv_mser (comment code in img_opencv3_mser.cpp from 84 to 108) thread-1: 237ms

Conclusion:

  1. img_fast_mser_v1 is stable in both visual studio 2012 and 2019 However, cv_mser in visual studio 2019 is much faster than that in visual studio 2012. This may be because new compiler in visual studio 2019 optimize the code in img_opencv3_mser.cpp from 84 to 108. The code uses a stl vector to store pixels extracted from MSERs. Method of push_back in stl vector may be fully optimized;
  2. img_fast_mser_v1 is stable in different configurations because it uses an efficient pixel extraction method. However, cv_mser is unstable in different configurations. When the number of pixels in MSERs is large (for example, use small delta and large max_point_ratio), img_fast_mser_v1 will have a obvious speed-up compared to cv_mser;
  3. img_fast_mser_v1 or img_fast_mser_v2 is a parallel algorithm. OpenMP may not work on your computer. I notice that the speeds of img_fast_mser_v1 and img_linked_linear_mser are similar. You may use omp_set_num_threads(4) and alg->set_parallel_thread_number(4) to accelerate img_fast_mser_v1 or img_fast_mser_v2;
  4. All experiments in paper are evaluated using visual studio 2012. In the configuration of TextDetection, for a grayscale image with the sie of 200M, img_fast_mser_v1 thread-1 is 24 times faster than cv_mser thread-1. The spped-up in visual studio 2019 reduces to 2.8 times.

@mmmn143
Copy link
Owner

mmmn143 commented Nov 8, 2020

By the way, I only have time on weekends to track down problems.

@gz-happy
Copy link
Author

gz-happy commented Nov 8, 2020

Thank you for your reply, I will try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants