filmout_display/src/image.cpp

36 lines
1.0 KiB
C++

#include "image.hpp"
Image::Image () {
}
Mat Image::getBlank () {
return Mat::zeros(height, width, CV_8UC3);
}
Mat Image::loadImage (string& image_path, uint64_t& x, uint64_t& y, uint64_t& w, uint64_t& h) {
string located_path = samples::findFile(image_path);
Mat loaded = imread(located_path, IMREAD_COLOR);
Mat image = getBlank();
if (image.empty()) {
cerr << "Image " << image << " empty" << endl;
} else {
cout << "loaded " << image_path << endl;
cout << " dim " << loaded.cols << "x" << loaded.rows << endl;
//resize(loaded, resized, Size(1280, 1080));
cout << " image " << image.cols << "x" << image.rows << endl;
//cout << "resized " << resized.cols << "x" << resized.rows << endl;
//resized.copyTo(image(Rect(0, 0, resized.cols, resized.rows)));
loaded.copyTo(image(Rect(x, y, loaded.cols, loaded.rows)));
flip(image, image, 0);
#if (CV_VERSION_MAJOR >= 4)
cvtColor(image, image, cv::COLOR_BGR2RGB);
#else
cvtColor(image, image, CV_BGR2RGB);
#endif
}
return image;
}