Getting OpenCV Error: Out of memory when starting OpenCV Sample: "stitching_detailed.cpp"

I recently started working with OpenCV to stitch a large number of images together to create massive panoramas. To start the experiments, I looked at examples of programs that come with OpenCV files to get an idea of ​​how to implement the OpenCV libraries. Since I was interested in stitching images, I went straight to "stitching_detailed.cpp". The code can be found at:

https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/cpp/stitching_detailed.cpp?rev=6856

Now this program does most of what I need, but I came across something interesting. I found that for 9 out of 15 additional projection cones, I get the following error when trying to run the program:

Insufficient memory (Failed to allocate XXXXXXXXXX bytes) in unknown function, file C:\slave\winInstallerMegaPack\src\opencv\modules\core\src\alloc.cpp, line 52 

where is the integer number of characters "X", which varies between different types of projections (as if different methods require different amounts of space). The full source code for "alloc.cpp" can be found at the following website:

https://code.ros.org/trac/opencv/browser/trunk/opencv/modules/core/src/alloc.cpp?rev=3060

However, the line of code that emits this error in alloc.cpp is:

  static void* OutOfMemoryError(size_t size) { --HERE--> CV_Error_(CV_StsNoMem, ("Failed to allocate %lu bytes", (unsigned long)size)); return 0; } 

So, I just lost the possible reasons why this error may occur. I understand that this error usually occurs if there is no memory in the system, but when I run this program with my test images, in my task manager, I never use more than ~ 3.5 GB of RAM.

Also, since the program was written as an example of OpenCV's stitching capabilities. OpenCV developers find it hard to believe that there is a sharp memory error in the source code.

Finally, the program works fine if I use some warping methods:

 - spherical - fisheye - transverseMercator - compressedPlanePortraitA2B1 - paniniPortraitA2B1 - paniniPortraitA1.5B1) 

but ask the program to use any of the others (via the command line tag
--warp [PROJECTION_NAME]):

 - plane - cylindrical - stereographic - compressedPlaneA2B1 - mercator - compressedPlaneA1.5B1 - compressedPlanePortraitA1.5B1 - paniniA2B1 - paniniA1.5B1 

I get the error mentioned above. I get pretty good results from the transverseMercator warper project, but I would like to test stereography in particular. Can someone help me figure this out?

The photos I'm trying to process have a resolution of 1360 x 1024, and my computer has the following statistics:

 Model: HP Z800 Workstation Operating System: Windows 7 enterprise 64-bit OPS Processor: Intel Xeon 2.40GHz (12 cores) Memory: 14GB RAM Hard Drive: 1TB Hitachi Video Card: ATI FirePro V4800 

Any help would be greatly appreciated, thanks!

+4
source share
2 answers

When I run tracascascade OpenCV APP, I get only the same error as you:

 Insufficient memory (Failed to allocate XXXXXXXXXX bytes) in unknown function, file C:\slave\winInstallerMegaPack\src\opencv\modules\core\src\alloc.cpp, line 52 

at that time only about 70% of my memory (6G) was occupied. And when runnig trainscascade step by step, I found that the error would be thrown. When it uses about 1.5 GB of RAM. then I found two arguments that can control how much memory should be used:

-precalcValBufSize -precalcIdxBufSize so I tried to set these two to 128, it starts. Hope my experience helps you.

I thought that this problem has nothing to do with a memory leak, it is simply related to how much memory the OS occupies. I expect someone to be able to verify my assumptions.

+1
source

This may be due to the sequence of the lines, I split the large picture into 3 * 3, and, firstly, I flash them in rows, and there is no problem when I sew them in a column, the problem is the same as you.

0
source

All Articles