adrelino / variational-depth-from-focus

Implementation of "Variational Depth from Focus Reconstruction" [Moeller 2015]
GNU General Public License v2.0
56 stars 23 forks source link

Run code on bigger image #3

Closed adrelino closed 7 years ago

adrelino commented 7 years ago

@hazirbas:

Plus would be nice to get some help from you to run the code on a bigger image. I tried on 378x379 but it caused a segmentation fault.

(Split up into new issue from #2 )

adrelino commented 7 years ago

Dear @hazirbas, could you please pull the code again and run it? I added some output which prints the available device memory. Maybe your GPU is just running out of memory while loading the image stack. Our code is quite stupid in that it just tries to read in all the images at once, allocates a lot of device and host memory and maybe doesn't release all of it properly before going to the next step. There are definitely smarter ways to do it. No streaming e.g. so if it doesn't fit, it just crashes.

hazirbas commented 7 years ago

Hi @adrelino, Thanks for your help. I will try it asap and let you know what exactly happens! Caner.

hazirbas commented 7 years ago

Hi again,

Here is the output error I get. My image size is 378x379. And I have 19 images in my focal stack.

PARAM[DEF]: grayscale : 0 ================================== General Parameters ============================== Specified sequence folder: ./IMG_0001 Export filename: Use page locked memory: False Use GPU to smooth depth estimate: True Use every n-th picture: 1 Use Tensor3f Class (experimental): False Delay: 1 minVal: -10 maxVal: 10 Degree of polynomial: 6 DenomRegu: 0.3

================================== Executing ======================================= AvailableGlobalMemory: 12682.91992 / 12799.57422 MB calling cudaDeviceReset to try to free GPU memory AvailableGlobalMemory: 12682.91992 / 12799.57422 MB Determine sharpness from images in ./IMG_0001 type: CV_8UC3 channels: 3 elemSize1: 1 bytes maxRange: 255 Executing with a single stream [1] 14446 segmentation fault (core dumped) ./vdff -dir ./IMG_0001 x

mngKd commented 7 years ago

Hi Caner, thanks for the feedback. It should be no problem with the image size, since we tried it on more than 400 HD images. Unfortunately, the debug output is not really detailed, it seems to crash in determining the sharpness of the image, but that's rather vague.

Could you provide us with a backtrace in gdb? For that:

hazirbas commented 7 years ago

Hi @mngKd ,

Here is the output:

================================== Executing ======================================= [New Thread 0x7fffd6627700 (LWP 13263)] [New Thread 0x7fffd5e26700 (LWP 13264)] AvailableGlobalMemory: 12682.91992 / 12799.57422 MB calling cudaDeviceReset to try to free GPU memory [Thread 0x7fffd5e26700 (LWP 13264) exited] [Thread 0x7fffd6627700 (LWP 13263) exited] [New Thread 0x7fffd6627700 (LWP 13265)] [New Thread 0x7fffd5e26700 (LWP 13266)] AvailableGlobalMemory: 12682.91992 / 12799.57422 MB Determine sharpness from images in /IMG_0001 type: CV_8UC3 channels: 3 elemSize1: 1 bytes maxRange: 255 Executing with a single stream Determining sharpness from picture 1 from 11 Thread 1 "vdff" received signal SIGSEGV, Segmentation fault. _int_malloc (av=av@entry=0x7fffef4ebb20 , bytes=bytes@entry=429816) at malloc.c:3803 3803 malloc.c: No such file or directory. (gdb) bt

0 _int_malloc (av=av@entry=0x7fffef4ebb20 , bytes=bytes@entry=429816) at malloc.c:3803

1 0x00007fffef1ab5a4 in __GI___libc_malloc (bytes=429816) at malloc.c:2914

2 0x00007fffefadb43e in cv::fastMalloc(unsigned long) () from /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4

3 0x00007fffefbafe2f in cv::Mat::create(int, int const*, int) () from /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4

4 0x00007ffff02e17d6 in ?? () from /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4

5 0x00007ffff02e1986 in cv::imread(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int) ()

from /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4

6 0x000000000041cebc in vdff::openCVHelpers::imreadFloat (filename="/IMG_0001/im_02.png", grayscale=false)

at variational-depth-from-focus/src/openCVHelpers.cpp:393

7 0x00000000004371ce in vdff::DataPreparator::determineSharpnessFromAllImagesSingleStream (this=0xc74bc0, imgFileNames=std::vector of length 11, capacity 11 = {...},

firstImage=..., paddingTop=3, paddingBottom=3, paddingLeft=2, paddingRight=3, nrPixels=429786, diffW=5, diffH=6, grayscale=false)
at variational-depth-from-focus/src/DataPreparator.cu:111

8 0x0000000000438bf7 in vdff::DataPreparator::determineSharpnessFromAllImages (this=0xc74bc0, deviceProperties=..., usePageLockedMemory=false, useNthPicture=1,

grayscale=false) at variational-depth-from-focus/src/DataPreparator.cu:282

9 0x0000000000423a30 in approximateSharpnessAndCreateDepthEstimate (params=..., deviceProperties=..., d_coefDerivative=0x7fffffffd088, mSmoothDepthEstimateScaled=...,

info=...) at variational-depth-from-focus/src/vdff.cu:145

10 0x00000000004241f6 in main (argc=3, argv=0x7fffffffd918) at variational-depth-from-focus/src/vdff.cu:228

mngKd commented 7 years ago

Thanks for the fast feedback,

seems to be a openCV problem with loading the "/IMG_0001/im_02.png" file, so it would be interesting to have a look at the images.

I will later drop by our office, and maybe you can give me your sample files, so that I can have a closer look at it.

Cheers from the master lab, Dennis

Edit: got the images, will check in the evening what's wrong