Ask Your Question
0

Can't compile .cu file when including opencv.hpp

asked 2012-07-10 01:51:11 -0600

soroosh.strife gravatar image

Hi all,

I'm not able to compile .cu files when I add this;

#include <opencv2/opencv.hpp>

Is there any way to make this work?

edit retag flag offensive close merge delete

Comments

Sharing the error message would be very helpful for others to figure out the problem.

Mourad gravatar imageMourad ( 2012-07-30 04:11:54 -0600 )edit

"opencv2/core/devmem2d.hpp" , This file does not exist in OpenCV3.1.0

What's the solution for this question in OpenCV3.1.0?

amir_pro gravatar imageamir_pro ( 2016-07-04 06:22:33 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-08-13 07:33:47 -0600

Vladislav Vinogradov gravatar image

This header includes some code that nvcc doesn't understand (some intrinsic, asm part, etc). You can divide your code into two parts (cpp & cu). In cpp file you can use all opencv headers, in cu file you can use "opencv2/core/devmem2d.hpp" - lightweight wrapper for GpuMat

// cu file
__global__ void kernel(DevMem2D_<Type> mat)
{
    ...
}
void gpu_func(DevMem2D_<Type> mat)
{
    kernel<<<...>>>(mat);
}

// cpp file
#include <opencv2/opencv.hpp>
void gpu_func(DevMem2D_<Type> mat);
void func(GpuMat mat)
{
   mat.create(...);
   gpu_func(mat);
}

gpu module works in such a way.

edit flag offensive delete link more

Comments

"opencv2/core/devmem2d.hpp" , This file does not exist in OpenCV3.1.0 What's the solution for this question in OpenCV3.1.0?

amir_pro gravatar imageamir_pro ( 2016-07-04 07:06:58 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-07-10 01:51:11 -0600

Seen: 3,679 times

Last updated: Jul 04 '16