fix compiling errors on Linux

more operators use oclMatExpr
This commit is contained in:
yao 2013-02-16 18:41:43 +08:00
parent 69fd2d8273
commit 9613135e8d
3 changed files with 42 additions and 36 deletions

View File

@ -12,6 +12,7 @@
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -51,23 +52,28 @@ namespace cv
enum
{
MAT_ADD,
MAT_ADD = 1,
MAT_SUB,
MAT_MUL,
MAT_DIV
MAT_DIV,
MAT_NOT,
MAT_AND,
MAT_OR,
MAT_XOR
};
class oclMatExpr
class CV_EXPORTS oclMatExpr
{
public:
oclMatExpr() : a(oclMat()), b(oclMat()), op(0) {}
oclMatExpr(const oclMat& _a, const oclMat& _b, int _op)
: a(_a), b(_b), op(_op){}
: a(_a), b(_b), op(_op) {}
operator oclMat() const;
void assign(oclMat& m) const;
protected:
int op;
oclMat a, b;
int op;
};
////////////////////////////////////////////////////////////////////////
//////////////////////////////// oclMat ////////////////////////////////
@ -255,7 +261,7 @@ namespace cv
return *this;
}
oclMat& oclMat::operator = (const oclMatExpr& expr)
inline oclMat& oclMat::operator = (const oclMatExpr& expr)
{
expr.assign(*this);
return *this;

View File

@ -153,7 +153,7 @@ namespace cv
oclMat &operator = (const oclMat &m);
//! assignment operator. Perfom blocking upload to device.
oclMat &operator = (const Mat &m);
oclMat& operator = (const oclMatExpr& expr);
oclMat &operator = (const oclMatExpr& expr);
//! pefroms blocking upload data to oclMat.
void upload(const cv::Mat &m);
@ -463,10 +463,10 @@ namespace cv
CV_EXPORTS void bitwise_xor(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat());
//! Logical operators
CV_EXPORTS oclMat operator ~ (const oclMat &src);
CV_EXPORTS oclMat operator | (const oclMat &src1, const oclMat &src2);
CV_EXPORTS oclMat operator & (const oclMat &src1, const oclMat &src2);
CV_EXPORTS oclMat operator ^ (const oclMat &src1, const oclMat &src2);
CV_EXPORTS oclMatExpr operator ~ (const oclMat &src);
CV_EXPORTS oclMatExpr operator | (const oclMat &src1, const oclMat &src2);
CV_EXPORTS oclMatExpr operator & (const oclMat &src1, const oclMat &src2);
CV_EXPORTS oclMatExpr operator ^ (const oclMat &src1, const oclMat &src2);
//! Mathematics operators
CV_EXPORTS oclMatExpr operator + (const oclMat &src1, const oclMat &src2);
@ -478,7 +478,7 @@ namespace cv
//! support only CV_32FC1 type
CV_EXPORTS void convolve(const oclMat &image, const oclMat &temp1, oclMat &result);
CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0);
CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0);
//////////////////////////////// Filter Engine ////////////////////////////////

View File

@ -2125,56 +2125,44 @@ void cv::ocl::bitwise_xor(const oclMat &src1, const Scalar &src2, oclMat &dst, c
bitwise_scalar( src1, src2, dst, mask, kernelName, &arithm_bitwise_xor_scalar);
}
cv::ocl::oclMat cv::ocl::operator ~ (const oclMat &src)
oclMatExpr cv::ocl::operator ~ (const oclMat &src)
{
oclMat dst;
bitwise_not(src, dst);
return dst;
return oclMatExpr(src, oclMat(), MAT_NOT);
}
cv::ocl::oclMat cv::ocl::operator | (const oclMat &src1, const oclMat &src2)
oclMatExpr cv::ocl::operator | (const oclMat &src1, const oclMat &src2)
{
oclMat dst;
bitwise_or(src1, src2, dst);
return dst;
return oclMatExpr(src1, src2, MAT_OR);
}
cv::ocl::oclMat cv::ocl::operator & (const oclMat &src1, const oclMat &src2)
oclMatExpr cv::ocl::operator & (const oclMat &src1, const oclMat &src2)
{
oclMat dst;
bitwise_and(src1, src2, dst);
return dst;
return oclMatExpr(src1, src2, MAT_AND);
}
cv::ocl::oclMat cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2)
oclMatExpr cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2)
{
oclMat dst;
bitwise_xor(src1, src2, dst);
return dst;
return oclMatExpr(src1, src2, MAT_XOR);
}
cv::ocl::oclMatExpr cv::ocl::operator + (const oclMat &src1, const oclMat &src2)
{
oclMatExpr dst(src1, src2, cv::ocl::MAT_ADD);
return dst;
return oclMatExpr(src1, src2, cv::ocl::MAT_ADD);
}
cv::ocl::oclMatExpr cv::ocl::operator - (const oclMat &src1, const oclMat &src2)
{
oclMatExpr dst(src1, src2, cv::ocl::MAT_SUB);
return dst;
return oclMatExpr(src1, src2, cv::ocl::MAT_SUB);
}
cv::ocl::oclMatExpr cv::ocl::operator * (const oclMat &src1, const oclMat &src2)
{
oclMatExpr dst(src1, src2, cv::ocl::MAT_MUL);
return dst;
return oclMatExpr(src1, src2, cv::ocl::MAT_MUL);
}
cv::ocl::oclMatExpr cv::ocl::operator / (const oclMat &src1, const oclMat &src2)
{
oclMatExpr dst(src1, src2, cv::ocl::MAT_DIV);
return dst;
return oclMatExpr(src1, src2, cv::ocl::MAT_DIV);
}
void oclMatExpr::assign(oclMat& m) const
@ -2193,6 +2181,18 @@ void oclMatExpr::assign(oclMat& m) const
case MAT_DIV:
divide(a, b, m);
break;
case MAT_NOT:
bitwise_not(a, m);
break;
case MAT_AND:
bitwise_and(a, b, m);
break;
case MAT_OR:
bitwise_or(a, b, m);
break;
case MAT_XOR:
bitwise_xor(a, b, m);
break;
}
}