From 6ea7e774479ebfef6b2dd749f26797e7ff015c6b Mon Sep 17 00:00:00 2001 From: WilliamLiuACPC Date: Fri, 6 May 2022 11:13:56 -0700 Subject: [PATCH] finishing part usable --- src/finish.cpp | 48 ++++++++++++++++++++++++++++++++++++++-- src/hdrplus_pipeline.cpp | 25 ++++++++++++++++++++- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/finish.cpp b/src/finish.cpp index aae7c9a..5d73d70 100644 --- a/src/finish.cpp +++ b/src/finish.cpp @@ -495,19 +495,62 @@ namespace hdrplus return sharpImage; } + void copy_mat_16U_3(u_int16_t* ptr_A, cv::Mat B){ + // u_int16_t* ptr_A = (u_int16_t*)A.data; + u_int16_t* ptr_B = (u_int16_t*)B.data; + int H = B.rows; + int W = B.cols; + int end = H*W; + for(int i=0;i dvals; + for(int c = 0; c < mergedImg.cols; c++) { + dvals.push_back(*(ptr+r*mergedImg.cols+c)); + } + cv::Mat mline(dvals, true); + cv::transpose(mline, mline); + m.push_back(mline); + } + int ch = CV_MAT_CN(opencv_type); + + m = m.reshape(ch); + m.convertTo(m, opencv_type); + + return m; + + } + void finish::process(std::string burstPath, cv::Mat mergedBayer,int refIdx){ // copy mergedBayer to rawReference std::cout<<"finish pipeline start ..."<refIdx = refIdx; this->burstPath = burstPath; - this->mergedBayer = mergedBayer;//loadFromCSV(mergedBayerPath, CV_16UC1); + this->mergedBayer = loadFromCSV("merged_haohua.csv", CV_16UC1);// processMergedMat(mergedBayer,CV_16UC1);//loadFromCSV(mergedBayerPath, CV_16UC1); load_rawPathList(burstPath); // read in ref img bayer_image* ref = new bayer_image(rawPathList[refIdx]); cv::Mat processedRefImage = postprocess(ref->libraw_processor,params.rawpyArgs); + std::cout<<"size ref: "<libraw_processor->imgdata.rawdata.raw_image,this->mergedBayer); + // mergedImg->libraw_processor->imgdata.rawdata.raw_image = (uint16_t*)mergedBayer.data; + copy_mat_16U_3(mergedImg->libraw_processor->imgdata.rawdata.raw_image,this->mergedBayer); cv::Mat processedMerge = postprocess(mergedImg->libraw_processor,params.rawpyArgs); // write merged image diff --git a/src/hdrplus_pipeline.cpp b/src/hdrplus_pipeline.cpp index c2c0f68..e064487 100644 --- a/src/hdrplus_pipeline.cpp +++ b/src/hdrplus_pipeline.cpp @@ -8,10 +8,18 @@ #include "hdrplus/align.h" #include "hdrplus/merge.h" #include "hdrplus/finish.h" +#include namespace hdrplus { - +void writeCSV(std::string filename, cv::Mat m) +{ + std::ofstream myfile; + myfile.open(filename.c_str()); + myfile<< cv::format(m, cv::Formatter::FMT_CSV) << std::endl; + myfile.close(); +} + void hdrplus_pipeline::run_pipeline( \ const std::string& burst_path, \ const std::string& reference_image_path ) @@ -26,6 +34,21 @@ void hdrplus_pipeline::run_pipeline( \ // Run merging merge_module.process( burst_images, alignments ); + cv::Mat mergedBayer = burst_images.merged_bayer_image.clone(); + + std::cout<