Ask Your Question
0

GPU resize Ubuntu 12.04

asked 2013-09-13 01:51:20 -0600

rkurian gravatar image

updated 2013-09-13 01:59:42 -0600

I installed OpenCV 2.4.6.1 on Ubuntu 12.04 with CUDA turned on. I have Cuda version 5.0 installed. While I can run the sample on http://opencv.willowgarage.com/wiki/OpenCV_GPU, when I try to run the following progrm:

#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"

using namespace cv;

int main (int argc, char* argv[])
{
    try
    {
        std::cout << CV_VERSION ;
        Mat src_host = imread("sunset.jpg", CV_LOAD_IMAGE_COLOR);
        gpu::GpuMat dst, src;
        src.upload(src_host);

        gpu::resize(src, dst, Size(256, 256), 0, 0, INTER_CUBIC);
        Mat dst_host(dst);
        imwrite("out.jpeg", dst);

        return 0;
    }
    catch(const cv::Exception& ex)
    {
        std::cout << "Error: " << ex.what() << std::endl;
    }
    return 0;
}

I get the following error: OpenCV Error: Assertion failed (k == STD_VECTOR_MAT) in getMat, file /home/opencv-2.4.6.1/modules/core/src/matrix.cpp, line 988 2.4.6.1Error: /home/opencv-2.4.6.1/modules/core/src/matrix.cpp:988: error: (-215) k == STD_VECTOR_MAT in function getMat

I have a GTX 460 which scores a 2.1 on the Nvidia compute capability score. Has any one else run into this problem?

edit retag flag offensive close merge delete

Comments

I also get this sometimes: OpenCV Error: Gpu API call (out of memory) in mallocPitch, file /home/opencv-2.4.6.1/modules/core/src/gpumat.cpp, line 1415 2.4.6.1Error: /home/opencv-2.4.6.1/modules/core/src/gpumat.cpp:1415: error: (-217) out of memory in function mallocPitch Not sure when I get the previous error vs this one.

rkurian gravatar imagerkurian ( 2013-09-13 01:57:58 -0600 )edit

Are you sure the crash happens in gpu::resize or maybe it is Mat dst_host(dst)?

Moster gravatar imageMoster ( 2013-09-13 02:45:19 -0600 )edit

Actually passing a GpuMat instance to imwrite was the issue.

rkurian gravatar imagerkurian ( 2013-09-13 11:48:11 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-09-13 03:02:57 -0600

Vladislav Vinogradov gravatar image

First, check that your image was loaded correctly:

Mat src_host = imread("sunset.jpg", CV_LOAD_IMAGE_COLOR);
if (src_host.empty())
{
    std::cerr << "Can't load image";
    exit(-1);
}

The second issues is that you are passing GpuMat dst to imwrite function. You should pass dst_host:

gpu::resize(src, dst, Size(256, 256), 0, 0, INTER_CUBIC);
Mat dst_host(dst);
imwrite("out.jpeg", dst_host);
edit flag offensive delete link more

Comments

I don't know how I missed that! Passing the GpuMat dst to imwrite was the issue.

rkurian gravatar imagerkurian ( 2013-09-13 11:47:22 -0600 )edit

Question Tools

Stats

Asked: 2013-09-13 01:51:20 -0600

Seen: 2,177 times

Last updated: Sep 13 '13