CUDA Integration with OpenCV Header File Errors

I’m working on a project that involves Video Processing on a GPU. I can get OpenCV aspects of my code to work in one file, and CUDA aspects of my code to work in another file. But for some reason, when I combine both pieces together (I’m doing a simple test program in which they do not interact) I get the following errors:

function “cv::Mat_<Tp>::t" returns incomplete type "cv::MatExpr<cv::MatExpr_Op2_<cv::Mat, double, cv::Mat, cv::MatOp_T_cv::Mat>, cv::Mat>”
This error occurs in: cxmat.hpp at line 730

no suitable user-defined conversion from “cv::MatExpr_<cv::MatExpr_Op3_<cv::Mat, cv::Scalar, int, cv::Mat, cv::MatOp_Bin_cv::Mat>, cv::Mat>” to “cv::MatExpr_<cv::MatExpr_Op3_<cv::Mat, cv::Scalar, int, cv::Mat, cv::MatOp_BinS_cv::Mat>, cv::Mat>” exists
This error occurs in: cxmat.hpp at line 2978

error PRJ0019: A tool returned an error code from “Performing Custom Build Step”

I also had another error in cxoperations.hpp that I was able to resolve by changing “r = Range(0, d.size());” to “const_castcv::Range&( r ) = Range(0, d.size());” (I found this fix in another thread on these forums)

I’m completely lost and these errors seem to stem from header files and not directly from my code. Furthermore, if I comment out all of the OpenCV portions of my code, I still get these errors when I keep the highgui.h and cv.h header files.

Any help/guidance would be much appreciated. I realize this may be more of an OpenCV concern than a CUDA one, but I’m not certain of that and it might just be a question that can be solved by someone who has a very deep understanding of C++.


Here’s more useful info (apologies for the double post):

First Error:

template<typename _Tp> inline Mat_<_Tp>::operator vector<_Tp>() const


    CV_Assert( rows == 1 || cols == 1 );

    return isContinuous() ?

        vector<_Tp>((_Tp*)data,(_Tp*)data + (rows + cols - 1)) :

        (vector<_Tp>)((Mat_<_Tp>)this->t()); //Error on this line


Second Error:

// abs(A)

template<typename _Tp> static inline

MatExpr_<MatExpr_Op3_<Mat, Scalar, int, Mat,

            MatOp_BinS_<Mat> >, Mat >

abs(const Mat_<_Tp>& a, const Mat_<_Tp>& b)


    typedef MatExpr_Op3_<Mat, Scalar, int, Mat,

        MatOp_Bin_<Mat> > MatExpr_Temp;

    return MatExpr_<MatExpr_Temp, Mat >(MatExpr_Temp( //Error here

        a, Scalar(0), 'a'));


Hi Adam, I’m having a similar problem. How did you solve it?

Im having the same problem here using OpenCV2.1 with CUDA 4.0 in VS2010.

Any ideas???