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
34567877
Commit
34567877
authored
Jan 04, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5771 from dtmoodie:pyrlk
parents
430e2f20
66738d74
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
28 deletions
+56
-28
perf_optflow.cpp
modules/cudaoptflow/perf/perf_optflow.cpp
+12
-3
pyrlk.cu
modules/cudaoptflow/src/cuda/pyrlk.cu
+0
-0
precomp.hpp
modules/cudaoptflow/src/precomp.hpp
+1
-1
pyrlk.cpp
modules/cudaoptflow/src/pyrlk.cpp
+0
-0
test_optflow.cpp
modules/cudaoptflow/test/test_optflow.cpp
+35
-18
pyr_down.cu
modules/cudawarping/src/cuda/pyr_down.cu
+5
-4
pyramids.cpp
modules/cudawarping/src/pyramids.cpp
+3
-2
No files found.
modules/cudaoptflow/perf/perf_optflow.cpp
View file @
34567877
...
...
@@ -116,10 +116,10 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, PyrLKOpticalFlowSparse,
const
int
levels
=
GET_PARAM
(
4
);
const
int
iters
=
GET_PARAM
(
5
);
c
onst
c
v
::
Mat
frame0
=
readImage
(
imagePair
.
first
,
useGray
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
cv
::
Mat
frame0
=
readImage
(
imagePair
.
first
,
useGray
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
ASSERT_FALSE
(
frame0
.
empty
());
c
onst
c
v
::
Mat
frame1
=
readImage
(
imagePair
.
second
,
useGray
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
cv
::
Mat
frame1
=
readImage
(
imagePair
.
second
,
useGray
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
ASSERT_FALSE
(
frame1
.
empty
());
cv
::
Mat
gray_frame
;
...
...
@@ -131,6 +131,14 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, PyrLKOpticalFlowSparse,
cv
::
Mat
pts
;
cv
::
goodFeaturesToTrack
(
gray_frame
,
pts
,
points
,
0.01
,
0.0
);
frame0
.
convertTo
(
frame0
,
CV_32F
);
frame1
.
convertTo
(
frame1
,
CV_32F
);
if
(
!
useGray
)
{
cv
::
cvtColor
(
frame0
,
frame0
,
cv
::
COLOR_BGR2BGRA
);
cv
::
cvtColor
(
frame1
,
frame1
,
cv
::
COLOR_BGR2BGRA
);
}
if
(
PERF_RUN_CUDA
())
{
const
cv
::
cuda
::
GpuMat
d_pts
(
pts
.
reshape
(
2
,
1
));
...
...
@@ -318,4 +326,4 @@ PERF_TEST_P(ImagePair, OpticalFlowDual_TVL1,
CPU_SANITY_CHECK
(
flow
);
}
}
}
\ No newline at end of file
modules/cudaoptflow/src/cuda/pyrlk.cu
View file @
34567877
This diff is collapsed.
Click to expand it.
modules/cudaoptflow/src/precomp.hpp
View file @
34567877
...
...
@@ -52,7 +52,7 @@
#include "opencv2/video.hpp"
#include "opencv2/core/private.cuda.hpp"
#include "opencv2/core/cuda/vec_traits.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_CUDALEGACY
...
...
modules/cudaoptflow/src/pyrlk.cpp
View file @
34567877
This diff is collapsed.
Click to expand it.
modules/cudaoptflow/test/test_optflow.cpp
View file @
34567877
...
...
@@ -167,33 +167,34 @@ INSTANTIATE_TEST_CASE_P(CUDA_OptFlow, BroxOpticalFlow, ALL_DEVICES);
namespace
{
IMPLEMENT_PARAM_CLASS
(
UseGray
,
bool
)
IMPLEMENT_PARAM_CLASS
(
Chan
,
int
)
IMPLEMENT_PARAM_CLASS
(
DataType
,
int
)
}
PARAM_TEST_CASE
(
PyrLKOpticalFlow
,
cv
::
cuda
::
DeviceInfo
,
UseGray
)
PARAM_TEST_CASE
(
PyrLKOpticalFlow
,
cv
::
cuda
::
DeviceInfo
,
Chan
,
DataType
)
{
cv
::
cuda
::
DeviceInfo
devInfo
;
bool
useGray
;
int
channels
;
int
dataType
;
virtual
void
SetUp
()
{
devInfo
=
GET_PARAM
(
0
);
useGray
=
GET_PARAM
(
1
);
channels
=
GET_PARAM
(
1
);
dataType
=
GET_PARAM
(
2
);
cv
::
cuda
::
setDevice
(
devInfo
.
deviceID
());
}
};
CUDA_TEST_P
(
PyrLKOpticalFlow
,
Sparse
)
{
cv
::
Mat
frame0
=
readImage
(
"opticalflow/frame0.png"
,
useGray
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
cv
::
Mat
frame0
=
readImage
(
"opticalflow/frame0.png"
,
channels
==
1
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
ASSERT_FALSE
(
frame0
.
empty
());
cv
::
Mat
frame1
=
readImage
(
"opticalflow/frame1.png"
,
useGray
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
cv
::
Mat
frame1
=
readImage
(
"opticalflow/frame1.png"
,
channels
==
1
?
cv
::
IMREAD_GRAYSCALE
:
cv
::
IMREAD_COLOR
);
ASSERT_FALSE
(
frame1
.
empty
());
cv
::
Mat
gray_frame
;
if
(
useGray
)
if
(
channels
==
1
)
gray_frame
=
frame0
;
else
cv
::
cvtColor
(
frame0
,
gray_frame
,
cv
::
COLOR_BGR2GRAY
);
...
...
@@ -208,22 +209,32 @@ CUDA_TEST_P(PyrLKOpticalFlow, Sparse)
cv
::
Ptr
<
cv
::
cuda
::
SparsePyrLKOpticalFlow
>
pyrLK
=
cv
::
cuda
::
SparsePyrLKOpticalFlow
::
create
();
std
::
vector
<
cv
::
Point2f
>
nextPts_gold
;
std
::
vector
<
unsigned
char
>
status_gold
;
cv
::
calcOpticalFlowPyrLK
(
frame0
,
frame1
,
pts
,
nextPts_gold
,
status_gold
,
cv
::
noArray
());
cv
::
cuda
::
GpuMat
d_nextPts
;
cv
::
cuda
::
GpuMat
d_status
;
pyrLK
->
calc
(
loadMat
(
frame0
),
loadMat
(
frame1
),
d_pts
,
d_nextPts
,
d_status
);
cv
::
Mat
converted0
,
converted1
;
if
(
channels
==
4
)
{
cv
::
cvtColor
(
frame0
,
frame0
,
cv
::
COLOR_BGR2BGRA
);
cv
::
cvtColor
(
frame1
,
frame1
,
cv
::
COLOR_BGR2BGRA
);
}
frame0
.
convertTo
(
converted0
,
dataType
);
frame1
.
convertTo
(
converted1
,
dataType
);
pyrLK
->
calc
(
loadMat
(
converted0
),
loadMat
(
converted1
),
d_pts
,
d_nextPts
,
d_status
);
std
::
vector
<
cv
::
Point2f
>
nextPts
(
d_nextPts
.
cols
);
cv
::
Mat
nextPts_mat
(
1
,
d_nextPts
.
cols
,
CV_32FC2
,
(
void
*
)
&
nextPts
[
0
]);
cv
::
Mat
nextPts_mat
(
1
,
d_nextPts
.
cols
,
CV_32FC2
,
(
void
*
)
&
nextPts
[
0
]);
d_nextPts
.
download
(
nextPts_mat
);
std
::
vector
<
unsigned
char
>
status
(
d_status
.
cols
);
cv
::
Mat
status_mat
(
1
,
d_status
.
cols
,
CV_8UC1
,
(
void
*
)
&
status
[
0
]);
cv
::
Mat
status_mat
(
1
,
d_status
.
cols
,
CV_8UC1
,
(
void
*
)
&
status
[
0
]);
d_status
.
download
(
status_mat
);
std
::
vector
<
cv
::
Point2f
>
nextPts_gold
;
std
::
vector
<
unsigned
char
>
status_gold
;
cv
::
calcOpticalFlowPyrLK
(
frame0
,
frame1
,
pts
,
nextPts_gold
,
status_gold
,
cv
::
noArray
());
ASSERT_EQ
(
nextPts_gold
.
size
(),
nextPts
.
size
());
ASSERT_EQ
(
status_gold
.
size
(),
status
.
size
());
...
...
@@ -251,11 +262,16 @@ CUDA_TEST_P(PyrLKOpticalFlow, Sparse)
double
bad_ratio
=
static_cast
<
double
>
(
mistmatch
)
/
nextPts
.
size
();
ASSERT_LE
(
bad_ratio
,
0.01
);
}
INSTANTIATE_TEST_CASE_P
(
CUDA_OptFlow
,
PyrLKOpticalFlow
,
testing
::
Combine
(
ALL_DEVICES
,
testing
::
Values
(
UseGray
(
true
),
UseGray
(
false
))));
testing
::
Values
(
Chan
(
1
),
Chan
(
3
),
Chan
(
4
)),
testing
::
Values
(
DataType
(
CV_8U
),
DataType
(
CV_16U
),
DataType
(
CV_32S
),
DataType
(
CV_32F
))));
//////////////////////////////////////////////////////
// FarnebackOpticalFlow
...
...
@@ -385,4 +401,4 @@ INSTANTIATE_TEST_CASE_P(CUDA_OptFlow, OpticalFlowDual_TVL1, testing::Combine(
ALL_DEVICES
,
testing
::
Values
(
Gamma
(
0.0
),
Gamma
(
1.0
))));
#endif // HAVE_CUDA
#endif // HAVE_CUDA
\ No newline at end of file
modules/cudawarping/src/cuda/pyr_down.cu
View file @
34567877
...
...
@@ -212,10 +212,10 @@ namespace cv { namespace cuda { namespace device
template void pyrDown_gpu<short3>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
template void pyrDown_gpu<short4>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
//
template void pyrDown_gpu<int>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
template void pyrDown_gpu<int>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
//template void pyrDown_gpu<int2>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
//
template void pyrDown_gpu<int3>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
//
template void pyrDown_gpu<int4>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
template void pyrDown_gpu<int3>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
template void pyrDown_gpu<int4>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
template void pyrDown_gpu<float>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
//template void pyrDown_gpu<float2>(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
...
...
@@ -225,4 +225,4 @@ namespace cv { namespace cuda { namespace device
}}} // namespace cv { namespace cuda { namespace cudev
#endif /* CUDA_DISABLER */
#endif /* CUDA_DISABLER */
\ No newline at end of file
modules/cudawarping/src/pyramids.cpp
View file @
34567877
...
...
@@ -74,7 +74,7 @@ void cv::cuda::pyrDown(InputArray _src, OutputArray _dst, Stream& stream)
{
0
/*pyrDown_gpu<schar>*/
,
0
/*pyrDown_gpu<schar2>*/
,
0
/*pyrDown_gpu<schar3>*/
,
0
/*pyrDown_gpu<schar4>*/
},
{
pyrDown_gpu
<
ushort
>
,
0
/*pyrDown_gpu<ushort2>*/
,
pyrDown_gpu
<
ushort3
>
,
pyrDown_gpu
<
ushort4
>
},
{
pyrDown_gpu
<
short
>
,
0
/*pyrDown_gpu<short2>*/
,
pyrDown_gpu
<
short3
>
,
pyrDown_gpu
<
short4
>
},
{
0
/*pyrDown_gpu<int>*/
,
0
/*pyrDown_gpu<int2>*/
,
0
/*pyrDown_gpu<int3>*/
,
0
/*pyrDown_gpu<int4>*/
},
{
pyrDown_gpu
<
int
>
,
0
/*pyrDown_gpu<int2>*/
,
pyrDown_gpu
<
int3
>
,
pyrDown_gpu
<
int4
>
},
{
pyrDown_gpu
<
float
>
,
0
/*pyrDown_gpu<float2>*/
,
pyrDown_gpu
<
float3
>
,
pyrDown_gpu
<
float4
>
}
};
...
...
@@ -131,4 +131,4 @@ void cv::cuda::pyrUp(InputArray _src, OutputArray _dst, Stream& stream)
func
(
src
,
dst
,
StreamAccessor
::
getStream
(
stream
));
}
#endif
#endif
\ No newline at end of file
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