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
50579d25
Commit
50579d25
authored
Nov 11, 2013
by
perping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Integral sum support cv_32f, sqsum support cv_64f.
parent
0ac61240
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
26 deletions
+58
-26
ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+3
-3
imgproc.cpp
modules/ocl/src/imgproc.cpp
+35
-15
imgproc_integral.cl
modules/ocl/src/opencl/imgproc_integral.cl
+0
-0
test_imgproc.cpp
modules/ocl/test/test_imgproc.cpp
+20
-8
No files found.
modules/ocl/include/opencv2/ocl/ocl.hpp
View file @
50579d25
...
@@ -861,10 +861,10 @@ namespace cv
...
@@ -861,10 +861,10 @@ namespace cv
CV_EXPORTS
void
warpPerspective
(
const
oclMat
&
src
,
oclMat
&
dst
,
const
Mat
&
M
,
Size
dsize
,
int
flags
=
INTER_LINEAR
);
CV_EXPORTS
void
warpPerspective
(
const
oclMat
&
src
,
oclMat
&
dst
,
const
Mat
&
M
,
Size
dsize
,
int
flags
=
INTER_LINEAR
);
//! computes the integral image and integral for the squared image
//! computes the integral image and integral for the squared image
// sum will
have CV_32S type, sqsum - CV32F type
// sum will
support CV_32S, CV_32F, sqsum - support CV32F, CV_64F
// supports only CV_8UC1 source type
// supports only CV_8UC1 source type
CV_EXPORTS
void
integral
(
const
oclMat
&
src
,
oclMat
&
sum
,
oclMat
&
sqsum
);
CV_EXPORTS
void
integral
(
const
oclMat
&
src
,
oclMat
&
sum
,
oclMat
&
sqsum
,
int
sdepth
=-
1
);
CV_EXPORTS
void
integral
(
const
oclMat
&
src
,
oclMat
&
sum
);
CV_EXPORTS
void
integral
(
const
oclMat
&
src
,
oclMat
&
sum
,
int
sdepth
=-
1
);
CV_EXPORTS
void
cornerHarris
(
const
oclMat
&
src
,
oclMat
&
dst
,
int
blockSize
,
int
ksize
,
double
k
,
int
bordertype
=
cv
::
BORDER_DEFAULT
);
CV_EXPORTS
void
cornerHarris
(
const
oclMat
&
src
,
oclMat
&
dst
,
int
blockSize
,
int
ksize
,
double
k
,
int
bordertype
=
cv
::
BORDER_DEFAULT
);
CV_EXPORTS
void
cornerHarris_dxdy
(
const
oclMat
&
src
,
oclMat
&
dst
,
oclMat
&
Dx
,
oclMat
&
Dy
,
CV_EXPORTS
void
cornerHarris_dxdy
(
const
oclMat
&
src
,
oclMat
&
dst
,
oclMat
&
Dx
,
oclMat
&
Dy
,
int
blockSize
,
int
ksize
,
double
k
,
int
bordertype
=
cv
::
BORDER_DEFAULT
);
int
blockSize
,
int
ksize
,
double
k
,
int
bordertype
=
cv
::
BORDER_DEFAULT
);
...
...
modules/ocl/src/imgproc.cpp
View file @
50579d25
...
@@ -783,7 +783,7 @@ namespace cv
...
@@ -783,7 +783,7 @@ namespace cv
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// integral
// integral
void
integral
(
const
oclMat
&
src
,
oclMat
&
sum
,
oclMat
&
sqsum
)
void
integral
(
const
oclMat
&
src
,
oclMat
&
sum
,
oclMat
&
sqsum
,
int
sdepth
)
{
{
CV_Assert
(
src
.
type
()
==
CV_8UC1
);
CV_Assert
(
src
.
type
()
==
CV_8UC1
);
if
(
!
src
.
clCxt
->
supportsFeature
(
ocl
::
FEATURE_CL_DOUBLE
)
&&
src
.
depth
()
==
CV_64F
)
if
(
!
src
.
clCxt
->
supportsFeature
(
ocl
::
FEATURE_CL_DOUBLE
)
&&
src
.
depth
()
==
CV_64F
)
...
@@ -792,6 +792,12 @@ namespace cv
...
@@ -792,6 +792,12 @@ namespace cv
return
;
return
;
}
}
int
depth
=
src
.
depth
();
if
(
sdepth
<=
0
)
sdepth
=
CV_32S
;
sdepth
=
CV_MAT_DEPTH
(
sdepth
);
int
type
=
CV_MAKE_TYPE
(
sdepth
,
1
);
int
vlen
=
4
;
int
vlen
=
4
;
int
offset
=
src
.
offset
/
vlen
;
int
offset
=
src
.
offset
/
vlen
;
int
pre_invalid
=
src
.
offset
%
vlen
;
int
pre_invalid
=
src
.
offset
%
vlen
;
...
@@ -799,17 +805,26 @@ namespace cv
...
@@ -799,17 +805,26 @@ namespace cv
oclMat
t_sum
,
t_sqsum
;
oclMat
t_sum
,
t_sqsum
;
int
w
=
src
.
cols
+
1
,
h
=
src
.
rows
+
1
;
int
w
=
src
.
cols
+
1
,
h
=
src
.
rows
+
1
;
int
depth
=
src
.
depth
()
==
CV_8U
?
CV_32S
:
CV_64F
;
int
type
=
CV_MAKE_TYPE
(
depth
,
1
);
char
build_option
[
250
];
if
(
Context
::
getContext
()
->
supportsFeature
(
ocl
::
FEATURE_CL_DOUBLE
))
{
t_sqsum
.
create
(
src
.
cols
,
src
.
rows
,
CV_64FC1
);
sqsum
.
create
(
h
,
w
,
CV_64FC1
);
sprintf
(
build_option
,
"-D TYPE=double -D TYPE4=double4 -D convert_TYPE4=convert_double4"
);
}
else
{
t_sqsum
.
create
(
src
.
cols
,
src
.
rows
,
CV_32FC1
);
sqsum
.
create
(
h
,
w
,
CV_32FC1
);
sprintf
(
build_option
,
"-D TYPE=float -D TYPE4=float4 -D convert_TYPE4=convert_float4"
);
}
t_sum
.
create
(
src
.
cols
,
src
.
rows
,
type
);
t_sum
.
create
(
src
.
cols
,
src
.
rows
,
type
);
sum
.
create
(
h
,
w
,
type
);
sum
.
create
(
h
,
w
,
type
);
t_sqsum
.
create
(
src
.
cols
,
src
.
rows
,
CV_32FC1
);
int
sum_offset
=
sum
.
offset
/
sum
.
elemSize
();
sqsum
.
create
(
h
,
w
,
CV_32FC1
);
int
sqsum_offset
=
sqsum
.
offset
/
sqsum
.
elemSize
();
int
sum_offset
=
sum
.
offset
/
vlen
;
int
sqsum_offset
=
sqsum
.
offset
/
vlen
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
src
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
src
.
data
));
...
@@ -821,8 +836,9 @@ namespace cv
...
@@ -821,8 +836,9 @@ namespace cv
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sqsum
.
step
));
size_t
gt
[
3
]
=
{((
vcols
+
1
)
/
2
)
*
256
,
1
,
1
},
lt
[
3
]
=
{
256
,
1
,
1
};
size_t
gt
[
3
]
=
{((
vcols
+
1
)
/
2
)
*
256
,
1
,
1
},
lt
[
3
]
=
{
256
,
1
,
1
};
openCLExecuteKernel
(
src
.
clCxt
,
&
imgproc_integral
,
"integral_cols"
,
gt
,
lt
,
args
,
-
1
,
depth
);
openCLExecuteKernel
(
src
.
clCxt
,
&
imgproc_integral
,
"integral_cols"
,
gt
,
lt
,
args
,
-
1
,
sdepth
,
build_option
);
args
.
clear
();
args
.
clear
();
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
t_sum
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
t_sum
.
data
));
...
@@ -832,15 +848,16 @@ namespace cv
...
@@ -832,15 +848,16 @@ namespace cv
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sqsum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sqsum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sqsum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sum_offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sum_offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sqsum_offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sqsum_offset
));
size_t
gt2
[
3
]
=
{
t_sum
.
cols
*
32
,
1
,
1
},
lt2
[
3
]
=
{
256
,
1
,
1
};
size_t
gt2
[
3
]
=
{
t_sum
.
cols
*
32
,
1
,
1
},
lt2
[
3
]
=
{
256
,
1
,
1
};
openCLExecuteKernel
(
src
.
clCxt
,
&
imgproc_integral
,
"integral_rows"
,
gt2
,
lt2
,
args
,
-
1
,
depth
);
openCLExecuteKernel
(
src
.
clCxt
,
&
imgproc_integral
,
"integral_rows"
,
gt2
,
lt2
,
args
,
-
1
,
sdepth
,
build_option
);
}
}
void
integral
(
const
oclMat
&
src
,
oclMat
&
sum
)
void
integral
(
const
oclMat
&
src
,
oclMat
&
sum
,
int
sdepth
)
{
{
CV_Assert
(
src
.
type
()
==
CV_8UC1
);
CV_Assert
(
src
.
type
()
==
CV_8UC1
);
int
vlen
=
4
;
int
vlen
=
4
;
...
@@ -848,10 +865,13 @@ namespace cv
...
@@ -848,10 +865,13 @@ namespace cv
int
pre_invalid
=
src
.
offset
%
vlen
;
int
pre_invalid
=
src
.
offset
%
vlen
;
int
vcols
=
(
pre_invalid
+
src
.
cols
+
vlen
-
1
)
/
vlen
;
int
vcols
=
(
pre_invalid
+
src
.
cols
+
vlen
-
1
)
/
vlen
;
if
(
sdepth
<=
0
)
sdepth
=
CV_32S
;
sdepth
=
CV_MAT_DEPTH
(
sdepth
);
int
type
=
CV_MAKE_TYPE
(
sdepth
,
1
);
oclMat
t_sum
;
oclMat
t_sum
;
int
w
=
src
.
cols
+
1
,
h
=
src
.
rows
+
1
;
int
w
=
src
.
cols
+
1
,
h
=
src
.
rows
+
1
;
int
depth
=
src
.
depth
()
==
CV_8U
?
CV_32S
:
CV_32F
;
int
type
=
CV_MAKE_TYPE
(
depth
,
1
);
t_sum
.
create
(
src
.
cols
,
src
.
rows
,
type
);
t_sum
.
create
(
src
.
cols
,
src
.
rows
,
type
);
sum
.
create
(
h
,
w
,
type
);
sum
.
create
(
h
,
w
,
type
);
...
@@ -867,7 +887,7 @@ namespace cv
...
@@ -867,7 +887,7 @@ namespace cv
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
t_sum
.
step
));
size_t
gt
[
3
]
=
{((
vcols
+
1
)
/
2
)
*
256
,
1
,
1
},
lt
[
3
]
=
{
256
,
1
,
1
};
size_t
gt
[
3
]
=
{((
vcols
+
1
)
/
2
)
*
256
,
1
,
1
},
lt
[
3
]
=
{
256
,
1
,
1
};
openCLExecuteKernel
(
src
.
clCxt
,
&
imgproc_integral_sum
,
"integral_sum_cols"
,
gt
,
lt
,
args
,
-
1
,
depth
);
openCLExecuteKernel
(
src
.
clCxt
,
&
imgproc_integral_sum
,
"integral_sum_cols"
,
gt
,
lt
,
args
,
-
1
,
s
depth
);
args
.
clear
();
args
.
clear
();
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
t_sum
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
t_sum
.
data
));
...
@@ -878,7 +898,7 @@ namespace cv
...
@@ -878,7 +898,7 @@ namespace cv
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sum
.
step
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sum_offset
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
sum_offset
));
size_t
gt2
[
3
]
=
{
t_sum
.
cols
*
32
,
1
,
1
},
lt2
[
3
]
=
{
256
,
1
,
1
};
size_t
gt2
[
3
]
=
{
t_sum
.
cols
*
32
,
1
,
1
},
lt2
[
3
]
=
{
256
,
1
,
1
};
openCLExecuteKernel
(
src
.
clCxt
,
&
imgproc_integral_sum
,
"integral_sum_rows"
,
gt2
,
lt2
,
args
,
-
1
,
depth
);
openCLExecuteKernel
(
src
.
clCxt
,
&
imgproc_integral_sum
,
"integral_sum_rows"
,
gt2
,
lt2
,
args
,
-
1
,
s
depth
);
}
}
/////////////////////// corner //////////////////////////////
/////////////////////// corner //////////////////////////////
...
...
modules/ocl/src/opencl/imgproc_integral.cl
View file @
50579d25
This diff is collapsed.
Click to expand it.
modules/ocl/test/test_imgproc.cpp
View file @
50579d25
...
@@ -275,23 +275,33 @@ OCL_TEST_P(CornerHarris, Mat)
...
@@ -275,23 +275,33 @@ OCL_TEST_P(CornerHarris, Mat)
//////////////////////////////////integral/////////////////////////////////////////////////
//////////////////////////////////integral/////////////////////////////////////////////////
typedef
ImgprocTestBase
Integral
;
struct
Integral
:
public
ImgprocTestBase
{
int
sdepth
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
blockSize
=
GET_PARAM
(
1
);
sdepth
=
GET_PARAM
(
2
);
useRoi
=
GET_PARAM
(
3
);
}
};
OCL_TEST_P
(
Integral
,
Mat1
)
OCL_TEST_P
(
Integral
,
Mat1
)
{
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
random_roi
();
random_roi
();
ocl
::
integral
(
gsrc_roi
,
gdst_roi
);
ocl
::
integral
(
gsrc_roi
,
gdst_roi
,
sdepth
);
integral
(
src_roi
,
dst_roi
);
integral
(
src_roi
,
dst_roi
,
sdepth
);
Near
();
Near
();
}
}
}
}
// TODO wrong output type
OCL_TEST_P
(
Integral
,
Mat2
)
OCL_TEST_P
(
Integral
,
DISABLED_Mat2
)
{
{
Mat
dst1
;
Mat
dst1
;
ocl
::
oclMat
gdst1
;
ocl
::
oclMat
gdst1
;
...
@@ -300,10 +310,12 @@ OCL_TEST_P(Integral, DISABLED_Mat2)
...
@@ -300,10 +310,12 @@ OCL_TEST_P(Integral, DISABLED_Mat2)
{
{
random_roi
();
random_roi
();
integral
(
src_roi
,
dst
1
,
dst_roi
);
integral
(
src_roi
,
dst
_roi
,
dst1
,
sdepth
);
ocl
::
integral
(
gsrc_roi
,
gdst
1
,
gdst_roi
);
ocl
::
integral
(
gsrc_roi
,
gdst
_roi
,
gdst1
,
sdepth
);
Near
();
Near
();
if
(
gdst1
.
clCxt
->
supportsFeature
(
ocl
::
FEATURE_CL_DOUBLE
))
EXPECT_MAT_NEAR
(
dst1
,
Mat
(
gdst1
),
0.
);
}
}
}
}
...
@@ -543,7 +555,7 @@ INSTANTIATE_TEST_CASE_P(Imgproc, CornerHarris, Combine(
...
@@ -543,7 +555,7 @@ INSTANTIATE_TEST_CASE_P(Imgproc, CornerHarris, Combine(
INSTANTIATE_TEST_CASE_P
(
Imgproc
,
Integral
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
Imgproc
,
Integral
,
Combine
(
Values
((
MatType
)
CV_8UC1
),
// TODO does not work with CV_32F, CV_64F
Values
((
MatType
)
CV_8UC1
),
// TODO does not work with CV_32F, CV_64F
Values
(
0
),
// not used
Values
(
0
),
// not used
Values
(
0
),
// not used
Values
(
(
MatType
)
CV_32SC1
,
(
MatType
)
CV_32FC1
),
Bool
()));
Bool
()));
INSTANTIATE_TEST_CASE_P
(
Imgproc
,
Threshold
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
Imgproc
,
Threshold
,
Combine
(
...
...
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