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
aee6a617
Commit
aee6a617
authored
May 18, 2013
by
Vadim Pisarevsky
Committed by
OpenCV Buildbot
May 18, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #897 from bitwangyaoyao:2.4_TVL1
parents
528db000
4162ebfa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
155 additions
and
10 deletions
+155
-10
ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+93
-0
arithm.cpp
modules/ocl/src/arithm.cpp
+7
-0
tvl1flow.cl
modules/ocl/src/opencl/tvl1flow.cl
+0
-0
tvl1flow.cpp
modules/ocl/src/tvl1flow.cpp
+0
-0
test_optflow.cpp
modules/ocl/test/test_optflow.cpp
+55
-10
No files found.
modules/ocl/include/opencv2/ocl/ocl.hpp
View file @
aee6a617
...
@@ -407,6 +407,9 @@ namespace cv
...
@@ -407,6 +407,9 @@ namespace cv
//! computes element-wise product of the two arrays (c = a * b)
//! computes element-wise product of the two arrays (c = a * b)
// supports all types except CV_8SC1,CV_8SC2,CV8SC3 and CV_8SC4
// supports all types except CV_8SC1,CV_8SC2,CV8SC3 and CV_8SC4
CV_EXPORTS
void
multiply
(
const
oclMat
&
a
,
const
oclMat
&
b
,
oclMat
&
c
,
double
scale
=
1
);
CV_EXPORTS
void
multiply
(
const
oclMat
&
a
,
const
oclMat
&
b
,
oclMat
&
c
,
double
scale
=
1
);
//! multiplies matrix to a number (dst = scalar * src)
// supports CV_32FC1 only
CV_EXPORTS
void
multiply
(
double
scalar
,
const
oclMat
&
src
,
oclMat
&
dst
);
//! computes element-wise quotient of the two arrays (c = a / b)
//! computes element-wise quotient of the two arrays (c = a / b)
// supports all types except CV_8SC1,CV_8SC2,CV8SC3 and CV_8SC4
// supports all types except CV_8SC1,CV_8SC2,CV8SC3 and CV_8SC4
CV_EXPORTS
void
divide
(
const
oclMat
&
a
,
const
oclMat
&
b
,
oclMat
&
c
,
double
scale
=
1
);
CV_EXPORTS
void
divide
(
const
oclMat
&
a
,
const
oclMat
&
b
,
oclMat
&
c
,
double
scale
=
1
);
...
@@ -1372,6 +1375,7 @@ namespace cv
...
@@ -1372,6 +1375,7 @@ namespace cv
private
:
private
:
oclMat
minSSD
,
leBuf
,
riBuf
;
oclMat
minSSD
,
leBuf
,
riBuf
;
};
};
class
CV_EXPORTS
StereoBeliefPropagation
class
CV_EXPORTS
StereoBeliefPropagation
{
{
public
:
public
:
...
@@ -1402,6 +1406,7 @@ namespace cv
...
@@ -1402,6 +1406,7 @@ namespace cv
std
::
vector
<
oclMat
>
datas
;
std
::
vector
<
oclMat
>
datas
;
oclMat
out
;
oclMat
out
;
};
};
class
CV_EXPORTS
StereoConstantSpaceBP
class
CV_EXPORTS
StereoConstantSpaceBP
{
{
public
:
public
:
...
@@ -1440,6 +1445,94 @@ namespace cv
...
@@ -1440,6 +1445,94 @@ namespace cv
oclMat
temp
;
oclMat
temp
;
oclMat
out
;
oclMat
out
;
};
};
// Implementation of the Zach, Pock and Bischof Dual TV-L1 Optical Flow method
//
// see reference:
// [1] C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow".
// [2] Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation".
class
CV_EXPORTS
OpticalFlowDual_TVL1_OCL
{
public
:
OpticalFlowDual_TVL1_OCL
();
void
operator
()(
const
oclMat
&
I0
,
const
oclMat
&
I1
,
oclMat
&
flowx
,
oclMat
&
flowy
);
void
collectGarbage
();
/**
* Time step of the numerical scheme.
*/
double
tau
;
/**
* Weight parameter for the data term, attachment parameter.
* This is the most relevant parameter, which determines the smoothness of the output.
* The smaller this parameter is, the smoother the solutions we obtain.
* It depends on the range of motions of the images, so its value should be adapted to each image sequence.
*/
double
lambda
;
/**
* Weight parameter for (u - v)^2, tightness parameter.
* It serves as a link between the attachment and the regularization terms.
* In theory, it should have a small value in order to maintain both parts in correspondence.
* The method is stable for a large range of values of this parameter.
*/
double
theta
;
/**
* Number of scales used to create the pyramid of images.
*/
int
nscales
;
/**
* Number of warpings per scale.
* Represents the number of times that I1(x+u0) and grad( I1(x+u0) ) are computed per scale.
* This is a parameter that assures the stability of the method.
* It also affects the running time, so it is a compromise between speed and accuracy.
*/
int
warps
;
/**
* Stopping criterion threshold used in the numerical scheme, which is a trade-off between precision and running time.
* A small value will yield more accurate solutions at the expense of a slower convergence.
*/
double
epsilon
;
/**
* Stopping criterion iterations number used in the numerical scheme.
*/
int
iterations
;
bool
useInitialFlow
;
private
:
void
procOneScale
(
const
oclMat
&
I0
,
const
oclMat
&
I1
,
oclMat
&
u1
,
oclMat
&
u2
);
std
::
vector
<
oclMat
>
I0s
;
std
::
vector
<
oclMat
>
I1s
;
std
::
vector
<
oclMat
>
u1s
;
std
::
vector
<
oclMat
>
u2s
;
oclMat
I1x_buf
;
oclMat
I1y_buf
;
oclMat
I1w_buf
;
oclMat
I1wx_buf
;
oclMat
I1wy_buf
;
oclMat
grad_buf
;
oclMat
rho_c_buf
;
oclMat
p11_buf
;
oclMat
p12_buf
;
oclMat
p21_buf
;
oclMat
p22_buf
;
oclMat
diff_buf
;
oclMat
norm_buf
;
};
}
}
}
}
#if defined _MSC_VER && _MSC_VER >= 1200
#if defined _MSC_VER && _MSC_VER >= 1200
...
...
modules/ocl/src/arithm.cpp
View file @
aee6a617
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
// Jiang Liyuan, jlyuan001.good@163.com
// Jiang Liyuan, jlyuan001.good@163.com
// Rock Li, Rock.Li@amd.com
// Rock Li, Rock.Li@amd.com
// Zailong Wu, bullet@yeah.net
// Zailong Wu, bullet@yeah.net
// Peng Xiao, pengxiao@outlook.com
//
//
// Redistribution and use in source and binary forms, with or without modification,
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
// are permitted provided that the following conditions are met:
...
@@ -286,6 +287,7 @@ void cv::ocl::multiply(const oclMat &src1, const oclMat &src2, oclMat &dst, doub
...
@@ -286,6 +287,7 @@ void cv::ocl::multiply(const oclMat &src1, const oclMat &src2, oclMat &dst, doub
else
else
arithmetic_run
<
float
>
(
src1
,
src2
,
dst
,
"arithm_mul"
,
&
arithm_mul
,
(
void
*
)(
&
scalar
));
arithmetic_run
<
float
>
(
src1
,
src2
,
dst
,
"arithm_mul"
,
&
arithm_mul
,
(
void
*
)(
&
scalar
));
}
}
void
cv
::
ocl
::
divide
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
double
scalar
)
void
cv
::
ocl
::
divide
(
const
oclMat
&
src1
,
const
oclMat
&
src2
,
oclMat
&
dst
,
double
scalar
)
{
{
...
@@ -468,6 +470,11 @@ void cv::ocl::subtract(const Scalar &src2, const oclMat &src1, oclMat &dst, cons
...
@@ -468,6 +470,11 @@ void cv::ocl::subtract(const Scalar &src2, const oclMat &src1, oclMat &dst, cons
const
char
**
kernelString
=
mask
.
data
?
&
arithm_add_scalar_mask
:
&
arithm_add_scalar
;
const
char
**
kernelString
=
mask
.
data
?
&
arithm_add_scalar_mask
:
&
arithm_add_scalar
;
arithmetic_scalar
(
src1
,
src2
,
dst
,
mask
,
kernelName
,
kernelString
,
-
1
);
arithmetic_scalar
(
src1
,
src2
,
dst
,
mask
,
kernelName
,
kernelString
,
-
1
);
}
}
void
cv
::
ocl
::
multiply
(
double
scalar
,
const
oclMat
&
src
,
oclMat
&
dst
)
{
string
kernelName
=
"arithm_muls"
;
arithmetic_scalar_run
(
src
,
dst
,
kernelName
,
&
arithm_mul
,
scalar
);
}
void
cv
::
ocl
::
divide
(
double
scalar
,
const
oclMat
&
src
,
oclMat
&
dst
)
void
cv
::
ocl
::
divide
(
double
scalar
,
const
oclMat
&
src
,
oclMat
&
dst
)
{
{
if
(
!
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
))
if
(
!
src
.
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
))
...
...
modules/ocl/src/opencl/tvl1flow.cl
0 → 100644
View file @
aee6a617
This diff is collapsed.
Click to expand it.
modules/ocl/src/tvl1flow.cpp
0 → 100644
View file @
aee6a617
This diff is collapsed.
Click to expand it.
modules/ocl/test/test_
pyrlk
.cpp
→
modules/ocl/test/test_
optflow
.cpp
View file @
aee6a617
/
*M/
//////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
//
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//
...
@@ -7,12 +7,16 @@
...
@@ -7,12 +7,16 @@
// copy or use the software.
// copy or use the software.
//
//
//
//
//
Intel
License Agreement
//
License Agreement
// For Open Source Computer Vision Library
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// 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.
// Third party copyrights are property of their respective owners.
// Third party copyrights are property of their respective owners.
//
//
// @Authors
//
//
// Redistribution and use in source and binary forms, with or without modification,
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
// are permitted provided that the following conditions are met:
//
//
...
@@ -21,9 +25,9 @@
...
@@ -21,9 +25,9 @@
//
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// this list of conditions and the following disclaimer in the documentation
// and/or other
m
aterials provided with the distribution.
// and/or other
oclM
aterials provided with the distribution.
//
//
// * The name of
Intel Corporation
may not be used to endorse or promote products
// * The name of
the copyright holders
may not be used to endorse or promote products
// derived from this software without specific prior written permission.
// derived from this software without specific prior written permission.
//
//
// This software is provided by the copyright holders and contributors "as is" and
// This software is provided by the copyright holders and contributors "as is" and
...
@@ -51,6 +55,47 @@ using namespace testing;
...
@@ -51,6 +55,47 @@ using namespace testing;
using
namespace
std
;
using
namespace
std
;
extern
string
workdir
;
extern
string
workdir
;
//////////////////////////////////////////////////////////////////////////
PARAM_TEST_CASE
(
TVL1
,
bool
)
{
bool
useRoi
;
virtual
void
SetUp
()
{
useRoi
=
GET_PARAM
(
0
);
}
};
TEST_P
(
TVL1
,
Accuracy
)
{
cv
::
Mat
frame0
=
readImage
(
workdir
+
"../gpu/rubberwhale1.png"
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame0
.
empty
());
cv
::
Mat
frame1
=
readImage
(
workdir
+
"../gpu/rubberwhale2.png"
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
frame1
.
empty
());
cv
::
ocl
::
OpticalFlowDual_TVL1_OCL
d_alg
;
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Mat
flowx
=
randomMat
(
rng
,
frame0
.
size
(),
CV_32FC1
,
0
,
0
,
useRoi
);
cv
::
Mat
flowy
=
randomMat
(
rng
,
frame0
.
size
(),
CV_32FC1
,
0
,
0
,
useRoi
);
cv
::
ocl
::
oclMat
d_flowx
(
flowx
),
d_flowy
(
flowy
);
d_alg
(
oclMat
(
frame0
),
oclMat
(
frame1
),
d_flowx
,
d_flowy
);
cv
::
Ptr
<
cv
::
DenseOpticalFlow
>
alg
=
cv
::
createOptFlow_DualTVL1
();
cv
::
Mat
flow
;
alg
->
calc
(
frame0
,
frame1
,
flow
);
cv
::
Mat
gold
[
2
];
cv
::
split
(
flow
,
gold
);
EXPECT_MAT_SIMILAR
(
gold
[
0
],
d_flowx
,
3e-3
);
EXPECT_MAT_SIMILAR
(
gold
[
1
],
d_flowy
,
3e-3
);
}
INSTANTIATE_TEST_CASE_P
(
OCL_Video
,
TVL1
,
Values
(
true
,
false
));
/////////////////////////////////////////////////////////////////////////////////////////////////
// PyrLKOpticalFlow
PARAM_TEST_CASE
(
Sparse
,
bool
,
bool
)
PARAM_TEST_CASE
(
Sparse
,
bool
,
bool
)
{
{
...
@@ -60,7 +105,7 @@ PARAM_TEST_CASE(Sparse, bool, bool)
...
@@ -60,7 +105,7 @@ PARAM_TEST_CASE(Sparse, bool, bool)
virtual
void
SetUp
()
virtual
void
SetUp
()
{
{
UseSmart
=
GET_PARAM
(
0
);
UseSmart
=
GET_PARAM
(
0
);
useGray
=
GET_PARAM
(
0
);
useGray
=
GET_PARAM
(
1
);
}
}
};
};
...
@@ -147,9 +192,9 @@ TEST_P(Sparse, Mat)
...
@@ -147,9 +192,9 @@ TEST_P(Sparse, Mat)
}
}
INSTANTIATE_TEST_CASE_P
(
Video
,
Sparse
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
OCL_
Video
,
Sparse
,
Combine
(
Values
(
false
,
true
),
Values
(
false
,
true
),
Values
(
fals
e
)));
Values
(
false
,
tru
e
)));
#endif // HAVE_OPENCL
#endif // HAVE_OPENCL
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