I am trying to practice good de-coupled architecture in my computer vision app. Since I am using a .net library (EMGU.CV) that wraps native OpenCV routines, I need to use C# interfaces to abstract out the EMGU classes in order to be able to subsitute them in future.
A concrete example is:
In EMGU I have a foreground detector class, that exposes Image<T,T> class. This call is purely EMGU-oriented.
I am working on IBackgroundDetector for my application, that presumably would support different background detectors, including EMGU.
So for a method in my interface
interface IBackgroundDetector
{
SomeGeneralImageType GetCurrentBackgroundFrame(SomeGeneralImage CameraFrame);
}
How do I go about creating this SomeGeneralImageType class to get the good architecture?
The idea is to create an Interface called
ISomeGeneralImageType.Declare a bunch of methods you would need for an Image (look at C#’s Image as an example for what you’d probably need)
Then for each Image type you create just inherit the interface
ISomeGeneralImageTypeand implement the methods.The way you would do this is by using encapsulation to hide all the complicated stuff you would usually do.
For Example (I really don’t know the real interface of your object, this is just to show the idea):
Then you could use your background detector on any image that implements your interface: