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
9aa44105
Commit
9aa44105
authored
Jan 22, 2014
by
Andrey Pavlenko
Committed by
OpenCV Buildbot
Jan 22, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2134 from vbystricky:ocl_calcOpticalFlowFarneback
parents
ee331001
e0c6377d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
237 additions
and
0 deletions
+237
-0
perf_optflow_farneback.cpp
modules/video/perf/opencl/perf_optflow_farneback.cpp
+115
-0
optical_flow_farneback.cl
modules/video/src/opencl/optical_flow_farneback.cl
+0
-0
optflowgf.cpp
modules/video/src/optflowgf.cpp
+0
-0
precomp.hpp
modules/video/src/precomp.hpp
+1
-0
test_optflow_farneback.cpp
modules/video/test/ocl/test_optflow_farneback.cpp
+121
-0
No files found.
modules/video/perf/opencl/perf_optflow_farneback.cpp
0 → 100644
View file @
9aa44105
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
using
std
::
tr1
::
make_tuple
;
#ifdef HAVE_OPENCL
namespace
cvtest
{
namespace
ocl
{
///////////// FarnebackOpticalFlow ////////////////////////
CV_ENUM
(
farneFlagType
,
0
,
OPTFLOW_FARNEBACK_GAUSSIAN
)
typedef
tuple
<
tuple
<
int
,
double
>
,
farneFlagType
,
bool
>
FarnebackOpticalFlowParams
;
typedef
TestBaseWithParam
<
FarnebackOpticalFlowParams
>
FarnebackOpticalFlowFixture
;
OCL_PERF_TEST_P
(
FarnebackOpticalFlowFixture
,
FarnebackOpticalFlow
,
::
testing
::
Combine
(
::
testing
::
Values
(
make_tuple
<
int
,
double
>
(
5
,
1.1
),
make_tuple
<
int
,
double
>
(
7
,
1.5
)
),
farneFlagType
::
all
(),
::
testing
::
Bool
()
)
)
{
Mat
frame0
=
imread
(
getDataPath
(
"gpu/opticalflow/rubberwhale1.png"
),
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame0
.
empty
())
<<
"can't load rubberwhale1.png"
;
Mat
frame1
=
imread
(
getDataPath
(
"gpu/opticalflow/rubberwhale2.png"
),
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame1
.
empty
())
<<
"can't load rubberwhale2.png"
;
const
Size
srcSize
=
frame0
.
size
();
const
int
numLevels
=
5
;
const
int
winSize
=
13
;
const
int
numIters
=
10
;
const
FarnebackOpticalFlowParams
params
=
GetParam
();
const
tuple
<
int
,
double
>
polyParams
=
get
<
0
>
(
params
);
const
int
polyN
=
get
<
0
>
(
polyParams
);
const
double
polySigma
=
get
<
1
>
(
polyParams
);
const
double
pyrScale
=
0.5
;
int
flags
=
get
<
1
>
(
params
);
const
bool
useInitFlow
=
get
<
2
>
(
params
);
const
double
eps
=
0.1
;
UMat
uFrame0
;
frame0
.
copyTo
(
uFrame0
);
UMat
uFrame1
;
frame1
.
copyTo
(
uFrame1
);
UMat
uFlow
(
srcSize
,
CV_32FC2
);
declare
.
in
(
uFrame0
,
uFrame1
,
WARMUP_READ
).
out
(
uFlow
,
WARMUP_READ
);
if
(
useInitFlow
)
{
cv
::
calcOpticalFlowFarneback
(
uFrame0
,
uFrame1
,
uFlow
,
pyrScale
,
numLevels
,
winSize
,
numIters
,
polyN
,
polySigma
,
flags
);
flags
|=
OPTFLOW_USE_INITIAL_FLOW
;
}
OCL_TEST_CYCLE
()
cv
::
calcOpticalFlowFarneback
(
uFrame0
,
uFrame1
,
uFlow
,
pyrScale
,
numLevels
,
winSize
,
numIters
,
polyN
,
polySigma
,
flags
);
SANITY_CHECK
(
uFlow
,
eps
,
ERROR_RELATIVE
);
}
}
}
// namespace cvtest::ocl
#endif // HAVE_OPENCL
\ No newline at end of file
modules/video/src/opencl/optical_flow_farneback.cl
0 → 100644
View file @
9aa44105
This diff is collapsed.
Click to expand it.
modules/video/src/optflowgf.cpp
View file @
9aa44105
This diff is collapsed.
Click to expand it.
modules/video/src/precomp.hpp
View file @
9aa44105
...
...
@@ -46,6 +46,7 @@
#include "opencv2/video.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#include "opencv2/core/ocl.hpp"
#ifdef HAVE_TEGRA_OPTIMIZATION
#include "opencv2/video/video_tegra.hpp"
...
...
modules/video/test/ocl/test_optflow_farneback.cpp
0 → 100644
View file @
9aa44105
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp"
#ifdef HAVE_OPENCL
namespace
cvtest
{
namespace
ocl
{
/////////////////////////////////////////////////////////////////////////////////////////////////
// FarnebackOpticalFlow
namespace
{
IMPLEMENT_PARAM_CLASS
(
PyrScale
,
double
)
IMPLEMENT_PARAM_CLASS
(
PolyN
,
int
)
CV_FLAGS
(
FarnebackOptFlowFlags
,
0
,
OPTFLOW_FARNEBACK_GAUSSIAN
)
IMPLEMENT_PARAM_CLASS
(
UseInitFlow
,
bool
)
}
PARAM_TEST_CASE
(
FarnebackOpticalFlow
,
PyrScale
,
PolyN
,
FarnebackOptFlowFlags
,
UseInitFlow
)
{
int
numLevels
;
int
winSize
;
int
numIters
;
double
pyrScale
;
int
polyN
;
int
flags
;
bool
useInitFlow
;
virtual
void
SetUp
()
{
numLevels
=
5
;
winSize
=
13
;
numIters
=
10
;
pyrScale
=
GET_PARAM
(
0
);
polyN
=
GET_PARAM
(
1
);
flags
=
GET_PARAM
(
2
);
useInitFlow
=
GET_PARAM
(
3
);
}
};
OCL_TEST_P
(
FarnebackOpticalFlow
,
Mat
)
{
cv
::
Mat
frame0
=
readImage
(
"optflow/RubberWhale1.png"
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame0
.
empty
());
cv
::
Mat
frame1
=
readImage
(
"optflow/RubberWhale2.png"
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame1
.
empty
());
double
polySigma
=
polyN
<=
5
?
1.1
:
1.5
;
cv
::
Mat
flow
;
cv
::
UMat
uflow
;
if
(
useInitFlow
)
{
OCL_ON
(
cv
::
calcOpticalFlowFarneback
(
frame0
,
frame1
,
uflow
,
pyrScale
,
numLevels
,
winSize
,
numIters
,
polyN
,
polySigma
,
flags
));
uflow
.
copyTo
(
flow
);
flags
|=
cv
::
OPTFLOW_USE_INITIAL_FLOW
;
}
OCL_OFF
(
cv
::
calcOpticalFlowFarneback
(
frame0
,
frame1
,
flow
,
pyrScale
,
numLevels
,
winSize
,
numIters
,
polyN
,
polySigma
,
flags
));
OCL_ON
(
cv
::
calcOpticalFlowFarneback
(
frame0
,
frame1
,
uflow
,
pyrScale
,
numLevels
,
winSize
,
numIters
,
polyN
,
polySigma
,
flags
));
EXPECT_MAT_SIMILAR
(
flow
,
uflow
,
0.1
)
}
OCL_INSTANTIATE_TEST_CASE_P
(
Video
,
FarnebackOpticalFlow
,
Combine
(
Values
(
PyrScale
(
0.3
),
PyrScale
(
0.5
),
PyrScale
(
0.8
)),
Values
(
PolyN
(
5
),
PolyN
(
7
)),
Values
(
FarnebackOptFlowFlags
(
0
),
FarnebackOptFlowFlags
(
cv
::
OPTFLOW_FARNEBACK_GAUSSIAN
)),
Values
(
UseInitFlow
(
false
),
UseInitFlow
(
true
))
)
);
}
}
// namespace cvtest::ocl
#endif // HAVE_OPENCL
\ 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