Should I release cv::Ptr before reassigning?
Say, I have a
cv::Ptr<cv::backgroundsubtractormog2> mogPtr = cv::createBackgroundSubtractorMOG2(300, 16, true);
Later, I'd like to change the configuration of the background subtractor, but I want to reassign the new object pointer to the same variable (mogPtr
):
mogPtr = cv::createBackgroundSubtractorMOG2(300, 64, false);
I wonder if I should release the mogPtr
before I assign a new pointer to it. Is it a bad idea if I do? Will there be a memory leak if I don't?