diff options
author | 2022-08-29 12:19:25 -0400 | |
---|---|---|
committer | 2022-08-29 12:19:25 -0400 | |
commit | d6663fe7b71db340b3c7a1d069c473f725caa3a8 (patch) | |
tree | f6db2a320abef031d4516541449735733a505899 /imageutil.cpp | |
parent | 67be79385f0b22fe6428e213d2b6422742d994c4 (diff) | |
download | deduper-d6663fe7b71db340b3c7a1d069c473f725caa3a8.tar.xz |
Trying to support the superior operating system.
Also reformat a bit of legacy code. Smells like mold.
Diffstat (limited to 'imageutil.cpp')
-rw-r--r-- | imageutil.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/imageutil.cpp b/imageutil.cpp index b3609d4..fd78ccf 100644 --- a/imageutil.cpp +++ b/imageutil.cpp @@ -1,8 +1,12 @@ #include <algorithm> #include <cmath> +#include <fstream> #include <iterator> #include <limits> //#include <cstdio> + +#include <opencv2/imgcodecs.hpp> + #include "imageutil.hpp" //libpuzzle uses a contrast-based cropping, and clamps the cropped area to a given percentage. @@ -111,3 +115,15 @@ cv::Mat image_util::blend_white(cv::Mat m) } return ret; } + +cv::Mat image_util::imread_path(const std::filesystem::path &p, int flags) +{ + auto size = std::filesystem::file_size(p); + std::fstream fst(p, std::ios::binary | std::ios::in); + std::vector<char> dat; + dat.resize(size); + fst.read(dat.data(), size); + fst.close(); + cv::Mat img = cv::imdecode(dat, flags); + return img; +} |