diff --git a/include/genimg/common.hh b/include/genimg/common.hh new file mode 100644 index 0000000..7073a3b --- /dev/null +++ b/include/genimg/common.hh @@ -0,0 +1,12 @@ +#ifndef GENETIC_IMAGE_INCLUDE_GENIMG_COMMON_HH_ +#define GENETIC_IMAGE_INCLUDE_GENIMG_COMMON_HH_ + +#include +#include +#include +#include +#include + +std::tuple init_image(const std::string &t_input_file); + +#endif /* GENETIC_IMAGE_INCLUDE_GENIMG_COMMON_HH_ */ diff --git a/src/parseargs.hh b/include/genimg/parseargs.hh similarity index 100% rename from src/parseargs.hh rename to include/genimg/parseargs.hh diff --git a/src/common.cc b/src/common.cc new file mode 100644 index 0000000..89231c3 --- /dev/null +++ b/src/common.cc @@ -0,0 +1,17 @@ +#include "common.hh" +#include + +std::tuple init_image(const std::string &t_input_file) { + cv::Mat input_image = + cv::imread(t_input_file, cv::IMREAD_COLOR); + if (!input_image.data) { + spdlog::critical("Could not open or find image!\n"); + exit(-1); + } + spdlog::info("Image loaded!"); + spdlog::info("Width:\t\t{}", input_image.size().width); + spdlog::info("Height:\t{}", input_image.size().height); + cv::Mat process_image(input_image.size().width, input_image.size().height, + CV_8UC3, cv::Scalar(0, 0, 0)); + return std::make_tuple(std::move(input_image), process_image); +} diff --git a/src/main.cc b/src/main.cc index 5a65942..e75b46f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,8 +1,5 @@ #include "parseargs.hh" -#include -#include -#include -#include +#include "common.hh" int main(int ac, char **av) { const auto [input_file, output_file, video_output, iterations] = @@ -11,14 +8,7 @@ int main(int ac, char **av) { spdlog::info("Output file:\t{}", output_file); spdlog::info("Video output:\t{}", video_output); spdlog::info("Iterations:\t{}", iterations); - cv::Mat image = cv::imread(input_file, cv::IMREAD_COLOR); // Read the file - if (!image.data) { // Check for invalid input - spdlog::critical("Could not open or find image!\n"); - return -1; - } - spdlog::info("Image loaded!"); - spdlog::info("Width:\t{}", image.size().width); - spdlog::info("Height:\t{}", image.size().height); + auto [input_image, process_image] = init_image(input_file); return 0; }