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
c8821bd9
Commit
c8821bd9
authored
Sep 25, 2013
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced manually new/delete by AutoBuffer
parent
0faac595
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
arithm.cpp
modules/ocl/src/arithm.cpp
+11
-11
No files found.
modules/ocl/src/arithm.cpp
View file @
c8821bd9
...
...
@@ -354,13 +354,11 @@ Scalar arithmetic_sum(const oclMat &src, int type = 0)
CV_Assert
(
groupnum
!=
0
);
int
vlen
=
src
.
oclchannels
()
==
3
?
12
:
8
,
dbsize
=
groupnum
*
vlen
;
Context
*
clCxt
=
src
.
clCxt
;
T
*
p
=
new
T
[
dbsize
];
AutoBuffer
<
T
>
_buf
(
dbsize
);
T
*
p
=
(
T
*
)
_buf
;
cl_mem
dstBuffer
=
openCLCreateBuffer
(
clCxt
,
CL_MEM_WRITE_ONLY
,
dbsize
*
sizeof
(
T
));
Scalar
s
;
s
.
val
[
0
]
=
0.0
;
s
.
val
[
1
]
=
0.0
;
s
.
val
[
2
]
=
0.0
;
s
.
val
[
3
]
=
0.0
;
Scalar
s
=
Scalar
::
all
(
0.0
);
arithmetic_sum_buffer_run
(
src
,
dstBuffer
,
vlen
,
groupnum
,
type
);
memset
(
p
,
0
,
dbsize
*
sizeof
(
T
));
...
...
@@ -370,7 +368,7 @@ Scalar arithmetic_sum(const oclMat &src, int type = 0)
for
(
int
j
=
0
;
j
<
src
.
oclchannels
();
j
++
,
i
++
)
s
.
val
[
j
]
+=
p
[
i
];
}
delete
[]
p
;
openCLFree
(
dstBuffer
);
return
s
;
}
...
...
@@ -1160,8 +1158,10 @@ void arithmetic_minMaxLoc(const oclMat &src, double *minVal, double *maxVal,
else
arithmetic_minMaxLoc_mask_run
(
src
,
mask
,
dstBuffer
,
vlen
,
groupnum
);
T
*
p
=
new
T
[
groupnum
*
vlen
*
4
];
AutoBuffer
<
T
>
_buf
(
groupnum
*
vlen
*
4
);
T
*
p
=
(
T
*
)
_buf
;
memset
(
p
,
0
,
dbsize
);
openCLReadBuffer
(
clCxt
,
dstBuffer
,
(
void
*
)
p
,
dbsize
);
for
(
int
i
=
0
;
i
<
vlen
*
(
int
)
groupnum
;
i
++
)
{
...
...
@@ -1197,7 +1197,6 @@ void arithmetic_minMaxLoc(const oclMat &src, double *minVal, double *maxVal,
else
maxLoc
->
x
=
maxLoc
->
y
=
-
1
;
}
delete
[]
p
;
openCLSafeCall
(
clReleaseMemObject
(
dstBuffer
));
}
...
...
@@ -1266,7 +1265,9 @@ int cv::ocl::countNonZero(const oclMat &src)
int
vlen
=
8
,
dbsize
=
groupnum
*
vlen
;
Context
*
clCxt
=
src
.
clCxt
;
string
kernelName
=
"arithm_op_nonzero"
;
int
*
p
=
new
int
[
dbsize
],
nonzero
=
0
;
AutoBuffer
<
int
>
_buf
(
dbsize
);
int
*
p
=
(
int
*
)
_buf
,
nonzero
=
0
;
cl_mem
dstBuffer
=
openCLCreateBuffer
(
clCxt
,
CL_MEM_WRITE_ONLY
,
dbsize
*
sizeof
(
int
));
arithmetic_countNonZero_run
(
src
,
dstBuffer
,
vlen
,
groupnum
,
kernelName
);
...
...
@@ -1275,7 +1276,6 @@ int cv::ocl::countNonZero(const oclMat &src)
for
(
int
i
=
0
;
i
<
dbsize
;
i
++
)
nonzero
+=
p
[
i
];
delete
[]
p
;
openCLSafeCall
(
clReleaseMemObject
(
dstBuffer
));
return
nonzero
;
}
...
...
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