cv::Mat image = cv::imread("example.jpg"); // use image here image.release(); // release memory
cv::Mat *image = new cv::Mat; // use image here image->release(); // release memory delete image;In this example, a cv::Mat object is allocated dynamically using the "new" operator and stored in a pointer variable "image". After using the image, the memory is released using the release() function, followed by deleting the pointer. The cv::Mat::release() function is a part of OpenCV library.