C# Calling Methods in Generic Classes
- by aip.cd.aish
I am extending the ImageBox control from EmguCV. The control's Image property can be set to anything implementing the IImage interface.
All of the following implement this interface:
Image<Bgr, Byte>
Image<Ycc, Byte>
Image<Hsv, Byte>
Now I want to call the Draw method on the object of the above type (what ever it may be).
The problem is when I access the Image property, the return type is IImage. IImage does not implement the Draw method, but all of the above do.
I believe I can cast the object of type IImage to one of the above (the right one) and I can access the Draw method. But how do I know what the right one is? If you have a better way of doing this, please suggest that as well.