[Thiago Cafe] Programming is fun!

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember

OpenCV Mat without copying and weird memory ownership

(Posted 2025-04-30 06:29:52)

Recently I found an interesting OpenCV behaviour.

OpenCV cv::Mat is built to be easy to use. It will allocate, free and reallocate it's own internal data. That's fine for most of the uses, but what if you are sensitive to extra memory allocations?

As you might expect, C++ developers very often track the memory ownership of any allocated piece of memory, especially when copying memory is not an option.

To use cv::Mat without copying the buffer, you can use this class constructor that does not own the memory:

Read More »

Pages: 1

About this blog

This blog is about programming and other technological things. Written by someone developing software for fun and professionally for longer than I want to admit and in more programming languages that I can remember