Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to derive from algorithm

Hi,

I'd like to implement a variety of segmentation algorithms using opencv. Therefore I'd like to use the Algorithm class as a base class to be able to set and get parameters to the segmentation algorithms.

Unfortunately i have a hard time understanding what's necessary to do so and the opencv documentation in that regard is not detailed enough for me to comprehend which steps are necessary.

The documentation I tried to follow is this one http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=algorithm#Algorithm in the section "Creating Own Algorithm"

Off course I declared Alogirhtm as a BaseClass of MyAlgorithm

class MyAlgorithm: public cv::Algorithm{

private:
    double aMem = 100.0;

public:
    MyAlgorithm() {}
    virtual ~MyAlgorithm() {}
    virtual cv::AlgorithmInfo* info() {}

};

The above code is a summary from step 1-3. But I now have no idea how info() has to be implemented. And there is also mentioned that I schould add an instance of AlgorithmInfo to my class. But there exists no AlgorithmInfo default constructor and i don't know how the existing constructor is meant to be handled. I also had a look at the recommended piece of code frome here:

https://github.com/Itseez/opencv/blob/master/modules/ml/src/ml_init.cpp

but I don't understand how that relates to to the info method. In that piece of code the info method is called from an obj, but there isn't mentioned what the method should look like.

I would really appreciate someone giving me a simple example on how to setup my own algorithm.

Thx in advance!