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, 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, 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. // Third party copyrights are property of their respective owners.
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
@ -51,23 +52,28 @@ namespace cv
enum enum
{ {
MAT_ADD, MAT_ADD = 1,
MAT_SUB, MAT_SUB,
MAT_MUL, MAT_MUL,
MAT_DIV MAT_DIV,
MAT_NOT,
MAT_AND,
MAT_OR,
MAT_XOR
}; };
class oclMatExpr class CV_EXPORTS oclMatExpr
{ {
public: public:
oclMatExpr() : a(oclMat()), b(oclMat()), op(0) {}
oclMatExpr(const oclMat& _a, const oclMat& _b, int _op) oclMatExpr(const oclMat& _a, const oclMat& _b, int _op)
: a(_a), b(_b), op(_op) {} : a(_a), b(_b), op(_op) {}
operator oclMat() const; operator oclMat() const;
void assign(oclMat& m) const; void assign(oclMat& m) const;
protected: protected:
int op;
oclMat a, b; oclMat a, b;
int op;
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
//////////////////////////////// oclMat //////////////////////////////// //////////////////////////////// oclMat ////////////////////////////////
@ -255,7 +261,7 @@ namespace cv
return *this; return *this;
} }
oclMat& oclMat::operator = (const oclMatExpr& expr) inline oclMat& oclMat::operator = (const oclMatExpr& expr)
{ {
expr.assign(*this); expr.assign(*this);
return *this; return *this;

View File

@ -463,10 +463,10 @@ namespace cv
CV_EXPORTS void bitwise_xor(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat()); CV_EXPORTS void bitwise_xor(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat());
//! Logical operators //! Logical operators
CV_EXPORTS oclMat operator ~ (const oclMat &src); CV_EXPORTS oclMatExpr operator ~ (const oclMat &src);
CV_EXPORTS oclMat operator | (const oclMat &src1, const oclMat &src2); CV_EXPORTS oclMatExpr operator | (const oclMat &src1, const oclMat &src2);
CV_EXPORTS oclMat operator & (const oclMat &src1, const oclMat &src2); CV_EXPORTS oclMatExpr operator & (const oclMat &src1, const oclMat &src2);
CV_EXPORTS oclMat operator ^ (const oclMat &src1, const oclMat &src2); CV_EXPORTS oclMatExpr operator ^ (const oclMat &src1, const oclMat &src2);
//! Mathematics operators //! Mathematics operators
CV_EXPORTS oclMatExpr operator + (const oclMat &src1, const oclMat &src2); CV_EXPORTS oclMatExpr operator + (const oclMat &src1, const oclMat &src2);

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); 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; return oclMatExpr(src, oclMat(), MAT_NOT);
bitwise_not(src, dst);
return dst;
} }
cv::ocl::oclMat cv::ocl::operator | (const oclMat &src1, const oclMat &src2) oclMatExpr cv::ocl::operator | (const oclMat &src1, const oclMat &src2)
{ {
oclMat dst; return oclMatExpr(src1, src2, MAT_OR);
bitwise_or(src1, src2, dst);
return dst;
} }
cv::ocl::oclMat cv::ocl::operator & (const oclMat &src1, const oclMat &src2) oclMatExpr cv::ocl::operator & (const oclMat &src1, const oclMat &src2)
{ {
oclMat dst; return oclMatExpr(src1, src2, MAT_AND);
bitwise_and(src1, src2, dst);
return dst;
} }
cv::ocl::oclMat cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2) oclMatExpr cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2)
{ {
oclMat dst; return oclMatExpr(src1, src2, MAT_XOR);
bitwise_xor(src1, src2, dst);
return dst;
} }
cv::ocl::oclMatExpr cv::ocl::operator + (const oclMat &src1, const oclMat &src2) cv::ocl::oclMatExpr cv::ocl::operator + (const oclMat &src1, const oclMat &src2)
{ {
oclMatExpr dst(src1, src2, cv::ocl::MAT_ADD); return oclMatExpr(src1, src2, cv::ocl::MAT_ADD);
return dst;
} }
cv::ocl::oclMatExpr cv::ocl::operator - (const oclMat &src1, const oclMat &src2) cv::ocl::oclMatExpr cv::ocl::operator - (const oclMat &src1, const oclMat &src2)
{ {
oclMatExpr dst(src1, src2, cv::ocl::MAT_SUB); return oclMatExpr(src1, src2, cv::ocl::MAT_SUB);
return dst;
} }
cv::ocl::oclMatExpr cv::ocl::operator * (const oclMat &src1, const oclMat &src2) cv::ocl::oclMatExpr cv::ocl::operator * (const oclMat &src1, const oclMat &src2)
{ {
oclMatExpr dst(src1, src2, cv::ocl::MAT_MUL); return oclMatExpr(src1, src2, cv::ocl::MAT_MUL);
return dst;
} }
cv::ocl::oclMatExpr cv::ocl::operator / (const oclMat &src1, const oclMat &src2) cv::ocl::oclMatExpr cv::ocl::operator / (const oclMat &src1, const oclMat &src2)
{ {
oclMatExpr dst(src1, src2, cv::ocl::MAT_DIV); return oclMatExpr(src1, src2, cv::ocl::MAT_DIV);
return dst;
} }
void oclMatExpr::assign(oclMat& m) const void oclMatExpr::assign(oclMat& m) const
@ -2193,6 +2181,18 @@ void oclMatExpr::assign(oclMat& m) const
case MAT_DIV: case MAT_DIV:
divide(a, b, m); divide(a, b, m);
break; 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;
} }
} }