Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
c6f6f9ab
Commit
c6f6f9ab
authored
Feb 18, 2013
by
Andrey Kamaev
Committed by
OpenCV Buildbot
Feb 18, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #451 from bitwangyaoyao:2.4_operator
parents
6503836b
9613135e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
28 deletions
+146
-28
matrix_operations.hpp
modules/ocl/include/opencv2/ocl/matrix_operations.hpp
+32
-2
ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+22
-10
arithm.cpp
modules/ocl/src/arithm.cpp
+67
-16
matrix_operations.cpp
modules/ocl/src/matrix_operations.cpp
+25
-0
No files found.
modules/ocl/include/opencv2/ocl/matrix_operations.hpp
View file @
c6f6f9ab
...
@@ -12,6 +12,7 @@
...
@@ -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,
...
@@ -48,9 +49,32 @@ namespace cv
...
@@ -48,9 +49,32 @@ namespace cv
namespace
ocl
namespace
ocl
{
{
////////////////////////////////////OpenCL kernel strings//////////////////////////
//extern const char *convertC3C4;
enum
{
MAT_ADD
=
1
,
MAT_SUB
,
MAT_MUL
,
MAT_DIV
,
MAT_NOT
,
MAT_AND
,
MAT_OR
,
MAT_XOR
};
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
)
{}
operator
oclMat
()
const
;
void
assign
(
oclMat
&
m
)
const
;
protected
:
oclMat
a
,
b
;
int
op
;
};
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//////////////////////////////// oclMat ////////////////////////////////
//////////////////////////////// oclMat ////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
@@ -237,6 +261,12 @@ namespace cv
...
@@ -237,6 +261,12 @@ namespace cv
return
*
this
;
return
*
this
;
}
}
inline
oclMat
&
oclMat
::
operator
=
(
const
oclMatExpr
&
expr
)
{
expr
.
assign
(
*
this
);
return
*
this
;
}
/* Fixme! To be supported in OpenCL later. */
/* Fixme! To be supported in OpenCL later. */
#if 0
#if 0
template <class T> inline oclMat::operator DevMem2D_<T>() const
template <class T> inline oclMat::operator DevMem2D_<T>() const
...
...
modules/ocl/include/opencv2/ocl/ocl.hpp
View file @
c6f6f9ab
...
@@ -125,6 +125,7 @@ namespace cv
...
@@ -125,6 +125,7 @@ namespace cv
Impl
*
impl
;
Impl
*
impl
;
};
};
class
CV_EXPORTS
oclMatExpr
;
//////////////////////////////// oclMat ////////////////////////////////
//////////////////////////////// oclMat ////////////////////////////////
class
CV_EXPORTS
oclMat
class
CV_EXPORTS
oclMat
{
{
...
@@ -158,7 +159,7 @@ namespace cv
...
@@ -158,7 +159,7 @@ namespace cv
oclMat
&
operator
=
(
const
oclMat
&
m
);
oclMat
&
operator
=
(
const
oclMat
&
m
);
//! assignment operator. Perfom blocking upload to device.
//! assignment operator. Perfom blocking upload to device.
oclMat
&
operator
=
(
const
Mat
&
m
);
oclMat
&
operator
=
(
const
Mat
&
m
);
oclMat
&
operator
=
(
const
oclMatExpr
&
expr
);
//! pefroms blocking upload data to oclMat.
//! pefroms blocking upload data to oclMat.
void
upload
(
const
cv
::
Mat
&
m
);
void
upload
(
const
cv
::
Mat
&
m
);
...
@@ -225,6 +226,11 @@ namespace cv
...
@@ -225,6 +226,11 @@ namespace cv
oclMat
operator
()(
Range
rowRange
,
Range
colRange
)
const
;
oclMat
operator
()(
Range
rowRange
,
Range
colRange
)
const
;
oclMat
operator
()(
const
Rect
&
roi
)
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
//! returns true if the oclMatrix data is continuous
// (i.e. when there are no gaps between successive rows).
// (i.e. when there are no gaps between successive rows).
// similar to CV_IS_oclMat_CONT(cvoclMat->type)
// similar to CV_IS_oclMat_CONT(cvoclMat->type)
...
@@ -297,6 +303,7 @@ namespace cv
...
@@ -297,6 +303,7 @@ namespace cv
int
wholecols
;
int
wholecols
;
};
};
///////////////////// mat split and merge /////////////////////////////////
///////////////////// mat split and merge /////////////////////////////////
//! Compose a multi-channel array from several single-channel arrays
//! Compose a multi-channel array from several single-channel arrays
// Support all types
// Support all types
...
@@ -460,18 +467,23 @@ namespace cv
...
@@ -460,18 +467,23 @@ namespace cv
// supports all types
// supports all types
CV_EXPORTS
void
bitwise_xor
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
=
oclMat
());
CV_EXPORTS
void
bitwise_xor
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
const
oclMat
&
mask
=
oclMat
());
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
());
//! computes convolution of two images
//! Logical operators
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
);
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
);
//! computes convolution of two images
//! support only CV_32FC1 type
//! support only CV_32FC1 type
CV_EXPORTS
void
convolve
(
const
oclMat
&
image
,
const
oclMat
&
temp1
,
oclMat
&
result
);
CV_EXPORTS
void
convolve
(
const
oclMat
&
image
,
const
oclMat
&
temp1
,
oclMat
&
result
);
//! 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
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 ////////////////////////////////
//////////////////////////////// Filter Engine ////////////////////////////////
...
...
modules/ocl/src/arithm.cpp
View file @
c6f6f9ab
...
@@ -12,6 +12,7 @@
...
@@ -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.
//
//
// @Authors
// @Authors
...
@@ -2124,32 +2125,82 @@ void cv::ocl::bitwise_xor(const oclMat &src1, const Scalar &src2, oclMat &dst, c
...
@@ -2124,32 +2125,82 @@ 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
)
{
return
oclMatExpr
(
src1
,
src2
,
cv
::
ocl
::
MAT_ADD
);
}
cv
::
ocl
::
oclMatExpr
cv
::
ocl
::
operator
-
(
const
oclMat
&
src1
,
const
oclMat
&
src2
)
{
return
oclMatExpr
(
src1
,
src2
,
cv
::
ocl
::
MAT_SUB
);
}
cv
::
ocl
::
oclMatExpr
cv
::
ocl
::
operator
*
(
const
oclMat
&
src1
,
const
oclMat
&
src2
)
{
return
oclMatExpr
(
src1
,
src2
,
cv
::
ocl
::
MAT_MUL
);
}
cv
::
ocl
::
oclMatExpr
cv
::
ocl
::
operator
/
(
const
oclMat
&
src1
,
const
oclMat
&
src2
)
{
return
oclMatExpr
(
src1
,
src2
,
cv
::
ocl
::
MAT_DIV
);
}
void
oclMatExpr
::
assign
(
oclMat
&
m
)
const
{
switch
(
op
)
{
case
MAT_ADD
:
add
(
a
,
b
,
m
);
break
;
case
MAT_SUB
:
subtract
(
a
,
b
,
m
);
break
;
case
MAT_MUL
:
multiply
(
a
,
b
,
m
);
break
;
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
;
}
}
oclMatExpr
::
operator
oclMat
()
const
{
oclMat
m
;
assign
(
m
);
return
m
;
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
...
...
modules/ocl/src/matrix_operations.cpp
View file @
c6f6f9ab
...
@@ -12,10 +12,12 @@
...
@@ -12,10 +12,12 @@
//
//
// 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.
//
//
// @Authors
// @Authors
// Niko Li, newlife20080214@gmail.com
// Niko Li, newlife20080214@gmail.com
// Yao Wang, bitwangyaoyao@gmail.com
//
//
// Redistribution and use in source and binary forms, with or without modification,
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
// are permitted provided that the following conditions are met:
...
@@ -1020,4 +1022,27 @@ void cv::ocl::oclMat::release()
...
@@ -1020,4 +1022,27 @@ void cv::ocl::oclMat::release()
refcount
=
0
;
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) */
#endif
/* !defined (HAVE_OPENCL) */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment