Suppose I want to use a Mat as float. The following code can be compiled without error. However, is it safe doing this?
Mat im = imread('test.jpg', CV_LOAD_IMAGE_GRAYSCALE);
im.convertTo(im, CV_32F1);
I want to do this because it's written more compact, otherwise I need to create a temporary Mat.
The documentation of Mat::convertTo() doesn't give much information about the memory usage of the function.
Mat::convertTo function should be safe to use when using inplace calls (i.e. same input and output Mat objects).
According to OpenCV DevZone, this function did have a bug when using inplace calls, but it was fixed a few years ago.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With