Understanding OpenCV3 HDR Synthesis

Asked 2 years ago, Updated 2 years ago, 82 views

I thought OpenCV 3.0's HDR synthesis would be used by iOS, so I coded it by referring to the following site.

http://docs.opencv.org/master/d3/db7/tutorial_hdr_imaging.html

The code is as follows.

 - (UIImage*) testHDR
{
    cv::Matters;
    cv::Mat1ftimes;
    // Fill in the image here
    cv::Mat srcMat1 = [self cvMatFromUIImage: [UIImage imageNamed:@"HDR1.JPG"]];
    cv::Mat srcMat2 = [self cvMatFromUIImage: [UIImage imageNamed:@"HDR2.JPG"]];
    cv::Mat srcMat3 = [self cvMatFromUIImage: [UIImage imageNamed:@"HDR3.JPG"]];
    images.push_back(srcMat1);
    images.push_back(srcMat2);
    images.push_back(srcMat3);
    // exposure time setting
    times.push_back(1/40);
    times.push_back(1/60);
    times.push_back(1/100);

    cv::Mat response;
    cv::Ptr<cv::CalibrateDevec>calibrate=cv::createCalibrateDevec();
    calibrate ->process(images, response, times);

    cv::Mathdr;
    cv::Ptr<cv::MergeDevec>merge_debevec=cv::createMergeDevec();
    merge_devec->process(images, hdr, times, response);

    cv::Matldr;
    cv::Ptr<cv::TonemapDurand>tonemap=cv::createTonemapDurand();
    tonemap ->process(hdr,ldr);

    cv::Mat fusion;
    cv::Ptr<cv::MergeMertens>merge_mertens=cv::createMergeMertens();
    merge_mertens->process(images, fusion);

    return [self UIImageFromCVMat:hdr];
}

calibrate->process(images, response, times);
It falls off with .I think it's not a good idea to set images and exposure time values for images and times, but I'm having trouble because I don't have a source code to refer to.

Please give me some advice.

Additional
An error similar to the following appears:

OpenCV Error: Assertion failed(images.size()==times.total()) in process, file/Volumes/Linux/builds/precommit_ios/opencv/modules/photo/src/calibrate.cpp, line 70
libc++abi.dylib:terminating with uncaught exception of type cv::Exception: /Volumes/Linux/builds/precommit_ios/opencv/modules/photo/src/calibrate.cpp:70:error:(-215) images.size()==times.procession

ios objective-c opencv

2022-09-30 17:56

1 Answers

The code on the reference site says times.push_back(int/float), and the code presented seems to be times.push_back(int/int).

2015-07-27 Additional
In addition, the types of variables in images and times are std::vector on the reference site, and the types of elements in that vector are cv::Mat and float.
This may be the reason why the assert in OpenCV is stuck.


2022-09-30 17:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.