gabrieleilertsen / hdrcnn

HDR image reconstruction from a single exposure using deep CNNs
https://computergraphics.on.liu.se/hdrcnn/
BSD 3-Clause "New" or "Revised" License
502 stars 101 forks source link

failed compile the virtual camera application #11

Closed PK15946 closed 5 years ago

PK15946 commented 6 years ago

Hi,

Thanks for your impressive job! It works as good as shown in the paper wih my own images.

But now I want to train the net and suffering errors when executing "gcc -Wall -lm -lstdc++ -lopencv_core -lopencv_imgproc -lopencv_imgcodecs virtualcamera.cpp -o virtualcamera"

The error shown is that"virtualcamera.cpp:314:57: error: no match for ‘operator+’ (operand types are ‘cv::Mat’ and ‘cv::Vec<double, 4>’) host_roi = host_roi.mul(1.0 / (host_roi + sigmoid_a*Scalar(1,1,1)));


"
Do you have any idea, or could you please tell me the versions of gcc and opencv you are using? Thanks in advance!
musicrainie commented 6 years ago

Try "gcc virtualcamera.cpp -o virtualcamera -lm -lstdc++ -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -std=c++11". My setting: Ubuntu16.04, gcc5.4, OpenCv3.4.1

PK15946 commented 6 years ago

THANK YOU! @musicrainie , it works like a charm!!!!

cherryMo commented 5 years ago

@PK15946 Hi, It works bad with my own images. https://github.com/gabrieleilertsen/hdrcnn/issues/12 this is one of my own image. can you give me some suggestions?

PK15946 commented 5 years ago

Hi, @musicrainie @gabrieleilertsen I have successfully compiled the virtual camera with the above script. However, the processed images in the 'training_data/jpg' all look blue and white like im_000001_000001 im_000001_000002 im_000001_000003 im_000001_000004

are they right?

gabrieleilertsen commented 5 years ago

No, that is not correct. The output images should be natural conventional images. Is it the same problem with the EXR ground truth images that are saved to disc? If not, the problem must be in the jpg output, and thus with the linked libjpeg library. Can you load and save an jpg as expected using OpenCV?

PK15946 commented 5 years ago

Thanks for you reply. @gabrieleilertsen .

When you say check the EXR ground truth that are saved to disc, do you mean those .bin files that are saved in "training_data/bin"? I read those .bin files use numpy.fromfile and save them to jpg format use scipy.misc.toimage, the results are correct.

Then I try to load and save a jpg using OpenCV using `#include "opencv2/opencv.hpp"

using namespace cv; using namespace std; int main(int argc, char *argv[]) { Mat host_im; host_im = cv::imread("1.jpg", CV_LOAD_IMAGE_COLOR|CV_LOAD_IMAGE_ANYDEPTH); imwrite("45.jpg",host_im); }` ,that result is correct, too.

gabrieleilertsen commented 5 years ago

Yes, I meant the raw binary HDR images. Forgot that those were not stored as EXR.

So, the problem must then be somewhere between generating the HDR output and converting this to an LDR an storing to disc. There are two operations in-between; first, a camera response function is applied, and then the result is converted to 8 bit and stored with a random compression quality. I can't figure out what your problem is, but I would suggest trying to look at those operations. For example, you can try to save the LDR image before applying the camera response function and see if this fixes the problem with the colors (the contrast will be exaggerated though). Or you can test if the problem is in the conversion and 8-bit storage. For example, there is a conversion BGR2RGB. Is this causing the problem (seems from the examples above though, that the problem is more than simply swapped color channels)?

The question is what in your configuration is different. I have not experienced this problem myself. Seems a bit odd that a difference in configuration can generate such different output, and I haven't of anyone else having this problem. What version of OpenCV are you using?

PK15946 commented 5 years ago

Really thanks for your kindly suggestion and guidance. @gabrieleilertsen I guess I do have configuration problem in my computer(though I have no idea what could it be), since I try the code on another one and it works well... Both of that two computer with OpenCV 3.4.1 installed.