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
b3a743f0
Commit
b3a743f0
authored
Dec 31, 2014
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix gpu samples compilation
parent
62f8240b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
69 deletions
+35
-69
farneback_optical_flow.cpp
samples/gpu/farneback_optical_flow.cpp
+12
-7
optical_flow.cpp
samples/gpu/optical_flow.cpp
+20
-41
pyrlk_optical_flow.cpp
samples/gpu/pyrlk_optical_flow.cpp
+3
-21
No files found.
samples/gpu/farneback_optical_flow.cpp
View file @
b3a743f0
...
...
@@ -7,6 +7,7 @@
#include "opencv2/highgui.hpp"
#include "opencv2/video.hpp"
#include "opencv2/cudaoptflow.hpp"
#include "opencv2/cudaarithm.hpp"
using
namespace
std
;
using
namespace
cv
;
...
...
@@ -70,8 +71,8 @@ int main(int argc, char **argv)
if
(
frameL
.
empty
()
||
frameR
.
empty
())
return
-
1
;
GpuMat
d_frameL
(
frameL
),
d_frameR
(
frameR
);
GpuMat
d_flow
x
,
d_flowy
;
FarnebackOpticalFlow
d_calc
;
GpuMat
d_flow
;
Ptr
<
cuda
::
FarnebackOpticalFlow
>
d_calc
=
cuda
::
FarnebackOpticalFlow
::
create
()
;
Mat
flowxy
,
flowx
,
flowy
,
image
;
bool
running
=
true
,
gpuMode
=
true
;
...
...
@@ -86,17 +87,21 @@ int main(int argc, char **argv)
if
(
gpuMode
)
{
tc0
=
getTickCount
();
d_calc
(
d_frameL
,
d_frameR
,
d_flowx
,
d_flowy
);
d_calc
->
calc
(
d_frameL
,
d_frameR
,
d_flow
);
tc1
=
getTickCount
();
d_flowx
.
download
(
flowx
);
d_flowy
.
download
(
flowy
);
GpuMat
planes
[
2
];
cuda
::
split
(
d_flow
,
planes
);
planes
[
0
].
download
(
flowx
);
planes
[
1
].
download
(
flowy
);
}
else
{
tc0
=
getTickCount
();
calcOpticalFlowFarneback
(
frameL
,
frameR
,
flowxy
,
d_calc
.
pyrScale
,
d_calc
.
numLevels
,
d_calc
.
winSize
,
d_calc
.
numIters
,
d_calc
.
polyN
,
d_calc
.
polySigma
,
d_calc
.
flags
);
frameL
,
frameR
,
flowxy
,
d_calc
->
getPyrScale
(),
d_calc
->
getNumLevels
(),
d_calc
->
getWinSize
()
,
d_calc
->
getNumIters
(),
d_calc
->
getPolyN
(),
d_calc
->
getPolySigma
(),
d_calc
->
getFlags
()
);
tc1
=
getTickCount
();
Mat
planes
[]
=
{
flowx
,
flowy
};
...
...
samples/gpu/optical_flow.cpp
View file @
b3a743f0
...
...
@@ -5,6 +5,7 @@
#include <opencv2/core/utility.hpp>
#include "opencv2/highgui.hpp"
#include "opencv2/cudaoptflow.hpp"
#include "opencv2/cudaarithm.hpp"
using
namespace
std
;
using
namespace
cv
;
...
...
@@ -122,10 +123,13 @@ static void drawOpticalFlow(const Mat_<float>& flowx, const Mat_<float>& flowy,
}
}
static
void
showFlow
(
const
char
*
name
,
const
GpuMat
&
d_flow
x
,
const
GpuMat
&
d_flowy
)
static
void
showFlow
(
const
char
*
name
,
const
GpuMat
&
d_flow
)
{
Mat
flowx
(
d_flowx
);
Mat
flowy
(
d_flowy
);
GpuMat
planes
[
2
];
cuda
::
split
(
d_flow
,
planes
);
Mat
flowx
(
planes
[
0
]);
Mat
flowy
(
planes
[
1
]);
Mat
out
;
drawOpticalFlow
(
flowx
,
flowy
,
out
,
10
);
...
...
@@ -171,14 +175,12 @@ int main(int argc, const char* argv[])
GpuMat
d_frame0
(
frame0
);
GpuMat
d_frame1
(
frame1
);
GpuMat
d_flowx
(
frame0
.
size
(),
CV_32FC1
);
GpuMat
d_flowy
(
frame0
.
size
(),
CV_32FC1
);
GpuMat
d_flow
(
frame0
.
size
(),
CV_32FC2
);
BroxOpticalFlow
brox
(
0.197
f
,
50.0
f
,
0.8
f
,
10
,
77
,
10
);
PyrLKOpticalFlow
lk
;
lk
.
winSize
=
Size
(
7
,
7
);
FarnebackOpticalFlow
farn
;
OpticalFlowDual_TVL1_CUDA
tvl1
;
FastOpticalFlowBM
fastBM
;
Ptr
<
cuda
::
BroxOpticalFlow
>
brox
=
cuda
::
BroxOpticalFlow
::
create
(
0.197
f
,
50.0
f
,
0.8
f
,
10
,
77
,
10
);
Ptr
<
cuda
::
DensePyrLKOpticalFlow
>
lk
=
cuda
::
DensePyrLKOpticalFlow
::
create
(
Size
(
7
,
7
));
Ptr
<
cuda
::
FarnebackOpticalFlow
>
farn
=
cuda
::
FarnebackOpticalFlow
::
create
();
Ptr
<
cuda
::
OpticalFlowDual_TVL1
>
tvl1
=
cuda
::
OpticalFlowDual_TVL1
::
create
();
{
GpuMat
d_frame0f
;
...
...
@@ -189,68 +191,45 @@ int main(int argc, const char* argv[])
const
int64
start
=
getTickCount
();
brox
(
d_frame0f
,
d_frame1f
,
d_flowx
,
d_flowy
);
brox
->
calc
(
d_frame0f
,
d_frame1f
,
d_flow
);
const
double
timeSec
=
(
getTickCount
()
-
start
)
/
getTickFrequency
();
cout
<<
"Brox : "
<<
timeSec
<<
" sec"
<<
endl
;
showFlow
(
"Brox"
,
d_flow
x
,
d_flowy
);
showFlow
(
"Brox"
,
d_flow
);
}
{
const
int64
start
=
getTickCount
();
lk
.
dense
(
d_frame0
,
d_frame1
,
d_flowx
,
d_flowy
);
lk
->
calc
(
d_frame0
,
d_frame1
,
d_flow
);
const
double
timeSec
=
(
getTickCount
()
-
start
)
/
getTickFrequency
();
cout
<<
"LK : "
<<
timeSec
<<
" sec"
<<
endl
;
showFlow
(
"LK"
,
d_flow
x
,
d_flowy
);
showFlow
(
"LK"
,
d_flow
);
}
{
const
int64
start
=
getTickCount
();
farn
(
d_frame0
,
d_frame1
,
d_flowx
,
d_flowy
);
farn
->
calc
(
d_frame0
,
d_frame1
,
d_flow
);
const
double
timeSec
=
(
getTickCount
()
-
start
)
/
getTickFrequency
();
cout
<<
"Farn : "
<<
timeSec
<<
" sec"
<<
endl
;
showFlow
(
"Farn"
,
d_flow
x
,
d_flowy
);
showFlow
(
"Farn"
,
d_flow
);
}
{
const
int64
start
=
getTickCount
();
tvl1
(
d_frame0
,
d_frame1
,
d_flowx
,
d_flowy
);
tvl1
->
calc
(
d_frame0
,
d_frame1
,
d_flow
);
const
double
timeSec
=
(
getTickCount
()
-
start
)
/
getTickFrequency
();
cout
<<
"TVL1 : "
<<
timeSec
<<
" sec"
<<
endl
;
showFlow
(
"TVL1"
,
d_flowx
,
d_flowy
);
}
{
const
int64
start
=
getTickCount
();
GpuMat
buf
;
calcOpticalFlowBM
(
d_frame0
,
d_frame1
,
Size
(
7
,
7
),
Size
(
1
,
1
),
Size
(
21
,
21
),
false
,
d_flowx
,
d_flowy
,
buf
);
const
double
timeSec
=
(
getTickCount
()
-
start
)
/
getTickFrequency
();
cout
<<
"BM : "
<<
timeSec
<<
" sec"
<<
endl
;
showFlow
(
"BM"
,
d_flowx
,
d_flowy
);
}
{
const
int64
start
=
getTickCount
();
fastBM
(
d_frame0
,
d_frame1
,
d_flowx
,
d_flowy
);
const
double
timeSec
=
(
getTickCount
()
-
start
)
/
getTickFrequency
();
cout
<<
"Fast BM : "
<<
timeSec
<<
" sec"
<<
endl
;
showFlow
(
"Fast BM"
,
d_flowx
,
d_flowy
);
showFlow
(
"TVL1"
,
d_flow
);
}
imshow
(
"Frame 0"
,
frame0
);
...
...
samples/gpu/pyrlk_optical_flow.cpp
View file @
b3a743f0
...
...
@@ -186,12 +186,8 @@ int main(int argc, const char* argv[])
// Sparse
PyrLKOpticalFlow
d_pyrLK
;
d_pyrLK
.
winSize
.
width
=
winSize
;
d_pyrLK
.
winSize
.
height
=
winSize
;
d_pyrLK
.
maxLevel
=
maxLevel
;
d_pyrLK
.
iters
=
iters
;
Ptr
<
cuda
::
SparsePyrLKOpticalFlow
>
d_pyrLK
=
cuda
::
SparsePyrLKOpticalFlow
::
create
(
Size
(
winSize
,
winSize
),
maxLevel
,
iters
);
GpuMat
d_frame0
(
frame0
);
GpuMat
d_frame1
(
frame1
);
...
...
@@ -199,7 +195,7 @@ int main(int argc, const char* argv[])
GpuMat
d_nextPts
;
GpuMat
d_status
;
d_pyrLK
.
sparse
(
useGray
?
d_frame0Gray
:
d_frame0
,
useGray
?
d_frame1Gray
:
d_frame1
,
d_prevPts
,
d_nextPts
,
d_status
);
d_pyrLK
->
calc
(
useGray
?
d_frame0Gray
:
d_frame0
,
useGray
?
d_frame1Gray
:
d_frame1
,
d_prevPts
,
d_nextPts
,
d_status
);
// Draw arrows
...
...
@@ -216,20 +212,6 @@ int main(int argc, const char* argv[])
imshow
(
"PyrLK [Sparse]"
,
frame0
);
// Dense
GpuMat
d_u
;
GpuMat
d_v
;
d_pyrLK
.
dense
(
d_frame0Gray
,
d_frame1Gray
,
d_u
,
d_v
);
// Draw flow field
Mat
flowField
;
getFlowField
(
Mat
(
d_u
),
Mat
(
d_v
),
flowField
);
imshow
(
"PyrLK [Dense] Flow Field"
,
flowField
);
waitKey
();
return
0
;
...
...
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