OpenCV Error: Assertion failed (layer_cols - 2 * min_margin > 0) in unknown func tion, file ..\..\..\modules\nonfree\src\surf_gpu.cpp, line 133 (Bug #3022)


Added by Nikolay Rogoshchenkov almost 12 years ago. Updated almost 12 years ago.


Status:Cancelled Start date:2013-05-13
Priority:Normal Due date:
Assignee:Vladislav Vinogradov % Done:

0%

Category:gpu (cuda)
Target version:-
Affected version:2.4.5 (latest release) Operating System:
Difficulty: HW Platform:
Pull request:

Description

I have compiled Opencv 2.4.5 with CUDA support (version 5) under Windows 7 (x64) for Visual Studio 2010 (Win32) without any errors.
And than, tried to run simple stiching code with new libraries and dll:

[...]
    Stitcher stitcher = Stitcher::createDefault( true ); // true for use GPU
    stitcher.setFeaturesMatcher(new cv::detail::BestOf2NearestMatcher(true, 0.25f/*=match_conf*/));
    Stitcher::Status status = stitcher.stitch(imgs, rois, pano);    
    if (status != Stitcher::OK)
    {
        cout << "Can't stitch images, error code = " << status << endl;
        return -1;
    }

and I've got this:

OpenCV Error: Assertion failed (layer_cols - 2 * min_margin > 0) in unknown func
tion, file ..\..\..\modules\nonfree\src\surf_gpu.cpp, line 133

If I compile this code without using GPU
 Stitcher stitcher = Stitcher::createDefault( false );

it works good.


CMakeCache.txt (151.8 kB) Nikolay Rogoshchenkov, 2013-05-14 05:20 am

images.zip (4 MB) Nikolay Rogoshchenkov, 2013-05-14 02:03 pm


History

Updated by Alexey Spizhevoy almost 12 years ago

Could you pelase attach the images that you used.

  • Assignee changed from Alexey Spizhevoy to Vladislav Vinogradov
  • Category changed from stitching to gpu (cuda)

Updated by Vladislav Vinogradov almost 12 years ago

GPU SURF doesn't support small image size. For such images use CPU algorithm.

Stitcher stitcher = Stitcher::createDefault( img.cols > 640 );

Updated by Nikolay Rogoshchenkov almost 12 years ago

Alexey, Vladislav, thank you for your answers!

My input images have size 1280x960 (TIFF).
Please find images in zip enclosed.
corr1.tif, corr2.tif - are input images;
result.tif - resutl image;

PS: May be GPU SURF don't like the small rois size?

Stitcher::Status status = stitcher.stitch(imgs, rois, pano);

it is real smaller than whole image.

Thank you.

Updated by Vladislav Vinogradov almost 12 years ago

Stitcher will pass only ROI of input image to SURF (not full image), so if your rois have small size use CPU version.

Updated by Nikolay Rogoshchenkov almost 12 years ago

Vladislav Vinogradov wrote:

Stitcher will pass only ROI of input image to SURF (not full image), so if your rois have small size use CPU version.

What size of ROI will support by SURF module?

This is how I calculate ROI from input image:

cv::Rect rect1 = cvRect(9*imgs[0].cols/10, 1*imgs[0].rows/8, imgs[0].cols/10, 6*imgs[0].rows/8);  //second part of the first image
    cv::vector<cv::Rect> roi1;
    roi1.push_back(rect1);
cv::Rect rect12 = cvRect(0, imgs[1].rows/8, imgs[1].cols/10, 6*imgs[1].rows/8);  //first part of the second image
    cv::vector<cv::Rect> roi2;
    roi2.push_back(rect12);

so, for 1280x960 input image, my ROI will be 128x720. When I have increased ROI width in 3 times, it works without exceptions, but does not stitch (Can't stitch images, error code = 1), why? ROI 128x720 works without GPU support, but very slow (it takes 3-4 seconds on Core i7 + GeForce GT550M).

Updated by Vladislav Vinogradov almost 12 years ago

The minimal image size supported by SURF_GPU depends from number of octaves.

Here is a formula for minimum image size:

min(image.rows, image.cols) > 23 * (2 ^ (nOctaves - 1))

By default Stitcher uses 3 octaves for detector and 4 for descriptor, so

min(image.rows, image.cols) > 184

Updated by Vladislav Vinogradov almost 12 years ago

Close this issue, because it's not a bug.

  • Status changed from Open to Cancelled

Also available in: Atom PDF