From 62c718190699125788663d4ed1ca85b352626889 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sat, 27 Apr 2024 12:09:33 -0600 Subject: [PATCH] Cache the blank Mat, no need to re-generate each time it's needed by loadImage() --- src/image.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/image.cpp b/src/image.cpp index b9c5e88..4787b85 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -5,7 +5,10 @@ Image::Image () { } 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) {