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
311a7233
Commit
311a7233
authored
Sep 24, 2013
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed comments from filtering.cpp and imgproc.cpp in ocl module
parent
bd36e556
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
107 deletions
+5
-107
filtering.cpp
modules/ocl/src/filtering.cpp
+3
-78
imgproc.cpp
modules/ocl/src/imgproc.cpp
+2
-29
No files found.
modules/ocl/src/filtering.cpp
View file @
311a7233
...
...
@@ -130,7 +130,7 @@ public:
{
Size
src_size
=
src
.
size
();
// Delete those two clause below which exist before, However, the result is al
os
correct
// Delete those two clause below which exist before, However, the result is al
so
correct
// dst.create(src_size, src.type());
// dst = Scalar(0.0);
...
...
@@ -394,23 +394,8 @@ public:
{
Filter2DEngine_GPU
::
apply
(
src
,
dst
);
//if (iters > 1)
//{
// Size wholesize;
// Point ofs;
// dst.locateROI(wholesize,ofs);
// int rows = dst.rows, cols = dst.cols;
// dst.adjustROI(ofs.y,-ofs.y-rows+dst.wholerows,ofs.x,-ofs.x-cols+dst.wholecols);
// dst.copyTo(morfBuf);
// dst.adjustROI(-ofs.y,ofs.y+rows-dst.wholerows,-ofs.x,ofs.x+cols-dst.wholecols);
// morfBuf.adjustROI(-ofs.y,ofs.y+rows-dst.wholerows,-ofs.x,ofs.x+cols-dst.wholecols);
// //morfBuf.create(src.size(),src.type());
// //Filter2DEngine_GPU::apply(dst, morfBuf);
// //morfBuf.copyTo(dst);
//}
for
(
int
i
=
1
;
i
<
iters
;
++
i
)
{
//dst.swap(morfBuf);
Size
wholesize
;
Point
ofs
;
dst
.
locateROI
(
wholesize
,
ofs
);
...
...
@@ -720,24 +705,16 @@ public:
virtual
void
apply
(
const
oclMat
&
src
,
oclMat
&
dst
,
Rect
roi
=
Rect
(
0
,
0
,
-
1
,
-
1
))
{
Size
src_size
=
src
.
size
();
//int src_type = src.type();
int
cn
=
src
.
oclchannels
();
//dst.create(src_size, src_type);
//dst = Scalar(0.0);
//dstBuf.create(src_size, src_type);
dstBuf
.
create
(
src_size
.
height
+
ksize
.
height
-
1
,
src_size
.
width
,
CV_MAKETYPE
(
CV_32F
,
cn
));
//dstBuf = Scalar(0.0);
normalizeROI
(
roi
,
ksize
,
anchor
,
src_size
);
srcROI
=
src
(
roi
);
dstROI
=
dst
(
roi
);
//dstBufROI = dstBuf(roi);
(
*
rowFilter
)(
srcROI
,
dstBuf
);
//Mat rm(dstBufROI);
//std::cout << "rm " << rm << endl;
(
*
columnFilter
)(
dstBuf
,
dstROI
);
}
...
...
@@ -1324,11 +1301,8 @@ void linearColumnFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_ker
CV_Assert
(
src
.
oclchannels
()
==
dst
.
oclchannels
());
CV_Assert
(
ksize
==
(
anchor
<<
1
)
+
1
);
int
src_pix_per_row
,
dst_pix_per_row
;
//int src_offset_x, src_offset_y;
int
dst_offset_in_pixel
;
src_pix_per_row
=
src
.
step
/
src
.
elemSize
();
//src_offset_x = (src.offset % src.step) / src.elemSize();
//src_offset_y = src.offset / src.step;
dst_pix_per_row
=
dst
.
step
/
dst
.
elemSize
();
dst_offset_in_pixel
=
dst
.
offset
/
dst
.
elemSize
();
...
...
@@ -1340,8 +1314,6 @@ void linearColumnFilter_gpu(const oclMat &src, const oclMat &dst, oclMat mat_ker
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src
.
wholecols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src
.
wholerows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
src_pix_per_row
));
//args.push_back(make_pair(sizeof(cl_int),(void*)&src_offset_x));
//args.push_back(make_pair(sizeof(cl_int),(void*)&src_offset_y));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst_pix_per_row
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
),
(
void
*
)
&
dst_offset_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
mat_kernel
.
data
));
...
...
@@ -1360,23 +1332,11 @@ Ptr<BaseColumnFilter_GPU> cv::ocl::getLinearColumnFilter_GPU(int /*bufType*/, in
linearColumnFilter_gpu
<
int
>
,
linearColumnFilter_gpu
<
float
>
};
/*
CV_Assert(dstType == CV_8UC4 || dstType == CV_8SC4 || dstType == CV_16UC2 ||
dstType == CV_16SC2 || dstType == CV_32SC1 || dstType == CV_32FC1);
CV_Assert(bufType == CV_8UC4 || bufType == CV_8SC4 || bufType == CV_16UC2 ||
bufType == CV_16SC2 || bufType == CV_32SC1 || bufType == CV_32FC1);
Mat temp(columnKernel.size(), CV_32SC1);
columnKernel.convertTo(temp, CV_32SC1);
Mat cont_krnl = temp.reshape(1, 1);
*/
Mat
temp
=
columnKernel
.
reshape
(
1
,
1
);
oclMat
mat_kernel
(
temp
);
int
ksize
=
temp
.
cols
;
//CV_Assert(ksize < 16);
normalizeAnchor
(
anchor
,
ksize
);
return
Ptr
<
BaseColumnFilter_GPU
>
(
new
GpuLinearColumnFilter
(
ksize
,
anchor
,
mat_kernel
,
...
...
@@ -1414,11 +1374,8 @@ void cv::ocl::sepFilter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat
}
if
(
ddepth
<
0
)
{
ddepth
=
src
.
depth
();
}
//CV_Assert(ddepth == src.depth());
dst
.
create
(
src
.
size
(),
CV_MAKETYPE
(
ddepth
,
src
.
channels
()));
Ptr
<
FilterEngine_GPU
>
f
=
createSeparableLinearFilter_GPU
(
src
.
type
(),
dst
.
type
(),
kernelX
,
kernelY
,
anchor
,
delta
,
bordertype
);
...
...
@@ -1445,18 +1402,10 @@ void cv::ocl::Sobel(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy,
// usually the smoothing part is the slowest to compute,
// so try to scale it instead of the faster differenciating part
if
(
dx
==
0
)
{
kx
*=
scale
;
}
else
{
ky
*=
scale
;
}
}
// Mat kx_, ky_;
//ky.convertTo(ky_,CV_32S,1<<8);
//kx.convertTo(kx_,CV_32S,1<<8);
sepFilter2D
(
src
,
dst
,
ddepth
,
kx
,
ky
,
Point
(
-
1
,
-
1
),
delta
,
borderType
);
}
...
...
@@ -1471,18 +1420,10 @@ void cv::ocl::Scharr(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy,
// usually the smoothing part is the slowest to compute,
// so try to scale it instead of the faster differenciating part
if
(
dx
==
0
)
{
kx
*=
scale
;
}
else
{
ky
*=
scale
;
}
}
// Mat kx_, ky_;
//ky.convertTo(ky_,CV_32S,1<<8);
//kx.convertTo(kx_,CV_32S,1<<8);
sepFilter2D
(
src
,
dst
,
ddepth
,
kx
,
ky
,
Point
(
-
1
,
-
1
),
delta
,
bordertype
);
}
...
...
@@ -1505,9 +1446,7 @@ void cv::ocl::Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize, d
Mat
kernel
(
3
,
3
,
CV_32S
,
(
void
*
)
K
[
ksize
==
3
]);
if
(
scale
!=
1
)
{
kernel
*=
scale
;
}
filter2D
(
src
,
dst
,
ddepth
,
kernel
,
Point
(
-
1
,
-
1
));
}
...
...
@@ -1526,14 +1465,10 @@ Ptr<FilterEngine_GPU> cv::ocl::createGaussianFilter_GPU(int type, Size ksize, do
// automatic detection of kernel size from sigma
if
(
ksize
.
width
<=
0
&&
sigma1
>
0
)
{
ksize
.
width
=
cvRound
(
sigma1
*
(
depth
==
CV_8U
?
3
:
4
)
*
2
+
1
)
|
1
;
}
if
(
ksize
.
height
<=
0
&&
sigma2
>
0
)
{
ksize
.
height
=
cvRound
(
sigma2
*
(
depth
==
CV_8U
?
3
:
4
)
*
2
+
1
)
|
1
;
}
CV_Assert
(
ksize
.
width
>
0
&&
ksize
.
width
%
2
==
1
&&
ksize
.
height
>
0
&&
ksize
.
height
%
2
==
1
);
...
...
@@ -1544,17 +1479,10 @@ Ptr<FilterEngine_GPU> cv::ocl::createGaussianFilter_GPU(int type, Size ksize, do
Mat
ky
;
if
(
ksize
.
height
==
ksize
.
width
&&
std
::
abs
(
sigma1
-
sigma2
)
<
DBL_EPSILON
)
{
ky
=
kx
;
}
else
{
ky
=
getGaussianKernel
(
ksize
.
height
,
sigma2
,
std
::
max
(
depth
,
CV_32F
));
}
//Mat kx_, ky_;
//kx.convertTo(kx_,CV_32S,1<<8);
//ky.convertTo(ky_,CV_32S,1<<8);
return
createSeparableLinearFilter_GPU
(
type
,
type
,
kx
,
ky
,
Point
(
-
1
,
-
1
),
0.0
,
bordertype
);
}
...
...
@@ -1585,15 +1513,11 @@ void cv::ocl::GaussianBlur(const oclMat &src, oclMat &dst, Size ksize, double si
if
(
bordertype
!=
BORDER_CONSTANT
)
{
if
(
src
.
rows
==
1
)
{
ksize
.
height
=
1
;
}
if
(
src
.
cols
==
1
)
{
ksize
.
width
=
1
;
}
}
Ptr
<
FilterEngine_GPU
>
f
=
createGaussianFilter_GPU
(
src
.
type
(),
ksize
,
sigma1
,
sigma2
,
bordertype
);
f
->
apply
(
src
,
dst
);
...
...
@@ -1618,6 +1542,7 @@ void cv::ocl::adaptiveBilateralFilter(const oclMat& src, oclMat& dst, Size ksize
{
lut
.
at
<
float
>
(
idx
++
)
=
sigma2
/
(
sigma2
+
x
*
x
+
y
*
y
);
}
oclMat
dlut
(
lut
);
int
depth
=
src
.
depth
();
int
cn
=
src
.
oclchannels
();
...
...
modules/ocl/src/imgproc.cpp
View file @
311a7233
...
...
@@ -244,9 +244,6 @@ namespace cv
kernelName
=
"remapNNF1Constant"
;
}
//int channels = dst.oclchannels();
//int depth = dst.depth();
//int type = src.type();
size_t
blkSizeX
=
16
,
blkSizeY
=
16
;
size_t
glbSizeX
;
int
cols
=
dst
.
cols
;
...
...
@@ -499,21 +496,13 @@ namespace cv
openCLExecuteKernel
(
clCxt
,
&
imgproc_median
,
kernelName
,
globalThreads
,
localThreads
,
args
,
src
.
oclchannels
(),
src
.
depth
());
}
else
{
CV_Error
(
CV_StsUnsupportedFormat
,
"Non-supported filter length"
);
//string kernelName = "medianFilter";
//args.push_back( make_pair( sizeof(cl_int),(void*)&m));
//openCLExecuteKernel(clCxt,&imgproc_median,kernelName,globalThreads,localThreads,args,src.oclchannels(),-1);
}
}
////////////////////////////////////////////////////////////////////////
// copyMakeBorder
void
copyMakeBorder
(
const
oclMat
&
src
,
oclMat
&
dst
,
int
top
,
int
bottom
,
int
left
,
int
right
,
int
bordertype
,
const
Scalar
&
scalar
)
{
//CV_Assert(src.oclchannels() != 2);
CV_Assert
(
top
>=
0
&&
bottom
>=
0
&&
left
>=
0
&&
right
>=
0
);
if
((
dst
.
cols
!=
dst
.
wholecols
)
||
(
dst
.
rows
!=
dst
.
wholerows
))
//has roi
{
...
...
@@ -529,10 +518,12 @@ namespace cv
{
CV_Assert
((
src
.
cols
>=
left
)
&&
(
src
.
cols
>=
right
)
&&
(
src
.
rows
>=
top
)
&&
(
src
.
rows
>=
bottom
));
}
if
(
bordertype
==
cv
::
BORDER_REFLECT_101
)
{
CV_Assert
((
src
.
cols
>
left
)
&&
(
src
.
cols
>
right
)
&&
(
src
.
rows
>
top
)
&&
(
src
.
rows
>
bottom
));
}
dst
.
create
(
src
.
rows
+
top
+
bottom
,
src
.
cols
+
left
+
right
,
src
.
type
());
int
srcStep
=
src
.
step1
()
/
src
.
oclchannels
();
int
dstStep
=
dst
.
step1
()
/
dst
.
oclchannels
();
...
...
@@ -732,19 +723,6 @@ namespace cv
}
openCLExecuteKernel
(
src
.
clCxt
,
&
imgproc_copymakeboder
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
,
compile_option
);
//uchar* cputemp=new uchar[32*dst.wholerows];
////int* cpudata=new int[this->step*this->wholerows/sizeof(int)];
//openCLSafeCall(clEnqueueReadBuffer(src.clCxt->impl->clCmdQueue, (cl_mem)dst.data, CL_TRUE,
// 0, 32*dst.wholerows, cputemp, 0, NULL, NULL));
//for(int i=0;i<dst.wholerows;i++)
//{
// for(int j=0;j<dst.wholecols;j++)
// {
// cout<< (int)cputemp[i*32+j]<<" ";
// }
// cout<<endl;
//}
//delete []cputemp;
}
////////////////////////////////////////////////////////////////////////
...
...
@@ -1286,11 +1264,6 @@ namespace cv
if
(
src
.
depth
()
!=
CV_8U
||
src
.
oclchannels
()
!=
4
)
CV_Error
(
CV_StsUnsupportedFormat
,
"Only 8-bit, 4-channel images are supported"
);
// if(!src.clCxt->supportsFeature(Context::CL_DOUBLE))
// {
// CV_Error( CV_GpuNotSupported, "Selected device doesn't support double, so a deviation exists.\nIf the accuracy is acceptable, the error can be ignored.\n");
// }
dst
.
create
(
src
.
size
(),
CV_8UC4
);
if
(
!
(
criteria
.
type
&
TermCriteria
::
MAX_ITER
)
)
...
...
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