micro improvements

This commit is contained in:
Kueffner, Maximilian
2025-05-23 15:15:01 +02:00
parent 436a61790c
commit 167dc1f9d4
7 changed files with 19 additions and 13 deletions
+5 -2
View File
@@ -1,15 +1,18 @@
#include "Image.hpp"
#include <filesystem>
#include <format>
#include <memory>
#include <opencv2/imgcodecs.hpp>
#include <stdexcept>
#include <string_view>
pixelarium::imaging::Image::Image(const std::string& uri)
{
if (!std::filesystem::exists(uri))
{
throw std::runtime_error("File not found");
throw std::runtime_error(std::format("File not {} found", uri));
}
this->_img = cv::imread(uri);
this->_img = std::make_unique<cv::Mat>(cv::imread(uri));
}
+6 -7
View File
@@ -1,10 +1,7 @@
#pragma once
#include <filesystem>
#include <memory>
#include <opencv2/core/mat.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/opencv.hpp>
#include <string>
namespace pixelarium::imaging
@@ -17,16 +14,18 @@ class Image
// get back the defaults
Image() = default;
Image(const Image& other) = default;
// we cannot copy an Image since this conflicts with the _img field
Image(const Image& other) = delete;
Image(Image&& other) noexcept = default;
Image& operator=(const Image& other) = default;
// requires a copy ctor which we don't have
Image& operator=(const Image& other) = delete;
Image& operator=(Image&& other) noexcept = default;
~Image() = default;
const cv::Mat& GetImage() const { return this->_img; }
const cv::Mat& GetImage() const { return *this->_img.get(); }
private:
cv::Mat _img;
std::unique_ptr<cv::Mat> _img;
};
} // namespace pixelarium::imaging