nona crashes with std::bad_alloc when input has more than 2^31 pixels

Bug #1307023 reported by kaefert
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Hugin
Won't Fix
Undecided
Unassigned

Bug Description

I would like to create cube faces for a 360° Panorama that is currently in equirectlinear projection with a size of 155.110 x 51.338 pixels (not full 180° height, top and bottom are cut away) - so a total pixel count of 7.963.037.180
It's currently in png format, since most programs don't seem to know that with bigtif a tif can be bigger than 4gb.

I like to use erect2cubic from the Panotools::Script cpan package. This creates a pto file which then needs to be called with nona:
erect2cubic --erect=equirectlinear.tif --ptofile=cube.pto; nona -o prefix cube.pto

This works perfectly when the total pixel count is smaller than 2^31. I am searching for a solution for bigger panoramas.

enblend suffers from the same limitation, theres an quite old bug report in the enblend launchpad tracker
https://bugs.launchpad.net/enblend/+bug/685105
that sort of ended with the statement that panoramas with more than 2^31 are out of the scope of what enblend want's to achieve.
Does this apply to nona too?

Is there some hint any of the devs can give me how to work around this problem?
In two of my previous panoramas I've stiched the 4 relevant faces seperatly directly with a linear projection, though I dislike this aproach because it's nearly impossible to make the 4 seams manually match. See:
https://kaefert.is-a-geek.org/SaladoPlayer-1.3.5/?pano=blindengasse55_2014-01-10&view=43,0,12
https://kaefert.is-a-geek.org/SaladoPlayer-1.3.5/?pano=koega_2013-11-27&view=44,-1,10

Revision history for this message
tmodes (tmodes) wrote :

Nona has the same limitation as it uses the same underlying vigra library for the image processing.

Changed in hugin:
status: New → Won't Fix
Revision history for this message
kaefert (kaefert) wrote :

I've just written a mail to the vigra mailing list, and vigra's author told me that
" VIGRA is certainly able to work with more than 2^31 pixels when compiled with a 64-bit compiler. We routinely do this."

He asked me "Can you describe the problem more precisely?"
Sadly I don't know how. All I know is that nona and enblend fail quickly with out-of-memory exceptions while enough free memory is available.

Revision history for this message
ner0 (ner0) wrote :

Hello.

Sorry to come into this old discussion.
I see that the status of this bug report is "Won't Fix" but the last user before me mentioned that it might be possible to build the VIGRA library using a 64bit compiler and overcome the limitation. I'd like to help out but don't know where to start. I'm not a coder but I'm facing the exact same problem where cubic2erect will fail when using nona with the error "std::bad_alloc".

I tried getting the 64bit compiled version of vigraimpex and using that instead of libvigraimpex but needless to say that I don't know what I am doing.

I almost had success using Hugin's 2015 64bit version but that gave me another different error:
ERROR: (c:\users\harryvanderwolf\downloads\hugin-sdk\sdk\hugin-2015.0.0\src\hugin_base\nona\Stitcher.h:547) HuginBase::Nona::WeightedStitcher<class vigra::BasicImage<class vigra::RGBValue<unsigned char,0,1,2>,class std::allocator<class vigra::RGBValue<unsigned char,0,1,2> > >,class vigra::BasicImage<unsigned char,class std::allocator<unsigned char> > >::stitch(): exception during stitching
Precondition violation!
separableConvolveX(): kernel longer than line

(c:\users\harryvanderwolf\downloads\hugin-sdk\sdk\vigra\include\vigra\separableconvolution.hxx:1103)

Nevertheless it produced the final image (527 MB - 25132x12566px) with 85% accuracy.
The missing 15% are because it is literally missing a full chunk (always the right side of the cubic panorama).

EDIT: Well, I was about to finish this off when I browsed through the sourceforge folders and saw the 2016.2 RC2 64bit version. And what do you know, it solves the issue completely! No more errors or missing chunks, it just works!

Thanks to the community and mainly the developers for all their hard work.

Cheers!

Revision history for this message
kaefert (kaefert) wrote :

I don't think that your solution fixes this issue.
Your panorama is 25132*12566 = 315.808.712 pixel in size.

The problem mentioned in the title is for panoramas with more than 2^31 = 2.147.483.648 pixels (nearly 7 times bigger than yours)

If somebody finds a a way to stich panoramas of that size or larger, I would still be very interested in the solution.

Revision history for this message
ner0 (ner0) wrote :

Fair enough, I misunderstood the OP's problem and took it as the same issue.

Nevertheless, I was curious about the limitation that I tried stitching something bigger, even though I don't plan on actually stitching such big images in the near future. The test I did succeeded but I'm not sure if the shortcuts taken during this test might have had anything to do with a perceived success.

Since I didn't have big enough images I created six identical 32000x32000 JPG images with Photoshop, completely white; I'm not sure if this might have influenced the success of the stitching process. Because they are plain white JPGs they are only 10.7MB each. Not sure if this counts for testing purposes, also worth mentioning that the output TIFF was only 20MB.

This is my system:
- OS: Windows 10 x64
- CPU: Intel Core i7-4770K @ 3.5GHz
- RAM: 16GB DDR3

Software and resources used:
- Photoshop CC
- Six identical white 32000x32000 JPGs
- cubic2erect bundled with Panotools-Script-0.22-win32
- nona and dependencies bundled with Hugin 2016.2 RC2 64bit

In my system, the whole process took around ~25min.
I ended up with an equirectangular TIFF with a size of 100530x50265 = 5.053.140.450 pixels (more than double the mentioned limit of 2^31).

Revision history for this message
kaefert (kaefert) wrote :

Well that's interesting, thanks for doing those tests!
I'll try to find my huge panorama from back then and try to retry the stiching with a current nona 64bit build.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.