Javacpp-presets: opencv Stitcher crashes for large images

Created on 28 Mar 2018  路  4Comments  路  Source: bytedeco/javacpp-presets

I wrote a stitcher based on the example shown here: https://github.com/bytedeco/sample-projects/tree/master/opencv-stitching
I have a sample of three images fresh from a DSLR camera, resolution 6000x4000. When I tried to stitch them, I got the following error:

OpenCL error CL_MEM_OBJECT_ALLOCATION_FAILURE (-4) during call: clEnqueueNDRangeKernel('pyrUp', dims=2, globalsize=5344x3840x1, localsize=16x16x1) sync=false
OpenCV Error: Unknown error code -220 (OpenCL error CL_MEM_OBJECT_ALLOCATION_FAILURE (-4) during call: clEnqueueReadBuffer(q, (cl_mem)u->handle, CL_TRUE, 0, u->size, alignedPtr.getAlignedPtr(), 0, 0, 0)) in map, file /projects/bytedeco/javacpp-presets/opencv/cppbuild/linux-x86_64/opencv-3.4.0/modules/core/src/ocl.cpp, line 4980
OpenCV Error: Assertion failed (u->refcount == 0 && "UMat deallocation error: some derived Mat is still alive") in deallocate, file /projects/bytedeco/javacpp-presets/opencv/cppbuild/linux-x86_64/opencv-3.4.0/modules/core/src/ocl.cpp, line 4724
terminate called after throwing an instance of 'cv::Exception'
  what():  /projects/bytedeco/javacpp-presets/opencv/cppbuild/linux-x86_64/opencv-3.4.0/modules/core/src/ocl.cpp:4724: error: (-215) u->refcount == 0 && "UMat deallocation error: some derived Mat is still alive" in function deallocate

After a bit of searching and trial and error, I took those same images and scaled them down to 1920x1280, and the stitching worked without issue.

I successfully reproduced the behaviour by running the linked example through the command line passing those same images.
I'm running the example on an upgraded HP ZBook with 24 gigs of Ram, so physical memory shouldn't be the problem here.

question

Most helpful comment

That worked, thanks a bunch!

All 4 comments

It's probably running out of memory on your GPU. Disable OpenCL and it should be able to use more memory.

I did pass false for try_use_gpu to Stitcher.createDefault(). Is there something else I must do?

You could try this, for example: https://github.com/opencv/opencv/issues/9852

That worked, thanks a bunch!

Was this page helpful?
0 / 5 - 0 ratings