I have a function that is executed many times in the application lifespan. In order to optimize the code, which solution is better?
Is this:
void foo() {
static const cv::Mat zeroMat16 = cv::Mat::zeros(rows, cols, CV_16UC1);
cv::Mat newMat = zeroMat16.clone();
...
}
faster than this:
void foo() {
cv::Mat newMat = cv::Mat::zeros(rows, cols, CV_16UC1);
...
}
Or the efficiency is pretty much the same?