samples/cpp/stitching_detailed.cpp minor bug (Patch #2603)


Added by John Maushammer over 12 years ago. Updated over 12 years ago.


Status:Cancelled Start date:2012-12-05
Priority:Low Due date:
Assignee:Alexey Spizhevoy % Done:

0%

Category:samples
Target version:2.4.4 Estimated time:0.10 hour
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

The demo code performs an exposure compensation before running the seam finder, but, due to the order of things, the results of the exposure compensation are never used.

samples/cpp/stitching_detailed.cpp, Lines 595-602:

    vector<Mat> images_warped_f(num_images);
    for (int i = 0; i < num_images; ++i)
        images_warped[i].convertTo(images_warped_f[i], CV_32F);

    LOGLN("Warping images, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");

    Ptr<ExposureCompensator> compensator = ExposureCompensator::createDefault(expos_comp_type);
    compensator->feed(corners, images_warped, masks_warped);

Then line 637 uses images_warped_f:

    seam_finder->find(images_warped_f, corners, masks_warped);

... images_warped is never used and is cleared on line 641.


Suggested fix:

Reorder lines 595-602:

    LOGLN("Warping images, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");

    Ptr<ExposureCompensator> compensator = ExposureCompensator::createDefault(expos_comp_type);
    compensator->feed(corners, images_warped, masks_warped);

    vector<Mat> images_warped_f(num_images);
    for (int i = 0; i < num_images; ++i)
        images_warped[i].convertTo(images_warped_f[i], CV_32F);

This demo code is awesome & really helpful - thanks!!


Associated revisions

Revision 8ab22474
Added by Roman Donchenko almost 11 years ago

Merge pull request #2603 from maksqwe:unused_fix_2.4

History

Updated by Anna Kogan over 12 years ago

Hello John,

Thank you for reporting this problem! If you could fix the issue on your side, a patch or pull request there: http://opencv.org/opencv-pull-requests-test-results.html would be highly appreciated!

Updated by Alexey Spizhevoy over 12 years ago

Hi John,

The line:

compensator->feed(corners, images_warped, masks_warped);
doesn't change 'images_warped' vector. What it actually does is train exposure models for further compensation at line 718 (just before blending images):
compensator->apply(img_idx, corners[img_idx], img_warped, mask_warped);

I'm glad the sample is helpful, thanks!

  • Status changed from Open to Cancelled

Also available in: Atom PDF