From: yao Date: Fri, 8 Feb 2013 03:41:46 +0000 (+0800) Subject: add +-*/ operators to oclMat X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1314^2~1503^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b365f6aa564766c236189d577d0c33b1209ca35;p=platform%2Fupstream%2Fopencv.git add +-*/ operators to oclMat --- diff --git a/modules/ocl/include/opencv2/ocl/ocl.hpp b/modules/ocl/include/opencv2/ocl/ocl.hpp index 5e4b143..e86207d 100644 --- a/modules/ocl/include/opencv2/ocl/ocl.hpp +++ b/modules/ocl/include/opencv2/ocl/ocl.hpp @@ -219,6 +219,11 @@ namespace cv oclMat operator()( Range rowRange, Range colRange ) const; oclMat operator()( const Rect &roi ) const; + oclMat& operator+=( const oclMat& m ); + oclMat& operator-=( const oclMat& m ); + oclMat& operator*=( const oclMat& m ); + oclMat& operator/=( const oclMat& m ); + //! returns true if the oclMatrix data is continuous // (i.e. when there are no gaps between successive rows). // similar to CV_IS_oclMat_CONT(cvoclMat->type) @@ -468,6 +473,12 @@ namespace cv CV_EXPORTS oclMat operator ^ (const oclMat &src1, const oclMat &src2); CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0); + //! Mathematics operators + 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 oclMat operator / (const oclMat &src1, const oclMat &src2); + //////////////////////////////// Filter Engine //////////////////////////////// /*! diff --git a/modules/ocl/src/arithm.cpp b/modules/ocl/src/arithm.cpp index de8f434..e43cf50 100644 --- a/modules/ocl/src/arithm.cpp +++ b/modules/ocl/src/arithm.cpp @@ -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. // // @Authors @@ -2152,6 +2153,34 @@ cv::ocl::oclMat cv::ocl::operator ^ (const oclMat &src1, const oclMat &src2) return dst; } +cv::ocl::oclMat cv::ocl::operator + (const oclMat &src1, const oclMat &src2) +{ + oclMat dst; + add(src1, src2, dst); + return dst; +} + +cv::ocl::oclMat cv::ocl::operator - (const oclMat &src1, const oclMat &src2) +{ + oclMat dst; + subtract(src1, src2, dst); + return dst; +} + +cv::ocl::oclMat cv::ocl::operator * (const oclMat &src1, const oclMat &src2) +{ + oclMat dst; + multiply(src1, src2, dst); + return dst; +} + +cv::ocl::oclMat cv::ocl::operator / (const oclMat &src1, const oclMat &src2) +{ + oclMat dst; + divide(src1, src2, dst); + return dst; +} + ////////////////////////////////////////////////////////////////////////////// /////////////////////////////// transpose //////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// diff --git a/modules/ocl/src/matrix_operations.cpp b/modules/ocl/src/matrix_operations.cpp index b2b8b5f..7b90218 100644 --- a/modules/ocl/src/matrix_operations.cpp +++ b/modules/ocl/src/matrix_operations.cpp @@ -12,10 +12,12 @@ // // 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. // // @Authors // Niko Li, newlife20080214@gmail.com +// Yao Wang, bitwangyaoyao@gmail.com // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: @@ -1020,4 +1022,27 @@ void cv::ocl::oclMat::release() refcount = 0; } +oclMat& cv::ocl::oclMat::operator+=( const oclMat& m ) +{ + add(*this, m, *this); + return *this; +} + +oclMat& cv::ocl::oclMat::operator-=( const oclMat& m ) +{ + subtract(*this, m, *this); + return *this; +} + +oclMat& cv::ocl::oclMat::operator*=( const oclMat& m ) +{ + multiply(*this, m, *this); + return *this; +} + +oclMat& cv::ocl::oclMat::operator/=( const oclMat& m ) +{ + divide(*this, m, *this); + return *this; +} #endif /* !defined (HAVE_OPENCL) */