Attention! This forum will be made read-only by Dec-20. Please migrate to https://forum.opencv.org. Most of existing active users should've received invitation by e-mail.
Ask Your Question
0

gpu::HOGDescriptor works for small image, but not larger image

asked 2013-12-03 15:14:06 -0500

daviddoria gravatar image

I have a small image (800x534) and a large image (1920x1080). I have some simple code that creates a gpu::HOGDescriptor, uploads the image to the GPU, and then runs hog.detectMultiScale. With the small image, it works fine. However, with the large image, I get

OpenCV Error: Gpu API call (out of memory) in mallocPitch, file /home/doriad/src/opencv-2.4.6.1/modules/core/src/gpumat.cpp, line 1415 terminate called after throwing an instance of 'cv::Exception' what(): /home/doriad/src/opencv-2.4.6.1/modules/core/src/gpumat.cpp:1415: error: (-217) out of memory in function mallocPitch

I have a Quadro NVS 420 card, so there should be plenty of memory. In fact, before the upload() call I have

Free memory: 115802112

and after: Free memory: 106459136

which makes sense. Can anyone explain what is going on internally that would take 100 MB of GPU memory for a 1920x1080 image?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2013-12-04 00:25:32 -0500

Vladislav Vinogradov gravatar image

It allocates image pyramid with 64 levels and scale = 1.05 (default parameters). This can be the largest part.

Also it allocates memory for descriptors: nbins * cells_per_block * blocks_per_img * sizeof(float). For 1920x1080 it something about 4.4 MB.

edit flag offensive delete link more

Comments

@Vladislav Vinogradov Ah, so that pyramid seems like it could be easily more than 100MB. The only parameter of the pyramid that it looks like I can pass is the scale - how is the number of levels affected by the scale? That is, if I set the scale to 1.1, does it still create 64 levels?

daviddoria gravatar imagedaviddoria ( 2013-12-04 06:41:04 -0500 )edit

You can change the number of scales in constructor of gpu::HOGDescriptor. And scale parameter also affects the real number of levels. The algorithm will downscale images until its size become smaller than size of block.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2013-12-04 23:53:02 -0500 )edit

@Vladislav Vinogradov That constructor definitely exposes more options, thanks. I was able to avoid the error by changing the scale to 1.10 (even with nlevels=64). However, with scale=1.05, no matter what I nlevels to (even nlevels=1) I again get the memory error - does that make sense to you?

daviddoria gravatar imagedaviddoria ( 2013-12-05 07:27:44 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-12-03 15:14:06 -0500

Seen: 498 times

Last updated: Dec 04 '13