Using cv::cuda::split ends in SEGFAULT

asked 2017-11-13 09:48:03 -0600

Hi,

When I use cv::cuda::split with an std::vector<cv::cuda::GpuMat> it appears to work fine. My 3 channel float matrix is split as expected; however when I try the other overload which uses a single cv::cuda::GpuMat I get segmentation faults.

I'm basically trying to split a float matrix into a 3 channel BGR matrix:

// mfloat has the float data
cv::cuda::GpuMat input_matrix;
cv::cuda::split(mfloat, &input_matrix);

This SEGFAULTS with:

Thread 1 "test_computer_v" received signal SIGSEGV, Segmentation fault. 0x00007fffead6844d in cv::cuda::GpuMat::create(int, int, int) () from /usr/local/lib/libopencv_core.so.3.3

I've tried setting the matrix size and allocating it, although the documentation does not make it clear what is expected, by setting each row to contain a full-sized matrix cv::cuda::GpuMat input_matrix(3, 224 * 224, CV_32FC1); but the same error still persists. Same with cv::cuda::GpuMat input_matrix(224 * 224, 3, CV_32FC1);.

When I allocate and pass pointers (std::unique_ptr or a raw pointer) I then get a SEGFAULT from a different line:

cv::cuda::GpuMat * input_matrix = new cv::cuda::GpuMat(224, 224, CV_32FC1);
cv::cuda::split(mfloat, input_matrix);

The error:

Thread 1 "test_computer_v" received signal SIGSEGV, Segmentation fault. 0x00007fffead6833d in cv::cuda::GpuMat::release() () from /usr/local/lib/libopencv_core.so.3.3

Can somebody explain how is the version of

void cv::cuda::split(InputArray     src,
                     GpuMat *   dst,
                     Stream &   stream = Stream::Null() 
                    )

to be properly used? How is dst to be allocated and sized?

edit retag flag offensive close merge delete