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
702a2a6f
Commit
702a2a6f
authored
Mar 11, 2014
by
Andrey Pavlenko
Committed by
OpenCV Buildbot
Mar 11, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2373 from mlyashko:optflow_dualtvl1
parents
5261fbe2
eb2e8a11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
235 additions
and
33 deletions
+235
-33
ocl.cpp
modules/core/src/ocl.cpp
+4
-2
perf_optflow_dualTVL1.cpp
modules/video/perf/opencl/perf_optflow_dualTVL1.cpp
+113
-0
lkpyramid.cpp
modules/video/src/lkpyramid.cpp
+0
-31
optical_flow_tvl1.cl
modules/video/src/opencl/optical_flow_tvl1.cl
+0
-0
tvl1flow.cpp
modules/video/src/tvl1flow.cpp
+0
-0
test_optflow_tvl1flow.cpp
modules/video/test/ocl/test_optflow_tvl1flow.cpp
+118
-0
No files found.
modules/core/src/ocl.cpp
View file @
702a2a6f
...
...
@@ -2814,7 +2814,8 @@ int Kernel::set(int i, const void* value, size_t sz)
{
if
(
!
p
||
!
p
->
handle
)
return
-
1
;
CV_Assert
(
i
>=
0
);
if
(
i
<
0
)
return
i
;
if
(
i
==
0
)
p
->
cleanupUMats
();
...
...
@@ -2840,7 +2841,8 @@ int Kernel::set(int i, const KernelArg& arg)
{
if
(
!
p
||
!
p
->
handle
)
return
-
1
;
CV_Assert
(
i
>=
0
);
if
(
i
<
0
)
return
i
;
if
(
i
==
0
)
p
->
cleanupUMats
();
if
(
arg
.
m
)
...
...
modules/video/perf/opencl/perf_optflow_dualTVL1.cpp
0 → 100644
View file @
702a2a6f
/*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
{
///////////// OpticalFlow Dual TVL1 ////////////////////////
typedef
tuple
<
tuple
<
int
,
double
>
,
bool
>
OpticalFlowDualTVL1Params
;
typedef
TestBaseWithParam
<
OpticalFlowDualTVL1Params
>
OpticalFlowDualTVL1Fixture
;
OCL_PERF_TEST_P
(
OpticalFlowDualTVL1Fixture
,
OpticalFlowDualTVL1
,
::
testing
::
Combine
(
::
testing
::
Values
(
make_tuple
<
int
,
double
>
(
-
1
,
0.3
),
make_tuple
<
int
,
double
>
(
3
,
0.5
)),
::
testing
::
Bool
()
)
)
{
Mat
frame0
=
imread
(
getDataPath
(
"cv/optflow/RubberWhale1.png"
),
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame0
.
empty
())
<<
"can't load RubberWhale1.png"
;
Mat
frame1
=
imread
(
getDataPath
(
"cv/optflow/RubberWhale2.png"
),
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame1
.
empty
())
<<
"can't load RubberWhale2.png"
;
const
Size
srcSize
=
frame0
.
size
();
const
OpticalFlowDualTVL1Params
params
=
GetParam
();
const
tuple
<
int
,
double
>
filteringScale
=
get
<
0
>
(
params
);
const
int
medianFiltering
=
get
<
0
>
(
filteringScale
);
const
double
scaleStep
=
get
<
1
>
(
filteringScale
);
const
bool
useInitFlow
=
get
<
1
>
(
params
);
double
eps
=
0.9
;
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
);
//create algorithm
cv
::
Ptr
<
cv
::
DenseOpticalFlow
>
alg
=
cv
::
createOptFlow_DualTVL1
();
//set parameters
alg
->
set
(
"scaleStep"
,
scaleStep
);
alg
->
setInt
(
"medianFiltering"
,
medianFiltering
);
if
(
useInitFlow
)
{
//calculate initial flow as result of optical flow
alg
->
calc
(
uFrame0
,
uFrame1
,
uFlow
);
}
//set flag to use initial flow
alg
->
setBool
(
"useInitialFlow"
,
useInitFlow
);
OCL_TEST_CYCLE
()
alg
->
calc
(
uFrame0
,
uFrame1
,
uFlow
);
SANITY_CHECK
(
uFlow
,
eps
,
ERROR_RELATIVE
);
}
}
}
// namespace cvtest::ocl
#endif // HAVE_OPENCL
\ No newline at end of file
modules/video/src/lkpyramid.cpp
View file @
702a2a6f
...
...
@@ -952,16 +952,6 @@ namespace cv
block
.
z
=
patch
.
z
=
1
;
}
#define SAFE_KERNEL_SET_ARG(idx, arg) \
{\
int idxNew = kernel.set(idx, arg);\
if (-1 == idxNew)\
{\
printf("lkSparse_run can't setup argument index = %d to kernel\n", idx);\
return false;\
}\
idx = idxNew;\
}
bool
lkSparse_run
(
UMat
&
I
,
UMat
&
J
,
const
UMat
&
prevPts
,
UMat
&
nextPts
,
UMat
&
status
,
UMat
&
err
,
int
ptcount
,
int
level
)
{
...
...
@@ -982,7 +972,6 @@ namespace cv
ocl
::
Image2D
imageI
(
I
);
ocl
::
Image2D
imageJ
(
J
);
int
idxArg
=
0
;
#if 0
idxArg
=
kernel
.
set
(
idxArg
,
imageI
);
//image2d_t I
idxArg
=
kernel
.
set
(
idxArg
,
imageJ
);
//image2d_t J
idxArg
=
kernel
.
set
(
idxArg
,
ocl
::
KernelArg
::
PtrReadOnly
(
prevPts
));
// __global const float2* prevPts
...
...
@@ -1000,26 +989,6 @@ namespace cv
idxArg
=
kernel
.
set
(
idxArg
,
(
int
)
winSize
.
height
);
// int c_winSize_y
idxArg
=
kernel
.
set
(
idxArg
,
(
int
)
iters
);
// int c_iters
idxArg
=
kernel
.
set
(
idxArg
,
(
char
)
calcErr
);
//char calcErr
#else
SAFE_KERNEL_SET_ARG
(
idxArg
,
imageI
);
//image2d_t I
SAFE_KERNEL_SET_ARG
(
idxArg
,
imageJ
);
//image2d_t J
SAFE_KERNEL_SET_ARG
(
idxArg
,
ocl
::
KernelArg
::
PtrReadOnly
(
prevPts
));
// __global const float2* prevPts
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
prevPts
.
step
);
// int prevPtsStep
SAFE_KERNEL_SET_ARG
(
idxArg
,
ocl
::
KernelArg
::
PtrReadWrite
(
nextPts
));
// __global const float2* nextPts
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
nextPts
.
step
);
// int nextPtsStep
SAFE_KERNEL_SET_ARG
(
idxArg
,
ocl
::
KernelArg
::
PtrReadWrite
(
status
));
// __global uchar* status
SAFE_KERNEL_SET_ARG
(
idxArg
,
ocl
::
KernelArg
::
PtrReadWrite
(
err
));
// __global float* err
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
level
);
// const int level
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
I
.
rows
);
// const int rows
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
I
.
cols
);
// const int cols
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
patch
.
x
);
// int PATCH_X
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
patch
.
y
);
// int PATCH_Y
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
winSize
.
width
);
// int c_winSize_x
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
winSize
.
height
);
// int c_winSize_y
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
int
)
iters
);
// int c_iters
SAFE_KERNEL_SET_ARG
(
idxArg
,
(
char
)
calcErr
);
//char calcErr
#endif
return
kernel
.
run
(
2
,
globalThreads
,
localThreads
,
true
);
}
private
:
...
...
modules/video/src/opencl/optical_flow_tvl1.cl
0 → 100644
View file @
702a2a6f
This diff is collapsed.
Click to expand it.
modules/video/src/tvl1flow.cpp
View file @
702a2a6f
This diff is collapsed.
Click to expand it.
modules/video/test/ocl/test_optflow_tvl1flow.cpp
0 → 100644
View file @
702a2a6f
/*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
{
/////////////////////////////////////////////////////////////////////////////////////////////////
// Optical_flow_tvl1
namespace
{
IMPLEMENT_PARAM_CLASS
(
UseInitFlow
,
bool
)
IMPLEMENT_PARAM_CLASS
(
MedianFiltering
,
int
)
IMPLEMENT_PARAM_CLASS
(
ScaleStep
,
double
)
}
PARAM_TEST_CASE
(
OpticalFlowTVL1
,
UseInitFlow
,
MedianFiltering
,
ScaleStep
)
{
bool
useInitFlow
;
int
medianFiltering
;
double
scaleStep
;
virtual
void
SetUp
()
{
useInitFlow
=
GET_PARAM
(
0
);
medianFiltering
=
GET_PARAM
(
1
);
scaleStep
=
GET_PARAM
(
2
);
}
};
OCL_TEST_P
(
OpticalFlowTVL1
,
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
());
cv
::
Mat
flow
;
cv
::
UMat
uflow
;
//create algorithm
cv
::
Ptr
<
cv
::
DenseOpticalFlow
>
alg
=
cv
::
createOptFlow_DualTVL1
();
//set parameters
alg
->
set
(
"scaleStep"
,
scaleStep
);
alg
->
setInt
(
"medianFiltering"
,
medianFiltering
);
//create initial flow as result of algorithm calculation
if
(
useInitFlow
)
{
OCL_ON
(
alg
->
calc
(
frame0
,
frame1
,
uflow
));
uflow
.
copyTo
(
flow
);
}
//set flag to use initial flow as it is ready to use
alg
->
setBool
(
"useInitialFlow"
,
useInitFlow
);
OCL_OFF
(
alg
->
calc
(
frame0
,
frame1
,
flow
));
OCL_ON
(
alg
->
calc
(
frame0
,
frame1
,
uflow
));
EXPECT_MAT_SIMILAR
(
flow
,
uflow
,
1e-2
);
}
OCL_INSTANTIATE_TEST_CASE_P
(
Video
,
OpticalFlowTVL1
,
Combine
(
Values
(
UseInitFlow
(
false
),
UseInitFlow
(
true
)),
Values
(
MedianFiltering
(
3
),
MedianFiltering
(
-
1
)),
Values
(
ScaleStep
(
0.3
),
ScaleStep
(
0.5
))
)
);
}
}
// 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