Opencv 3.0.0 alpha与Cuda 6.5,CudaStereo错误(Visual Studio 2013 x64)

时间:2014-10-21 03:16:55

标签: opencv cuda

当我尝试编译cudastereo项目时,我收到40个这样的错误:

Error   46  error : calling a __host__ function("fmin<int, float> ") from a __global__ function("cv::cuda::device::stereocsbp::init_data_cost<short, (int)1> ") is not allowed  D:\ImageProcessing\GPU\opencv\sources\modules\cudastereo\src\cuda\stereocsbp.cu 219 opencv_cudastereo   1
你能帮我吗? 顺便说一句,opencv中的所有其他cuda项目都成功编译,这是我在opencv中需要的非编译功能。

我认为问题在于调用这些函数:

        template<>  __device__ __forceinline__ static float pixeldiff<1>(const uchar* left, const uchar* right, float max_data_term)
    {
        return fmin( ::abs((int)*left - *righ), max_data_term);
    }
    template<>  __device__ __forceinline__ static float pixeldiff<3>(const uchar* left, const uchar* right, float max_data_term)
    {
        float tb = 0.114f * ::abs((int)left[0] - right[0]);
        float tg = 0.587f * ::abs((int)left[1] - right[1]);
        float tr = 0.299f * ::abs((int)left[2] - right[2]);

        return fmin(tr + tg + tb, max_data_term);
    }
    template<> __device__ __forceinline__ static float pixeldiff<4>(const uchar* left, const uchar* right, float max_data_term)
    {
        uchar4 l = *((const uchar4*)left);
        uchar4 r = *((const uchar4*)right);

        float tb = 0.114f * ::abs((int)l.x - r.x);
        float tg = 0.587f * ::abs((int)l.y - r.y);
        float tr = 0.299f * ::abs((int)l.z - r.z);

        return fmin(tr + tg + tb, max_data_term);
    }

2 个答案:

答案 0 :(得分:1)

问题出现在第一个函数中,所以我将其更改为

        template<> __device__ __forceinline__ static float pixeldiff<1>(const uchar* left, const uchar* right, float max_data_term)
    {

        float  tempfloat = ::abs((int)*left - *right);
        return fmin( tempfloat, max_data_term);

    }

答案 1 :(得分:0)

需要删除静态声明

模板&LT;&GT; 设备 强制在线浮动pixeldiff&lt; 1&gt;(const uchar * left,const uchar * right,float max_data_term)     { .....