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
d9489bbe
Commit
d9489bbe
authored
Dec 01, 2010
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug in gpu::cornerHarris and gpu::cornerMinEigenVal
parent
db5cce88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
23 deletions
+41
-23
imgproc.cu
modules/gpu/src/cuda/imgproc.cu
+16
-10
imgproc_gpu.cpp
tests/gpu/src/imgproc_gpu.cpp
+25
-13
No files found.
modules/gpu/src/cuda/imgproc.cu
View file @
d9489bbe
...
...
@@ -478,10 +478,13 @@ namespace cv { namespace gpu { namespace imgproc
float b = 0.f;
float c = 0.f;
const unsigned int j_begin = max(x - block_size, 0);
const unsigned int i_begin = max(y - block_size, 0);
const unsigned int j_end = min(x + block_size + 1, cols);
const unsigned int i_end = min(y + block_size + 1, rows);
int offset1 = -(block_size / 2);
int offset2 = offset1 + block_size;
unsigned int j_begin = max(x + offset1, 0);
unsigned int i_begin = max(y + offset1, 0);
unsigned int j_end = min(x + offset2, cols);
unsigned int i_end = min(y + offset2, rows);
for (unsigned int i = i_begin; i < i_end; ++i)
{
...
...
@@ -509,7 +512,7 @@ namespace cv { namespace gpu { namespace imgproc
dim3 threads(32, 8);
dim3 grid(divUp(cols, threads.x), divUp(rows, threads.y));
cornerHarris_kernel<<<grid, threads>>>(cols, rows, block_size
/ 2
, k, Dx, Dy, dst);
cornerHarris_kernel<<<grid, threads>>>(cols, rows, block_size, k, Dx, Dy, dst);
cudaSafeCall(cudaThreadSynchronize());
}
...
...
@@ -527,10 +530,13 @@ namespace cv { namespace gpu { namespace imgproc
float b = 0.f;
float c = 0.f;
const unsigned int j_begin = max(x - block_size, 0);
const unsigned int i_begin = max(y - block_size, 0);
const unsigned int j_end = min(x + block_size + 1, cols);
const unsigned int i_end = min(y + block_size + 1, rows);
int offset1 = -(block_size / 2);
int offset2 = offset1 + block_size;
unsigned int j_begin = max(x + offset1, 0);
unsigned int i_begin = max(y + offset1, 0);
unsigned int j_end = min(x + offset2, cols);
unsigned int i_end = min(y + offset2, rows);
for (unsigned int i = i_begin; i < i_end; ++i)
{
...
...
@@ -560,7 +566,7 @@ namespace cv { namespace gpu { namespace imgproc
dim3 threads(32, 8);
dim3 grid(divUp(cols, threads.x), divUp(rows, threads.y));
cornerMinEigenVal_kernel<<<grid, threads>>>(cols, rows, block_size
/ 2
, Dx, Dy, dst);
cornerMinEigenVal_kernel<<<grid, threads>>>(cols, rows, block_size, Dx, Dy, dst);
cudaSafeCall(cudaThreadSynchronize());
}
}}}
tests/gpu/src/imgproc_gpu.cpp
View file @
d9489bbe
...
...
@@ -614,12 +614,11 @@ struct CV_GpuCornerHarrisTest: CvTest
{
try
{
int
rows
=
1
+
rand
()
%
300
,
cols
=
1
+
rand
()
%
300
;
if
(
!
compareToCpuTest
(
rows
,
cols
,
CV_32F
,
1
+
rand
()
%
5
,
-
1
))
return
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
rows
=
1
+
rand
()
%
300
;
cols
=
1
+
rand
()
%
300
;
int
rows
=
1
+
rand
()
%
300
,
cols
=
1
+
rand
()
%
300
;
if
(
!
compareToCpuTest
(
rows
,
cols
,
CV_32F
,
1
+
rand
()
%
5
,
1
+
2
*
(
rand
()
%
4
)))
return
;
if
(
!
compareToCpuTest
(
rows
,
cols
,
CV_32F
,
1
+
rand
()
%
5
,
-
1
))
return
;
}
}
catch
(
const
Exception
&
e
)
...
...
@@ -645,14 +644,21 @@ struct CV_GpuCornerHarrisTest: CvTest
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
cornerHarris
(
cv
::
gpu
::
GpuMat
(
src
),
dst
,
blockSize
,
apertureSize
,
k
);
int
asize
=
apertureSize
>
0
?
apertureSize
:
3
;
cv
::
Mat
dsth
=
dst
;
for
(
int
i
=
apertureSize
+
2
;
i
<
dst
.
rows
-
apertureSize
-
2
;
++
i
)
for
(
int
i
=
max
(
blockSize
,
asize
)
+
2
;
i
<
dst
.
rows
-
max
(
blockSize
,
asize
)
-
2
;
++
i
)
{
for
(
int
j
=
apertureSize
+
2
;
j
<
dst
.
cols
-
apertureSize
-
2
;
++
j
)
for
(
int
j
=
max
(
blockSize
,
asize
)
+
2
;
j
<
dst
.
cols
-
max
(
blockSize
,
asize
)
-
2
;
++
j
)
{
float
a
=
dst_gold
.
at
<
float
>
(
i
,
j
);
float
b
=
dsth
.
at
<
float
>
(
i
,
j
);
if
(
fabs
(
a
-
b
)
>
1e-3
f
)
return
false
;
if
(
fabs
(
a
-
b
)
>
1e-3
f
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"%d %d %f %f %d
\n
"
,
i
,
j
,
a
,
b
,
apertureSize
);
ts
->
set_failed_test_info
(
CvTS
::
FAIL_INVALID_OUTPUT
);
return
false
;
};
}
}
return
true
;
...
...
@@ -670,11 +676,10 @@ struct CV_GpuCornerMinEigenValTest: CvTest
{
try
{
int
rows
=
1
+
rand
()
%
300
,
cols
=
1
+
rand
()
%
300
;
if
(
!
compareToCpuTest
(
rows
,
cols
,
CV_32F
,
1
+
rand
()
%
5
,
-
1
))
return
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
rows
=
1
+
rand
()
%
300
;
cols
=
1
+
rand
()
%
300
;
int
rows
=
1
+
rand
()
%
300
,
cols
=
1
+
rand
()
%
300
;
if
(
!
compareToCpuTest
(
rows
,
cols
,
CV_32F
,
1
+
rand
()
%
5
,
-
1
))
return
;
if
(
!
compareToCpuTest
(
rows
,
cols
,
CV_32F
,
1
+
rand
()
%
5
,
1
+
2
*
(
rand
()
%
4
)))
return
;
}
}
...
...
@@ -700,14 +705,21 @@ struct CV_GpuCornerMinEigenValTest: CvTest
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
cornerMinEigenVal
(
cv
::
gpu
::
GpuMat
(
src
),
dst
,
blockSize
,
apertureSize
);
int
asize
=
apertureSize
>
0
?
apertureSize
:
3
;
cv
::
Mat
dsth
=
dst
;
for
(
int
i
=
apertureSize
+
2
;
i
<
dst
.
rows
-
apertureSize
-
2
;
++
i
)
for
(
int
i
=
max
(
blockSize
,
asize
)
+
2
;
i
<
dst
.
rows
-
max
(
blockSize
,
asize
)
-
2
;
++
i
)
{
for
(
int
j
=
apertureSize
+
2
;
j
<
dst
.
cols
-
apertureSize
-
2
;
++
j
)
for
(
int
j
=
max
(
blockSize
,
asize
)
+
2
;
j
<
dst
.
cols
-
max
(
blockSize
,
asize
)
-
2
;
++
j
)
{
float
a
=
dst_gold
.
at
<
float
>
(
i
,
j
);
float
b
=
dsth
.
at
<
float
>
(
i
,
j
);
if
(
fabs
(
a
-
b
)
>
1e-3
f
)
return
false
;
if
(
fabs
(
a
-
b
)
>
1e-3
f
)
{
ts
->
printf
(
CvTS
::
CONSOLE
,
"%d %d %f %f %d %d
\n
"
,
i
,
j
,
a
,
b
,
apertureSize
,
blockSize
);
ts
->
set_failed_test_info
(
CvTS
::
FAIL_INVALID_OUTPUT
);
return
false
;
};
}
}
return
true
;
...
...
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