Ask Your Question

Revision history [back]

How do I select Algorithms at runtime?

In OpenCV 2.4 I could construct and configure Algorithms from the base class. If I knew I had a FeatureDetector, my code didn't need to know what kind of feature detector it was. I could use the create() member function with a string name like "SIFT" or "ORB" to construct an algorithm based on a string specified in a config file. I could similarly set algorithm parameters from the base class. Can I do something similar in OpenCV 3.0?

From what I can tell, in OpenCV 3.0 I need to explicitly construct the algorithm with its constructor and can only set parameters in the constructor, or in some cases by reading from a config file (which most algorithms don't yet support), or in some cases by member functions on the derived class (which most algorithms don't provide yet). Is this correct? Are there any plans for future OpenCV releases to bring back construction of algorithms from a string name and setting algorithm parameters without needing to know which algorithm it is?

How do I select Algorithms at runtime?

In OpenCV 2.4 I could construct and configure Algorithms from the base class. If I knew I had a FeatureDetector, my code didn't need to know what kind of feature detector it was. I could use the create() member function with a string name like "SIFT" or "ORB" to construct an algorithm based on a string specified in a config file. I could similarly set algorithm parameters from the base class. Can I do something similar in OpenCV 3.0?

From what I can tell, in OpenCV 3.0 I need to explicitly construct the algorithm with its constructor and can only set parameters in the constructor, or in some cases by reading from a config file (which most algorithms don't yet support), or in some cases by member functions on the derived class (which most algorithms don't provide yet). Is this correct? Are there any plans for future OpenCV releases to bring back construction of algorithms from a string name and setting algorithm parameters without needing to know which algorithm it is?

For some context, I'm writing an open source application built on OpenCV that uses FeatureDetectors, DescriptorExtractors, DescriptorMatchers, etc. in an abstract way. This should compile across a range of OpenCV versions and build configurations (e.g. with or without contrib). At run time I'd like to allow the user to select and configure any detector, descriptor, and matcher that their build of OpenCV happens to support. OpenCV 2.4 had a nice solution for this. Although it was buggy, I miss it.

I suppose my questions are more roadmap questions.

  1. Are algorithms factories ever coming back in OpenCV 3.x?
  2. Is a general parameter configuration API ever coming back?