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
8d97d959
Commit
8d97d959
authored
Mar 29, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated GPU version of TVL1
parent
6062601c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
gpu.hpp
modules/gpu/include/opencv2/gpu.hpp
+2
-0
perf_video.cpp
modules/gpu/perf/perf_video.cpp
+3
-0
tvl1flow.cpp
modules/gpu/src/tvl1flow.cpp
+9
-8
test_optflow.cpp
modules/gpu/test/test_optflow.cpp
+5
-2
No files found.
modules/gpu/include/opencv2/gpu.hpp
View file @
8d97d959
...
@@ -1810,6 +1810,8 @@ public:
...
@@ -1810,6 +1810,8 @@ public:
*/
*/
int
iterations
;
int
iterations
;
double
scaleStep
;
bool
useInitialFlow
;
bool
useInitialFlow
;
private
:
private
:
...
...
modules/gpu/perf/perf_video.cpp
View file @
8d97d959
...
@@ -434,6 +434,9 @@ PERF_TEST_P(ImagePair, Video_OpticalFlowDual_TVL1,
...
@@ -434,6 +434,9 @@ PERF_TEST_P(ImagePair, Video_OpticalFlowDual_TVL1,
cv
::
Mat
flow
;
cv
::
Mat
flow
;
cv
::
Ptr
<
cv
::
DenseOpticalFlow
>
alg
=
cv
::
createOptFlow_DualTVL1
();
cv
::
Ptr
<
cv
::
DenseOpticalFlow
>
alg
=
cv
::
createOptFlow_DualTVL1
();
alg
->
set
(
"medianFiltering"
,
1
);
alg
->
set
(
"innerIterations"
,
1
);
alg
->
set
(
"outerIterations"
,
300
);
TEST_CYCLE
()
alg
->
calc
(
frame0
,
frame1
,
flow
);
TEST_CYCLE
()
alg
->
calc
(
frame0
,
frame1
,
flow
);
...
...
modules/gpu/src/tvl1flow.cpp
View file @
8d97d959
...
@@ -63,6 +63,7 @@ cv::gpu::OpticalFlowDual_TVL1_GPU::OpticalFlowDual_TVL1_GPU()
...
@@ -63,6 +63,7 @@ cv::gpu::OpticalFlowDual_TVL1_GPU::OpticalFlowDual_TVL1_GPU()
warps
=
5
;
warps
=
5
;
epsilon
=
0.01
;
epsilon
=
0.01
;
iterations
=
300
;
iterations
=
300
;
scaleStep
=
0.8
;
useInitialFlow
=
false
;
useInitialFlow
=
false
;
}
}
...
@@ -112,8 +113,8 @@ void cv::gpu::OpticalFlowDual_TVL1_GPU::operator ()(const GpuMat& I0, const GpuM
...
@@ -112,8 +113,8 @@ void cv::gpu::OpticalFlowDual_TVL1_GPU::operator ()(const GpuMat& I0, const GpuM
// create the scales
// create the scales
for
(
int
s
=
1
;
s
<
nscales
;
++
s
)
for
(
int
s
=
1
;
s
<
nscales
;
++
s
)
{
{
gpu
::
pyrDown
(
I0s
[
s
-
1
],
I0s
[
s
]
);
gpu
::
resize
(
I0s
[
s
-
1
],
I0s
[
s
],
Size
(),
scaleStep
,
scaleStep
);
gpu
::
pyrDown
(
I1s
[
s
-
1
],
I1s
[
s
]
);
gpu
::
resize
(
I1s
[
s
-
1
],
I1s
[
s
],
Size
(),
scaleStep
,
scaleStep
);
if
(
I0s
[
s
].
cols
<
16
||
I0s
[
s
].
rows
<
16
)
if
(
I0s
[
s
].
cols
<
16
||
I0s
[
s
].
rows
<
16
)
{
{
...
@@ -123,11 +124,11 @@ void cv::gpu::OpticalFlowDual_TVL1_GPU::operator ()(const GpuMat& I0, const GpuM
...
@@ -123,11 +124,11 @@ void cv::gpu::OpticalFlowDual_TVL1_GPU::operator ()(const GpuMat& I0, const GpuM
if
(
useInitialFlow
)
if
(
useInitialFlow
)
{
{
gpu
::
pyrDown
(
u1s
[
s
-
1
],
u1s
[
s
]
);
gpu
::
resize
(
u1s
[
s
-
1
],
u1s
[
s
],
Size
(),
scaleStep
,
scaleStep
);
gpu
::
pyrDown
(
u2s
[
s
-
1
],
u2s
[
s
]
);
gpu
::
resize
(
u2s
[
s
-
1
],
u2s
[
s
],
Size
(),
scaleStep
,
scaleStep
);
gpu
::
multiply
(
u1s
[
s
],
Scalar
::
all
(
0.5
),
u1s
[
s
]);
gpu
::
multiply
(
u1s
[
s
],
Scalar
::
all
(
scaleStep
),
u1s
[
s
]);
gpu
::
multiply
(
u2s
[
s
],
Scalar
::
all
(
0.5
),
u2s
[
s
]);
gpu
::
multiply
(
u2s
[
s
],
Scalar
::
all
(
scaleStep
),
u2s
[
s
]);
}
}
else
else
{
{
...
@@ -159,8 +160,8 @@ void cv::gpu::OpticalFlowDual_TVL1_GPU::operator ()(const GpuMat& I0, const GpuM
...
@@ -159,8 +160,8 @@ void cv::gpu::OpticalFlowDual_TVL1_GPU::operator ()(const GpuMat& I0, const GpuM
gpu
::
resize
(
u2s
[
s
],
u2s
[
s
-
1
],
I0s
[
s
-
1
].
size
());
gpu
::
resize
(
u2s
[
s
],
u2s
[
s
-
1
],
I0s
[
s
-
1
].
size
());
// scale the optical flow with the appropriate zoom factor
// scale the optical flow with the appropriate zoom factor
gpu
::
multiply
(
u1s
[
s
-
1
],
Scalar
::
all
(
2
),
u1s
[
s
-
1
]);
gpu
::
multiply
(
u1s
[
s
-
1
],
Scalar
::
all
(
1
/
scaleStep
),
u1s
[
s
-
1
]);
gpu
::
multiply
(
u2s
[
s
-
1
],
Scalar
::
all
(
2
),
u2s
[
s
-
1
]);
gpu
::
multiply
(
u2s
[
s
-
1
],
Scalar
::
all
(
1
/
scaleStep
),
u2s
[
s
-
1
]);
}
}
}
}
...
...
modules/gpu/test/test_optflow.cpp
View file @
8d97d959
...
@@ -435,13 +435,16 @@ GPU_TEST_P(OpticalFlowDual_TVL1, Accuracy)
...
@@ -435,13 +435,16 @@ GPU_TEST_P(OpticalFlowDual_TVL1, Accuracy)
d_alg
(
loadMat
(
frame0
,
useRoi
),
loadMat
(
frame1
,
useRoi
),
d_flowx
,
d_flowy
);
d_alg
(
loadMat
(
frame0
,
useRoi
),
loadMat
(
frame1
,
useRoi
),
d_flowx
,
d_flowy
);
cv
::
Ptr
<
cv
::
DenseOpticalFlow
>
alg
=
cv
::
createOptFlow_DualTVL1
();
cv
::
Ptr
<
cv
::
DenseOpticalFlow
>
alg
=
cv
::
createOptFlow_DualTVL1
();
alg
->
set
(
"medianFiltering"
,
1
);
alg
->
set
(
"innerIterations"
,
1
);
alg
->
set
(
"outerIterations"
,
d_alg
.
iterations
);
cv
::
Mat
flow
;
cv
::
Mat
flow
;
alg
->
calc
(
frame0
,
frame1
,
flow
);
alg
->
calc
(
frame0
,
frame1
,
flow
);
cv
::
Mat
gold
[
2
];
cv
::
Mat
gold
[
2
];
cv
::
split
(
flow
,
gold
);
cv
::
split
(
flow
,
gold
);
EXPECT_MAT_SIMILAR
(
gold
[
0
],
d_flowx
,
3
e-3
);
EXPECT_MAT_SIMILAR
(
gold
[
0
],
d_flowx
,
4
e-3
);
EXPECT_MAT_SIMILAR
(
gold
[
1
],
d_flowy
,
3
e-3
);
EXPECT_MAT_SIMILAR
(
gold
[
1
],
d_flowy
,
4
e-3
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU_Video
,
OpticalFlowDual_TVL1
,
testing
::
Combine
(
INSTANTIATE_TEST_CASE_P
(
GPU_Video
,
OpticalFlowDual_TVL1
,
testing
::
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