Merge branch 'main' of ssh://git.sixteenmillimeter.com/16mm/filmout_display

This commit is contained in:
Matt McWilliams 2024-08-29 18:05:37 -04:00
commit f8dc0a0283
2 changed files with 37 additions and 20 deletions

View File

@ -22,6 +22,21 @@ This application will take over the full screen when launched and display frames
* [OpenCV](https://github.com/opencv/opencv) * [OpenCV](https://github.com/opencv/opencv)
* [nlohmann/json](https://github.com/nlohmann/json) * [nlohmann/json](https://github.com/nlohmann/json)
### Submodules
To clone this project with the `nlohmann/json` submodule included:
```
git clone --recursive https://git.sixteenmillimeter.com/16mm/filmout_display.git
```
If you have already cloned this repo:
```bash
git submodule init
git submodule update
```
### Installing on Debian-based systems ### Installing on Debian-based systems
```bash ```bash

View File

@ -5,32 +5,34 @@ 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();
} }
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) {
string located_path = samples::findFile(image_path); string located_path = samples::findFile(image_path);
Mat loaded = imread(located_path, IMREAD_COLOR); Mat loaded = imread(located_path, IMREAD_COLOR);
Mat resized; Mat resized;
Mat image = getBlank(); Mat image = getBlank();
if (loaded.empty()) { if (loaded.empty()) {
cerr << "{ \"error\" : \"" << image_path << " empty\" }" << endl; cerr << "{ \"error\" : \"" << image_path << " empty\" }" << endl;
} else { } else {
cout << "{ \"loaded\" : \"" << image_path << "\", "; resize(loaded, resized, Size(w, h));
cout << "\"original\" : { \"w\" : " << loaded.cols << ", \"h\" : " << loaded.rows << " }, ";
cout << "\"resized\" : { \"w\" : " << w << ", \"h\" : " << h << " } }" << endl; cout << "{ \"loaded\" : \"" << image_path << "\", ";
resize(loaded, resized, Size(h, w)); cout << "\"original\" : { \"w\" : " << loaded.cols << ", \"h\" : " << loaded.rows << " }, ";
resized.copyTo(image(Rect(x, y, resized.cols, resized.rows))); cout << "\"resized\" : { \"w\" : " << resized.cols << ", \"h\" : " << resized.rows << " } }" << endl;
flip(image, image, 0);
resized.copyTo(image(Rect(x, y, resized.cols, resized.rows)));
flip(image, image, 0);
#if (CV_VERSION_MAJOR >= 4) #if (CV_VERSION_MAJOR >= 4)
cvtColor(image, image, cv::COLOR_BGR2RGB); cvtColor(image, image, cv::COLOR_BGR2RGB);
#else #else
cvtColor(image, image, CV_BGR2RGB); cvtColor(image, image, CV_BGR2RGB);
#endif #endif
} }
return image; return image;