Ask Your Question
2

How to used MSER in OpenCV2.4.2 to detect regions?

asked 2012-07-14 03:08:02 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

We know that MSER(Maximally stable extremal region)was to detect affine regions between stereo images(http://en.wikipedia.org/wiki/Maximallystableextremal_regions).I just could get points(x pixel coordinate and y pixel coordinate) using MserFeatureDetector,However,I extremmely like to get region parameters besides points,such format: u(pixel coordinate x ),v(pixel coordinate y),a,b,c(a,b and c are affine region parameters),ellipse would be drawn by a,b and c.Is any friend would help me to solve the problem?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2012-07-14 04:56:13 -0600

AlexanderShishkov gravatar image

You can get contours of MSER using operator().

#include <opencv2/opencv.hpp>

int main(int argc, char *argv[])
{
    Mat box = imread("box.png",1);
    MSER ms;
    vector<vector<Point>> regions;
    ms(box, regions, Mat());
    for (int i = 0; i < regions.size(); i++)
    {
        ellipse(box, fitEllipse(regions[i]), Scalar(255));
    }
    imshow("mser", box);
    waitKey(0);
    return 0;
}

image description

edit flag offensive delete link more

Comments

Whenever I try to run this code, I get an error message: OpenCV Error: Bad argument (Input array is not a valid matrix) in unknown function, file ......\src\opencv\modules\imgproc\src\utils.cpp, line 53 And then it stops responding! I'm using OpenCV 2.4.2, with Visual Studio 2012 RC. Any idea what's going wrong, and how I can fix it?

rdasgupta gravatar imagerdasgupta ( 2012-08-11 09:32:00 -0600 )edit

Please check that your matrix is not empty.

AlexanderShishkov gravatar imageAlexanderShishkov ( 2012-08-29 09:32:55 -0600 )edit

If i try this, i get an error that no instance can be created of an abstract class in line "MSER ms;" in line "ms(box, regions, Mat());" i get another error stating that i make a call of a class type without a ()-operator or convertion function for type "pointer-to-function". I'm using openCV 3.0.0 and Visual Studio 2012 What can i do?

anmi gravatar imageanmi ( 2015-10-14 03:38:59 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-07-14 03:08:02 -0600

Seen: 12,233 times

Last updated: Jul 14 '12