Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

hdr_imaging in opencv3 with VS2015. Assertion failed (!images.empty())

I am trying to run the HDR processing code distributed with opencv3.2.0. The process fails with the following error

OpenCV Error: Assertion failed (!images.empty()) in cv::checkImageDimensions, file C:\build\master_winpack-build-win64-vc14\opencv\modules\photo\src\hdr_common.cpp, line 51

I have read previous answers related to this error, but I am not able to get past this problem. images is a vector of png images. I have verified that the vector is not empty. I have tried using absolute and relative paths for command line input. I have also tried sending an empty vector of images. The error is the same. Here is my code with debug statements followed by the output. Thanks in advance for any help.

include <opencv2 photo.hpp="">

include "opencv2/imgcodecs.hpp"

include <opencv2 highgui.hpp="">

include <vector>

include <iostream>

include <fstream>

using namespace cv; using namespace std; void loadExposureSeq(String, vector<mat>&, vector<float>&); int main(int, char**argv) { vector<mat> images; vector<float> times; loadExposureSeq(argv[1], images, times);

cout << "images.isempty=" << images.empty() << " size=" << images.size() << endl;
Mat response;
cout << "Calling createCalibrateDebevec" << endl;
Ptr<CalibrateDebevec> calibrate = createCalibrateDebevec();
cout << "Calling calibrate.process" << endl;
calibrate->process(images, response, times);
cout << "Back from calibrate.process" << endl;
Mat hdr;
cout << "Calling createMergeDebevec" << endl;
Ptr<MergeDebevec> merge_debevec = createMergeDebevec();
merge_debevec->process(images, hdr, times, response);
Mat ldr;
cout << "Calling createTonemapDurand" << endl;
Ptr<TonemapDurand> tonemap = createTonemapDurand(2.2f);
tonemap->process(hdr, ldr);
Mat fusion;
cout << "Calling createMergeMertens" << endl;
Ptr<MergeMertens> 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<mat>& images, vector<float>& times) {

path = path + std::string("/"); ifstream list_file((path + "list.txt").c_str()); string name; float val; cout << ((path + "list.txt").c_str()) << endl; while (list_file >> name >> val) { cout << "name=" << name << " val=" << val << " " << (path + name) << endl; Mat img = imread(path + name); cout << "img.size=" << img.dims<< endl; images.push_back(img);
times.push_back(1 / val); }

for (int i = 0; i < images.size(); i++) {
    int width = images[i].cols;
    int height = images[i].rows;
    int type = images[i].type();
    float tt = times[i];

    cout << "width, height, type, time=" << width << " " << height << " " << type << " " << tt << endl;
}

list_file.close();

}

$ ./CannyStill1.exe c://SSAD//forHDRTest

c://SSAD//forHDRTest/list.txt name=9_1_HDR-227-3.png val=227 c://SSAD//forHDRTest/9_1_HDR-227-3.png img.size=2 name=9_1_HDR-454-0.png val=454 c://SSAD//forHDRTest/9_1_HDR-454-0.png img.size=2 name=9_1_HDR-681-1.png val=681 c://SSAD//forHDRTest/9_1_HDR-681-1.png img.size=2 width, height, type, time=1288 964 16 0.00440529 width, height, type, time=1288 964 16 0.00220264 width, height, type, time=1288 964 16 0.00146843 images.isempty=0 size=3 Calling createCalibrateDebevec Calling calibrate.process OpenCV Error: Assertion failed (!images.empty()) in cv::checkImageDimensions, file C:\build\master_winpack-build-win64-vc14\opencv\modules\photo\src\hdr_common.cpp, line 51

$ ./CannyStill1.exe .

./list.txt name=9_1_HDR-227-3.png val=227 ./9_1_HDR-227-3.png img.size=2 name=9_1_HDR-454-0.png val=454 ./9_1_HDR-454-0.png img.size=2 name=9_1_HDR-681-1.png val=681 ./9_1_HDR-681-1.png img.size=2 width, height, type, time=1288 964 16 0.00440529 width, height, type, time=1288 964 16 0.00220264 width, height, type, time=1288 964 16 0.00146843 images.isempty=0 size=3 Calling createCalibrateDebevec Calling calibrate.process OpenCV Error: Assertion failed (!images.empty()) in cv::checkImageDimensions, file C:\build\master_winpack-build-win64-vc14\opencv\modules\photo\src\hdr_common.cpp, line 51

hdr_imaging in opencv3 with VS2015. Assertion failed (!images.empty())

I am trying to run the HDR processing code distributed with opencv3.2.0. The process fails with the following error

OpenCV Error: Assertion failed (!images.empty()) in cv::checkImageDimensions, file C:\build\master_winpack-build-win64-vc14\opencv\modules\photo\src\hdr_common.cpp, line 51

I have read previous answers related to this error, but I am not able to get past this problem. images is a vector of png images. I have verified that the vector is not empty. I have tried using absolute and relative paths for command line input. I have also tried sending an empty vector of images. The error is the same. Here is my code with debug statements followed by the output. Thanks in advance for any help.

include <opencv2 photo.hpp="">

include "opencv2/imgcodecs.hpp"

include <opencv2 highgui.hpp="">

include <vector>

include <iostream>

include <fstream>

#include <opencv2/photo.hpp>
#include "opencv2/imgcodecs.hpp"
#include <opencv2/highgui.hpp>


#include <vector>
#include <iostream>
#include <fstream>
using namespace cv;
using namespace std;
void loadExposureSeq(String, vector<mat>&, vector<Mat>&, vector<float>&);
int main(int, char**argv)
{
 vector<mat> 
vector<Mat> images;
 vector<float> times;
 loadExposureSeq(argv[1], images, times);

times);
cout << "images.isempty=" << images.empty() << " size=" << images.size() << endl;
Mat response;
cout << "Calling createCalibrateDebevec" << endl;
Ptr<CalibrateDebevec> calibrate = createCalibrateDebevec();
cout << "Calling calibrate.process" << endl;
calibrate->process(images, response, times);
cout << "Back from calibrate.process" << endl;
Mat hdr;
cout << "Calling createMergeDebevec" << endl;
Ptr<MergeDebevec> merge_debevec = createMergeDebevec();
merge_debevec->process(images, hdr, times, response);
Mat ldr;
cout << "Calling createTonemapDurand" << endl;
Ptr<TonemapDurand> tonemap = createTonemapDurand(2.2f);
tonemap->process(hdr, ldr);
Mat fusion;
cout << "Calling createMergeMertens" << endl;
Ptr<MergeMertens> 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<mat>& vector<Mat>& images, vector<float>& times) {

{ path = path + std::string("/"); ifstream list_file((path + "list.txt").c_str()); string name; float val; cout << ((path + "list.txt").c_str()) << endl; while (list_file >> name >> val) { cout << "name=" << name << " val=" << val << " " << (path + name) << endl; Mat img = imread(path + name); cout << "img.size=" << img.dims<< endl; images.push_back(img);
times.push_back(1 / val); }

}
for (int i = 0; i < images.size(); i++) {
int width = images[i].cols;
int height = images[i].rows;
int type = images[i].type();
float tt = times[i];
cout << "width, height, type, time=" << width << " " << height << " " << type << " " << tt << endl;
}
list_file.close();
 }

}

$ ./CannyStill1.exe c://SSAD//forHDRTest

c://SSAD//forHDRTest/list.txt
name=9_1_HDR-227-3.png val=227 c://SSAD//forHDRTest/9_1_HDR-227-3.png
img.size=2
name=9_1_HDR-454-0.png val=454 c://SSAD//forHDRTest/9_1_HDR-454-0.png
img.size=2
name=9_1_HDR-681-1.png val=681 c://SSAD//forHDRTest/9_1_HDR-681-1.png
img.size=2
width, height, type, time=1288 964 16 0.00440529
width, height, type, time=1288 964 16 0.00220264
width, height, type, time=1288 964 16 0.00146843
images.isempty=0 size=3
Calling createCalibrateDebevec
Calling calibrate.process
OpenCV Error: Assertion failed (!images.empty()) in cv::checkImageDimensions, file C:\build\master_winpack-build-win64-vc14\opencv\modules\photo\src\hdr_common.cpp, line 51

51

$ ./CannyStill1.exe .

./list.txt

*./list.txt
name=9_1_HDR-227-3.png val=227 ./9_1_HDR-227-3.png
img.size=2
name=9_1_HDR-454-0.png val=454 ./9_1_HDR-454-0.png
img.size=2
name=9_1_HDR-681-1.png val=681 ./9_1_HDR-681-1.png
img.size=2
width, height, type, time=1288 964 16 0.00440529
width, height, type, time=1288 964 16 0.00220264
width, height, type, time=1288 964 16 0.00146843
images.isempty=0 size=3
Calling createCalibrateDebevec
Calling calibrate.process
OpenCV Error: Assertion failed (!images.empty()) in cv::checkImageDimensions, file C:\build\master_winpack-build-win64-vc14\opencv\modules\photo\src\hdr_common.cpp, line 51

51*