Updated based on runtime-related errors. Was crashing under normal use.

This commit is contained in:
mmcwilliams 2024-08-25 09:28:24 -04:00
parent d7c06543f3
commit d1e72528c7
1 changed files with 22 additions and 20 deletions

View File

@ -6,7 +6,7 @@ Image::Image () {
Mat Image::getBlank () { Mat Image::getBlank () {
if (blank.empty()) { if (blank.empty()) {
blank = Mat::zeros(height, width, CV_8UC3); blank = Mat::zeros(Size(width, height), CV_8UC3);
} }
return blank.clone(); return blank.clone();
} }
@ -20,10 +20,12 @@ Mat Image::loadImage (string& image_path, uint64_t& x, uint64_t& y, uint64_t& w,
if (loaded.empty()) { if (loaded.empty()) {
cerr << "{ \"error\" : \"" << image_path << " empty\" }" << endl; cerr << "{ \"error\" : \"" << image_path << " empty\" }" << endl;
} else { } else {
resize(loaded, resized, Size(w, h));
cout << "{ \"loaded\" : \"" << image_path << "\", "; cout << "{ \"loaded\" : \"" << image_path << "\", ";
cout << "\"original\" : { \"w\" : " << loaded.cols << ", \"h\" : " << loaded.rows << " }, "; cout << "\"original\" : { \"w\" : " << loaded.cols << ", \"h\" : " << loaded.rows << " }, ";
cout << "\"resized\" : { \"w\" : " << w << ", \"h\" : " << h << " } }" << endl; cout << "\"resized\" : { \"w\" : " << resized.cols << ", \"h\" : " << resized.rows << " } }" << endl;
resize(loaded, resized, Size(h, w));
resized.copyTo(image(Rect(x, y, resized.cols, resized.rows))); resized.copyTo(image(Rect(x, y, resized.cols, resized.rows)));
flip(image, image, 0); flip(image, image, 0);