1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <opencv2/photo.hpp> #include "opencv2/imgcodecs.hpp" #include <opencv2/highgui.hpp> #include <opencv2/xphoto.hpp> #include <vector> #include <iostream> #include <fstream> using namespace cv; using namespace std; void loadExposureSeq(String path, vector<Mat>& images, vector<float>& times) { path = path + std::string("/"); ifstream list_file((path + "list.txt").c_str()); string name; float val; while (list_file >> name >> val) { Mat img = imread(path + name); images.push_back(img); times.push_back(1 / val); } list_file.close(); } int main(int, char**argv) { vector<Mat> images; vector<float> times; string strPath = "HDR"; loadExposureSeq(strPath, images, times); Mat response; Ptr<CalibrateDebevec> calibrate = createCalibrateDebevec(); calibrate->process(images, response, times); Mat hdr; Ptr<MergeDebevec> merge_debevec = createMergeDebevec(); merge_debevec->process(images, hdr, times, response); Mat ldr; Ptr<xphoto::TonemapDurand> tonemap = xphoto::createTonemapDurand(2.2f); tonemap->process(hdr, ldr); Mat fusion; Ptr<MergeMertens> merge_mertens = createMergeMertens(); merge_mertens->process(images, fusion); cv::imshow("hdr", hdr); imwrite("fusion.png", fusion * 255); imwrite("ldr.png", ldr * 255); imwrite("hdr.hdr", hdr); cv::waitKey(0); return 0; }
|