Misc Improvements (#7)
* get rid of optional<ptr> -> double indirection * more optional cleanup * fix * add more render pixel type options * towards different views * missing virtual declaration of ShowImage * fix runtime * init image view factory * fix build Render Image close button re-enable add readme init documentation use awesomeDoxygen ci build docs install doxygen id token permission add pages write permission
This commit is contained in:
committed by
Maximilian Kueffner
parent
0be064bb8e
commit
235d00192a
@@ -7,9 +7,13 @@ message(STATUS "OpenCV_LIBs from: " ${OpenCV_LIBS})
|
||||
|
||||
set(IMAGELIBSRC
|
||||
IPixelariumImage.hpp
|
||||
PixelariumImageFactory.hpp
|
||||
PixelariumImageFactory.cpp
|
||||
impl/PixelariumJpg.hpp
|
||||
impl/PixelariumJpg.cpp
|
||||
impl/PixelariumPng.hpp
|
||||
impl/PixelariumPng.cpp
|
||||
impl/PixelariumCzi.hpp
|
||||
impl/PixelariumCzi.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <opencv2/core/mat.hpp>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace pixelarium::imaging
|
||||
@@ -35,15 +34,27 @@ class IPixelariumImage
|
||||
virtual ~IPixelariumImage() = default;
|
||||
|
||||
// this will have to throw or something for multidimensional images
|
||||
virtual std::optional<std::unique_ptr<cv::Mat>> TryGetImage() = 0;
|
||||
virtual std::unique_ptr<cv::Mat> TryGetImage() = 0;
|
||||
|
||||
virtual std::optional<std::unique_ptr<cv::Mat>> TryGetImage(const IImageQuery&) = 0;
|
||||
virtual std::unique_ptr<cv::Mat> TryGetImage(const IImageQuery&) = 0;
|
||||
|
||||
virtual std::string Name() const noexcept = 0;
|
||||
virtual std::vector<std::unique_ptr<cv::Mat>> TryGetImages(const IImageQuery&) = 0;
|
||||
|
||||
virtual bool Empty() const noexcept = 0;
|
||||
|
||||
virtual std::filesystem::path Uri() const noexcept = 0;
|
||||
// default implemented
|
||||
public:
|
||||
virtual std::filesystem::path Uri() const noexcept { return this->uri_; }
|
||||
|
||||
virtual std::string Name() const noexcept
|
||||
{
|
||||
if (!this->uri_.empty())
|
||||
{
|
||||
return this->uri_.filename().string();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
public:
|
||||
const static ImageFileType type_{ImageFileType::ABSTRACT};
|
||||
|
||||
@@ -8,26 +8,6 @@
|
||||
#include "impl/PixelariumJpg.hpp"
|
||||
#include "impl/PixelariumPng.hpp"
|
||||
|
||||
constexpr pixelarium::imaging::ImageFileType ExtensionToType(const std::string& extension)
|
||||
{
|
||||
std::string lower_ext{extension};
|
||||
std::ranges::transform(extension, lower_ext.begin(), [](const char c) -> char { return std::tolower(c); });
|
||||
|
||||
if (lower_ext == ".jpg" || lower_ext == ".jpeg")
|
||||
{
|
||||
return pixelarium::imaging::ImageFileType::JPG;
|
||||
}
|
||||
if (lower_ext == ".png")
|
||||
{
|
||||
return pixelarium::imaging::ImageFileType::PNG;
|
||||
}
|
||||
if (lower_ext == ".czi")
|
||||
{
|
||||
return pixelarium::imaging::ImageFileType::CZI;
|
||||
}
|
||||
|
||||
return pixelarium::imaging::ImageFileType::UNKNOWN;
|
||||
}
|
||||
|
||||
/*static*/ std::unique_ptr<pixelarium::imaging::IPixelariumImage>
|
||||
pixelarium::imaging::PixelariumImageFactory::CreateImage(const std::string& uri)
|
||||
|
||||
@@ -5,6 +5,27 @@
|
||||
#include "IPixelariumImage.hpp"
|
||||
namespace pixelarium::imaging
|
||||
{
|
||||
constexpr pixelarium::imaging::ImageFileType ExtensionToType(const std::string& extension)
|
||||
{
|
||||
std::string lower_ext{extension};
|
||||
std::ranges::transform(extension, lower_ext.begin(), [](const char c) -> char { return std::tolower(c); });
|
||||
|
||||
if (lower_ext == ".jpg" || lower_ext == ".jpeg")
|
||||
{
|
||||
return pixelarium::imaging::ImageFileType::JPG;
|
||||
}
|
||||
if (lower_ext == ".png")
|
||||
{
|
||||
return pixelarium::imaging::ImageFileType::PNG;
|
||||
}
|
||||
if (lower_ext == ".czi")
|
||||
{
|
||||
return pixelarium::imaging::ImageFileType::CZI;
|
||||
}
|
||||
|
||||
return pixelarium::imaging::ImageFileType::UNKNOWN;
|
||||
}
|
||||
|
||||
class PixelariumImageFactory
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -92,7 +92,7 @@ pixelarium::imaging::PixelariumCzi::PixelariumCzi(const std::string& uri)
|
||||
this->uri_ = std::filesystem::path(uri);
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<cv::Mat>> pixelarium::imaging::PixelariumCzi::TryGetImage()
|
||||
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumCzi::TryGetImage()
|
||||
{
|
||||
auto stream = libCZI::CreateStreamFromFile(this->uri_.wstring().c_str());
|
||||
auto cziReader = libCZI::CreateCZIReader();
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
|
||||
namespace pixelarium::imaging
|
||||
{
|
||||
struct CziParams : public IImageQuery
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class PixelariumCzi : public IPixelariumImage
|
||||
{
|
||||
public:
|
||||
@@ -13,26 +18,20 @@ class PixelariumCzi : public IPixelariumImage
|
||||
|
||||
// IPixelariumImage member implementations
|
||||
public:
|
||||
std::optional<std::unique_ptr<cv::Mat>> TryGetImage() override;
|
||||
std::unique_ptr<cv::Mat> TryGetImage() override;
|
||||
|
||||
std::optional<std::unique_ptr<cv::Mat>> TryGetImage(const IImageQuery&) override
|
||||
std::unique_ptr<cv::Mat> TryGetImage(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not implemented.");
|
||||
}
|
||||
|
||||
std::string Name() const noexcept override
|
||||
std::vector<std::unique_ptr<cv::Mat>> TryGetImages(const IImageQuery&) override
|
||||
{
|
||||
if (!this->uri_.empty())
|
||||
{
|
||||
return this->uri_.filename().string();
|
||||
}
|
||||
|
||||
return {};
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not implemented.");
|
||||
}
|
||||
|
||||
std::filesystem::path Uri() const noexcept override { return this->uri_.string(); }
|
||||
|
||||
bool Empty() const noexcept override { return this->is_empty_; }
|
||||
|
||||
public:
|
||||
|
||||
@@ -16,7 +16,7 @@ pixelarium::imaging::PixelariumJpg::PixelariumJpg(const std::string& uri)
|
||||
this->uri_ = std::filesystem::path(uri);
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<cv::Mat>> pixelarium::imaging::PixelariumJpg::TryGetImage()
|
||||
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumJpg::TryGetImage()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -14,27 +14,18 @@ class PixelariumJpg : public IPixelariumImage
|
||||
|
||||
// IPixelariumImage member implementations
|
||||
public:
|
||||
std::optional<std::unique_ptr<cv::Mat>> TryGetImage() override;
|
||||
std::unique_ptr<cv::Mat> TryGetImage() override;
|
||||
|
||||
std::optional<std::unique_ptr<cv::Mat>> TryGetImage(const IImageQuery&) override
|
||||
std::unique_ptr<cv::Mat> TryGetImage(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with jpg.");
|
||||
}
|
||||
|
||||
std::string Name() const noexcept override
|
||||
std::vector<std::unique_ptr<cv::Mat>> TryGetImages(const IImageQuery&) override
|
||||
{
|
||||
if (!this->uri_.empty())
|
||||
{
|
||||
return this->uri_.filename().string();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::filesystem::path Uri() const noexcept override
|
||||
{
|
||||
return this->uri_.string();
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with jpg.");
|
||||
}
|
||||
|
||||
bool Empty() const noexcept override { return this->is_empty_; }
|
||||
|
||||
@@ -16,7 +16,7 @@ pixelarium::imaging::PixelariumPng::PixelariumPng(const std::string& uri)
|
||||
this->uri_ = std::filesystem::path(uri);
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<cv::Mat>> pixelarium::imaging::PixelariumPng::TryGetImage()
|
||||
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumPng::TryGetImage()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -14,27 +14,18 @@ class PixelariumPng : public IPixelariumImage
|
||||
|
||||
// IPixelariumImage member implementations
|
||||
public:
|
||||
std::optional<std::unique_ptr<cv::Mat>> TryGetImage() override;
|
||||
std::unique_ptr<cv::Mat> TryGetImage() override;
|
||||
|
||||
std::optional<std::unique_ptr<cv::Mat>> TryGetImage(const IImageQuery&) override
|
||||
std::unique_ptr<cv::Mat> TryGetImage(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with png.");
|
||||
}
|
||||
|
||||
std::string Name() const noexcept override
|
||||
std::vector<std::unique_ptr<cv::Mat>> TryGetImages(const IImageQuery&) override
|
||||
{
|
||||
if (!this->uri_.empty())
|
||||
{
|
||||
return this->uri_.filename().string();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::filesystem::path Uri() const noexcept override
|
||||
{
|
||||
return this->uri_.string();
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with png.");
|
||||
}
|
||||
|
||||
bool Empty() const noexcept override { return this->is_empty_; }
|
||||
|
||||
Reference in New Issue
Block a user