Deleting a Mat object

A Mat object can be cleaned up by using its release function, however, since release is called in the destructor of the Mat class, there is usually no need to call this function at all. It's important to note that the Mat class shares the same data between multiple objects that point to it. This has the advantage of less data copying and less memory usage, and since all of the reference counting is done automatically, you don't usually need to take care of anything.

The only scenario in which you need to take extra care of how and when your objects and data are cleaned up is when you use a data pointer to construct a Mat object, as mentioned in the previous section. In such cases, calling the release function of the Mat class, or its destructor, will have nothing to do with the external data you have used to construct it, and the cleanup will be completely on your shoulders.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.216.75