#pragma once #include // all opencv header #include #include #include #include #include #include #include #include #include namespace hdrplus { uint16_t uGammaCompress_1pix(float x, float threshold,float gainMin,float gainMax,float exponent); uint16_t uGammaDecompress_1pix(float x, float threshold,float gainMin,float gainMax,float exponent); cv::Mat uGammaCompress_(cv::Mat m,float threshold,float gainMin,float gainMax,float exponent); cv::Mat uGammaDecompress_(cv::Mat m,float threshold,float gainMin,float gainMax,float exponent); cv::Mat gammasRGB(cv::Mat img, bool mode); class finish { public: cv::Mat mergedBayer; // merged image from Merge Module std::string burstPath; // path to burst images std::vector rawPathList; // a list or array of the path to all burst imgs under burst Path int refIdx; // index of the reference img Parameters params; cv::Mat rawReference; // LibRaw libraw_processor_finish; bayer_image* refBayer; std::string mergedImgPath; finish() = default; // please use this initialization after merging part finish finish(std::string burstPath, cv::Mat mergedBayer,int refIdx){ this->refIdx = refIdx; this->burstPath = burstPath; this->mergedBayer = mergedBayer; } // for local testing only finish(std::string burstPath, std::string mergedBayerPath,int refIdx){ this->refIdx = refIdx; this->burstPath = burstPath; this->mergedBayer = loadFromCSV(mergedBayerPath, CV_16UC1);// load_rawPathList(burstPath); refBayer= new bayer_image(this->rawPathList[refIdx]); this->rawReference = refBayer->raw_image;//;grayscale_image // initialize parameters in libraw_processor_finish setLibRawParams(); showParams(); std::cout<<"Finish init() finished!"<& libraw_ptr, cv::Mat B); // postprocess // cv::Mat postprocess(std::shared_ptr& libraw_ptr); void showImg(cv::Mat img) { int ch = CV_MAT_CN(CV_8UC1); // cv::Mat tmp(4208,3120,CV_16UC1); cv::Mat tmp(img); // u_int16_t* ptr_tmp = (u_int16_t*)tmp.data; // u_int16_t* ptr_img = (u_int16_t*)img.data; // // col major to row major // for(int r = 0; r < tmp.rows; r++) { // for(int c = 0; c < tmp.cols; c++) { // *(ptr_tmp+r*tmp.cols+c) = *(ptr_img+c*tmp.rows+r)/2048.0*255.0; // } // } // std::cout<<"height="<mergedBayer.size()<rawPathList){ std::cout< dvals; std::stringstream ss(line); std::string val; // int count=0; while (getline(ss, val, ',')) { dvals.push_back(stod(val));//*255.0/2048.0 // count++; } // std::cout<d_name; // current filepath that ptr points to if (ptr->d_type != 8 && ptr->d_type != 4) { // not normal file or dir return; } // only need normal files if (ptr->d_type == 8) { if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) { if (strstr(ptr->d_name, ".dng")) { rawPathList.emplace_back(sub_file); } } } } // close root dir closedir(pDir); } void setLibRawParams(){ refBayer->libraw_processor->imgdata.params.user_qual = params.rawpyArgs.demosaic_algorithm; refBayer->libraw_processor->imgdata.params.half_size = params.rawpyArgs.half_size; refBayer->libraw_processor->imgdata.params.use_camera_wb = params.rawpyArgs.use_camera_wb; refBayer->libraw_processor->imgdata.params.use_auto_wb = params.rawpyArgs.use_auto_wb; refBayer->libraw_processor->imgdata.params.no_auto_bright = params.rawpyArgs.no_auto_bright; refBayer->libraw_processor->imgdata.params.output_color = params.rawpyArgs.output_color; refBayer->libraw_processor->imgdata.params.gamm[0] = params.rawpyArgs.gamma[0]; refBayer->libraw_processor->imgdata.params.gamm[1] = params.rawpyArgs.gamma[1]; refBayer->libraw_processor->imgdata.params.output_bps = params.rawpyArgs.output_bps; // libraw_processor_finish.imgdata.params.user_qual = params.rawpyArgs.demosaic_algorithm; // libraw_processor_finish.imgdata.params.half_size = params.rawpyArgs.half_size; // libraw_processor_finish.imgdata.params.use_camera_wb = params.rawpyArgs.use_camera_wb; // libraw_processor_finish.imgdata.params.use_auto_wb = params.rawpyArgs.use_auto_wb; // libraw_processor_finish.imgdata.params.no_auto_bright = params.rawpyArgs.no_auto_bright; // libraw_processor_finish.imgdata.params.output_color = params.rawpyArgs.output_color; // libraw_processor_finish.imgdata.params.gamm[0] = params.rawpyArgs.gamma[0]; // libraw_processor_finish.imgdata.params.gamm[1] = params.rawpyArgs.gamma[1]; // libraw_processor_finish.imgdata.params.output_bps = params.rawpyArgs.output_bps; } }; } // namespace hdrplus