Cache the blank Mat, no need to re-generate each time it's needed by loadImage()

This commit is contained in:
mmcwilliams 2024-04-27 12:09:33 -06:00
parent a2b69433e2
commit 62c7181906
1 changed files with 4 additions and 1 deletions

View File

@ -5,7 +5,10 @@ Image::Image () {
} }
Mat Image::getBlank () { Mat Image::getBlank () {
return Mat::zeros(height, width, CV_8UC3); if (blank.empty()) {
blank = Mat::zeros(height, width, CV_8UC3);
}
return blank;
} }
Mat Image::loadImage (string& image_path, uint64_t& x, uint64_t& y, uint64_t& w, uint64_t& h) { Mat Image::loadImage (string& image_path, uint64_t& x, uint64_t& y, uint64_t& w, uint64_t& h) {