HDR opencv 代码

#include "opencv2/photo.hpp"

#include "opencv2/imgcodecs.hpp"

#include "opencv2/highgui.hpp"

#include

#include

#include

using namespace cv;

using namespace std;

void loadExposureSeq(String, vector&, vector&);

int main(int argc, char**argv)

{

CommandLineParser parser( argc, argv, "{@input | | Input directory that contains images and exposure times. }" );

vector images;

vector times;

loadExposureSeq(parser.get( "@input" ), images, times);

Mat response;

Ptr calibrate = createCalibrateDebevec();

calibrate->process(images, response, times);

Mat hdr;

Ptr merge_debevec = createMergeDebevec();

merge_debevec->process(images, hdr, times, response);

Mat ldr;

Ptr tonemap = createTonemap(2.2f);

tonemap->process(hdr, ldr);

Mat fusion;

Ptr merge_mertens = createMergeMertens();

merge_mertens->process(images, fusion);

imwrite("fusion.png", fusion * 255);

imwrite("ldr.png", ldr * 255);

imwrite("hdr.hdr", hdr);

return 0;

}

void loadExposureSeq(String path, vector& images, vector& times)

{

path = path + "/";

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();

}

你可能感兴趣的:(C++,视觉算法代码库)