From 04894893225c90de38269ad8fc607a126c427370 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 30 May 2013 13:11:32 +0400 Subject: [PATCH] used cudaMalloc for 1-row or 1-column matrix instead of cudaMallocPitch --- modules/core/src/gpu_mat.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/core/src/gpu_mat.cpp b/modules/core/src/gpu_mat.cpp index 1bbcb843d..a2e8da65a 100644 --- a/modules/core/src/gpu_mat.cpp +++ b/modules/core/src/gpu_mat.cpp @@ -678,11 +678,17 @@ void cv::gpu::GpuMat::create(int _rows, int _cols, int _type) size_t esz = elemSize(); void* devPtr; - cudaSafeCall( cudaMallocPitch(&devPtr, &step, esz * cols, rows) ); - // Single row must be continuous - if (rows == 1) + if (rows > 1 && cols > 1) + { + cudaSafeCall( cudaMallocPitch(&devPtr, &step, esz * cols, rows) ); + } + else + { + // Single row or single column must be continuous + cudaSafeCall( cudaMalloc(&devPtr, esz * cols * rows) ); step = esz * cols; + } if (esz * cols == step) flags |= Mat::CONTINUOUS_FLAG;