Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Image.cs #481

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update Image.cs #481

wants to merge 1 commit into from

Conversation

CSBVision
Copy link
Contributor

We would like to suggest an additional constructor for the Image class to improve its usability in inheritance chains.
Deriving a child class from Image is possible, however all inherited functions that return Image instances return base class object (Image instances) only.
For example, DerivedImage.Clone() will return only an Image, but not a DerivedImage, and the temporary Image instance has to be converted into a DerivedImage.
This requires an explicit instantiation of DerivedImage.
Currently, the latter cannot be performed without copying the data from the temporary source image (i.e. the return value of the inherited member function like Clone()) into the new one.
Here, the additional protected Image constructor allows to move the data from the temporary source image into the newly created one.
Alternatively, this functionality could also be implemented in method that swaps the member variables between two Image instances, but it requires access to private data members as welll such that it also requires an extension of your sources.
Therefore, we found this modification to be the best suited one for this functionality and would appreciate if you accept our proposed modifications.
Thanks in advance!

We would like to suggest an additional constructor for the Image class to improve its usability in inheritance chains.
Deriving a child class from Image is possible, however all inherited functions that return Image instances return base class object (Image instances) only.
For example, DerivedImage.Clone() will return only an Image, but not a DerivedImage, and the temporary Image instance has to be converted into a DerivedImage.
This requires an explicit instantiation of DerivedImage.
Currently, the latter cannot be performed without copying the data from the temporary source image (i.e. the return value of the inherited member function like Clone()) into the new one.
Here, the additional protected Image constructor allows to move the data from the temporary source image into the newly created one.
Alternatively, this functionality could also be implemented in method that swaps the member variables between two Image instances, but it requires access to private data members as welll such that it also requires an extension of your sources.
Therefore, we found this modification to be the best suited one for this functionality and would appreciate if you accept our proposed modifications.
Thanks in advance!
@emgucv
Copy link
Owner

emgucv commented May 19, 2021

The Image<,> class is based on the old IplImage* used in opencv v2.0 and earlier release, we are planning to phase it out in the future (when open cv did so).

You can based your class on Emgu.CV.Mat instead, which is based on "cv::Mat" used by opencv 3.0 and forward.

If your class is based on Emgu.CV.Mat, you can use CvInvoke.Swap ( https://www.emgu.com/wiki/files/4.5.1/document/html/62b2d470-fe90-cb8e-130f-9f1fe1e4a219.htm ) function to swap the data in the Mat.

@CSBVision
Copy link
Contributor Author

Yes, but switiching over to using Mat results in losing all the implemented handy member functions that are available in the Image class. Thus, we prefer sticking with the latter. Here, swap() does not swap the ManagedArrays but only the Mat pointers. Alternatively, an extended swap() function in Image would be possible as well but it cannot be implemented in derived classes because the _array field is private. Therefore, we thought that the additional constructor offering this swap functionality is safer as it can only be used at construction time but not arbitrarily.

But does the deprecation of OpenCV's IplImage interface also mean that EmguCV's Image class is deprecated as well? If so, are you planning to move the additional functionality provided by the Image<> class to Mat instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants