-1

I'm doing a tutorial on creating HDR images and when I call the process function of the calDebevec or mergeDebevec I keep getting this exception:

Exception

I tried using following library versions: 2.4.13.2, 3.1 and 3.2 with no success.

Code:

using namespace std;
using namespace cv;

int main() {
vector<Mat> images;
vector<float> exposures;

exposures.push_back(1 / 180);
exposures.push_back(1 / 750);
exposures.push_back(1 / 45);

String path = "/path/to/pictures";

Mat buffer = imread(path + "grandcanal_mean.jpg"); 
images.push_back(buffer);
buffer = imread(path + "grandcanal_under.jpg");
images.push_back(buffer);
buffer = imread(path + "grandcanal_over.jpg");
images.push_back(buffer);

//Ptr<MergeDebevec> mergeDebevec = createMergeDebevec();

Mat l;

Ptr<CalibrateDebevec> calDebevec = createCalibrateDebevec();
calDebevec->process(images, l, exposures);

//mergeDebevec->process(images, l, exposures);
return 1;
}

The link to the tutorial: http://docs.opencv.org/3.0-rc1/d3/db7/tutorial_hdr_imaging.html

phuclv
  • 37,963
  • 15
  • 156
  • 475
Rok
  • 476
  • 1
  • 5
  • 12
  • Possible duplicate of [Division result is always zero](http://stackoverflow.com/questions/2345902/division-result-is-always-zero) – phuclv May 18 '17 at 15:48

2 Answers2

0

You have an integer division: 1 / 45 is 0.0f. Notice that tutorial manages to dodge the bullet by supplying float as divider.

user7860670
  • 35,849
  • 4
  • 58
  • 84
  • I tried using float numbers by dividing the exposure times and that didn't change it. So instead of using division i used the following floats: 0.0055f 0.0013f and 0.02f – Rok May 17 '17 at 07:34
  • @Rok because you have used the wrong way. You must use `1.0f/45` or `1/45.0f` or `1.0f/45.0f` [Division result is always zero](http://stackoverflow.com/q/2345902/995714) – phuclv May 17 '17 at 11:12
0

I resolved the issue by using the debug dll instead of the release version.

Rok
  • 476
  • 1
  • 5
  • 12