diff --git a/bin/demo.cpp b/bin/demo.cpp index 8d2413d..5a610cd 100644 --- a/bin/demo.cpp +++ b/bin/demo.cpp @@ -2,6 +2,12 @@ int main( int argc, char** argv ) { + if ( argc != 3 ) + { + printf("Usage: ./demo BURST_FOLDER_PATH(no / at end) REFERENCE_IMAGE_PATH\n"); + exit(1); + } + hdrplus::hdrplus_pipeline pipeline; - pipeline.run_pipeline(); + pipeline.run_pipeline( argv[1], argv[ 2 ]); } \ No newline at end of file diff --git a/include/hdrplus/align.h b/include/hdrplus/align.h index 72b9b9f..587baa1 100644 --- a/include/hdrplus/align.h +++ b/include/hdrplus/align.h @@ -12,7 +12,17 @@ class align { public: align() = default; - void process( hdrplus::burst& burst_images, \ + ~align() = default; + + /** + * @brief Run alignment on burst of images + * + * @param burst_images collection of burst images + * @param aligements alignment in pixel value pair. + * Outer most vector is per alternative image. + * Inner most two vector is for horizontle & verticle tiles + */ + void process( const hdrplus::burst& burst_images, \ std::vector>>>& aligements ); const std::vector inv_scale_factors = { 1, 2, 2, 4 }; diff --git a/include/hdrplus/burst.h b/include/hdrplus/burst.h index 0b9fd09..4dd7eea 100644 --- a/include/hdrplus/burst.h +++ b/include/hdrplus/burst.h @@ -19,7 +19,11 @@ class burst int reference_image_idx; std::vector bayer_image_paths; + // Source bayer images & grayscale unpadded image std::vector bayer_images; + + // Image padded to tile size + // Use for alignment, merging, and finishing std::vector grayscale_images_pad; }; diff --git a/include/hdrplus/hdrplus_pipeline.h b/include/hdrplus/hdrplus_pipeline.h index 0e992e3..9df420a 100644 --- a/include/hdrplus/hdrplus_pipeline.h +++ b/include/hdrplus/hdrplus_pipeline.h @@ -1,5 +1,6 @@ #pragma once +#include #include // all opencv header #include "hdrplus/burst.h" #include "hdrplus/align.h" @@ -17,8 +18,9 @@ class hdrplus_pipeline hdrplus::finish finish_module; public: - void run_pipeline(); + void run_pipeline( const std::string& burst_path, const std::string& reference_image_path ); hdrplus_pipeline() = default; + ~hdrplus_pipeline() = default; }; } // namespace hdrplus diff --git a/include/hdrplus/merge.h b/include/hdrplus/merge.h index 0204c53..cd7bcec 100644 --- a/include/hdrplus/merge.h +++ b/include/hdrplus/merge.h @@ -1,6 +1,8 @@ #pragma once +#include #include // all opencv header +#include "hdrplus/burst.h" namespace hdrplus { @@ -9,6 +11,18 @@ class merge { public: merge() = default; + ~merge() = default; + + /** + * @brief Run alignment on burst of images + * + * @param burst_images collection of burst images + * @param aligements alignment in pixel value pair. + * Outer most vector is per alternative image. + * Inner most two vector is for horizontle & verticle tiles + */ + void process( const hdrplus::burst& burst_images, \ + std::vector>>>& aligements ); }; } // namespace hdrplus diff --git a/src/align.cpp b/src/align.cpp index 26a81fa..124edde 100644 --- a/src/align.cpp +++ b/src/align.cpp @@ -1,7 +1,52 @@ +#include #include // all opencv header #include "hdrplus/align.h" +#include "hdrplus/burst.h" +#include "hdrplus/utility.h" namespace hdrplus { - + +void align::process( const hdrplus::burst& burst_images, \ + std::vector>>>& aligements ) +{ + /* + // Build image pyramid + std::vector> grayscale_images_pyramid; + grayscale_images_pyramid.resize( burst_images.grayscale_images_pad.size() ); + for ( int img_idx = 0; img_idx < burst_images.grayscale_images_pad.size(); ++img_idx ) + { + grayscale_images_pyramid[ img_idx ].resize( inv_scale_factors.size() ); + + // pyramid image are laied out from coarse to fine + // level 0 is the original grayscale image + grayscale_images_pyramid[ img_idx ][ inv_scale_factors.size() - 1 ] = burst_images.grayscale_images_pad[ img_idx]; + + // downsample and gaussian blur + for ( int i = 1; i < inv_scale_factors.size(); ++i ) + { + int inv_scale_factor_i = inv_scale_factors[ i ]; + cv::Mat blurred_image = \ + hdrplus::gaussian_blur( grayscale_images_pyramid[ img_idx ][ i - 1 ], inv_scale_factor_i * 0.5 ); + + // Get around with template + cv::Mat downsampled_blurred_image; + if ( inv_scale_factor_i == 2 ) + { + hdrplus::downsample_nearest_neighbour( blurred_image ); + } + else if ( inv_scale_factor_i == 4 ) + { + hdrplus::downsample_nearest_neighbour( blurred_image ); + } + + grayscale_images_pyramid[ img_idx ][ inv_scale_factors.size() - i - 1 ] = downsampled_blurred_image; + } + } + + cv::GaussianBlur( src_image, dst_image, cv::Size(0, 0), sigma ); + + */ +} + } // namespace hdrplus diff --git a/src/hdrplus_pipeline.cpp b/src/hdrplus_pipeline.cpp index 60f0e83..fc53dff 100644 --- a/src/hdrplus_pipeline.cpp +++ b/src/hdrplus_pipeline.cpp @@ -1,13 +1,32 @@ #include +#include +#include +#include // std::pair #include // all opencv header #include "hdrplus/hdrplus_pipeline.h" +#include "hdrplus/burst.h" +#include "hdrplus/align.h" +#include "hdrplus/merge.h" +#include "hdrplus/finish.h" namespace hdrplus { -void hdrplus_pipeline::run_pipeline() +void hdrplus_pipeline::run_pipeline( \ + const std::string& burst_path, \ + const std::string& reference_image_path ) { - printf("Run pipeline\n"); + // Create burst of images + burst burst_images( burst_path, reference_image_path ); + std::vector>>> alignments; + + // Run align + align_module.process( burst_images, alignments ); + + // Run merging + merge_module.process( burst_images, alignments ); + + // Run finishing } } // namespace hdrplus diff --git a/src/merge.cpp b/src/merge.cpp index c1195ef..aaa46db 100644 --- a/src/merge.cpp +++ b/src/merge.cpp @@ -1,7 +1,15 @@ #include // all opencv header +#include #include "hdrplus/merge.h" +#include "hdrplus/burst.h" namespace hdrplus { + +void merge::process( const hdrplus::burst& burst_images, \ + std::vector>>>& aligements ) +{ +} + } // namespace hdrplus