Unhandled exception while creating HDR image in OpenCV

320 views Asked by At

Using the code below, I am trying to create a HDR image using 3 images shot with different exposure values. The IDE used is Visual Studio 2013.

#include <opencv2/photo.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int, char** argv)
{
vector<Mat> images;
vector<float> times;

// Load images and exposures...
Mat img1 = imread("C:\\Users\\Prashant\\Documents\\Visual Studio 2013\\Projects\\OpenCVProject3\\mem0.png");
if (img1.empty())
{
    cout << "Error! Input image cannot be read...\n";
    return -1;
}
Mat img2 = imread("C:\\Users\\Prashant\\Documents\\Visual Studio 2013\\Projects\\OpenCVProject3\\mem1.png");
Mat img3 = imread("C:\\Users\\Prashant\\Documents\\Visual Studio 2013\\Projects\\OpenCVProject3\\mem2.png");
images.push_back(img1);
images.push_back(img2);
images.push_back(img3);
times.push_back((float)1 / 66);
times.push_back((float)1 / 32);
times.push_back((float)1 / 12);

// Estimate camera response...
Mat response;
Ptr<CalibrateDebevec> calibrate = createCalibrateDebevec();
calibrate->process(images, response, times);

// Show the estimated camera response function...
cout << response;

// Create and write the HDR image...
Mat hdr;
Ptr<MergeDebevec> merge_debevec = createMergeDebevec();
merge_debevec->process(images, hdr, times, response);
imwrite("hdr.hdr", hdr);

cout << "\nDone. Press any key to exit...\n";
waitKey(); // Wait for key press
return 0;
}

On running the code, it shows me the following error:

Unhandled exception at 0x00007FFFC90FA1C8 in OpenCVProject3.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000B170C3E630.

What is the exact problem?

0

There are 0 answers