Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
1417dc65
Commit
1417dc65
authored
May 21, 2016
by
Vladislav Samsonov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Boosted accuracy a little bit more
parent
76ee8380
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
pcaflow.hpp
modules/optflow/include/opencv2/optflow/pcaflow.hpp
+3
-1
pcaflow.cpp
modules/optflow/src/pcaflow.cpp
+8
-9
No files found.
modules/optflow/include/opencv2/optflow/pcaflow.hpp
View file @
1417dc65
...
@@ -172,10 +172,12 @@ protected:
...
@@ -172,10 +172,12 @@ protected:
const
float
sparseRate
;
// (0 .. 0.1)
const
float
sparseRate
;
// (0 .. 0.1)
const
float
retainedCornersFraction
;
// [0 .. 1]
const
float
retainedCornersFraction
;
// [0 .. 1]
const
float
occlusionsThreshold
;
const
float
occlusionsThreshold
;
const
float
dampingFactor
;
public
:
public
:
OpticalFlowPCAFlow
(
const
Size
_basisSize
=
Size
(
18
,
14
),
float
_sparseRate
=
0.02
,
OpticalFlowPCAFlow
(
const
Size
_basisSize
=
Size
(
18
,
14
),
float
_sparseRate
=
0.02
,
float
_retainedCornersFraction
=
1.0
,
float
_occlusionsThreshold
=
0.00002
);
float
_retainedCornersFraction
=
0.7
,
float
_occlusionsThreshold
=
0.0003
,
float
_dampingFactor
=
0.00002
);
void
calc
(
InputArray
I0
,
InputArray
I1
,
InputOutputArray
flow
);
void
calc
(
InputArray
I0
,
InputArray
I1
,
InputOutputArray
flow
);
void
collectGarbage
();
void
collectGarbage
();
...
...
modules/optflow/src/pcaflow.cpp
View file @
1417dc65
...
@@ -51,9 +51,9 @@ namespace optflow
...
@@ -51,9 +51,9 @@ namespace optflow
{
{
OpticalFlowPCAFlow
::
OpticalFlowPCAFlow
(
const
Size
_basisSize
,
float
_sparseRate
,
float
_retainedCornersFraction
,
OpticalFlowPCAFlow
::
OpticalFlowPCAFlow
(
const
Size
_basisSize
,
float
_sparseRate
,
float
_retainedCornersFraction
,
float
_occlusionsThreshold
)
float
_occlusionsThreshold
,
float
_dampingFactor
)
:
basisSize
(
_basisSize
),
sparseRate
(
_sparseRate
),
retainedCornersFraction
(
_retainedCornersFraction
),
:
basisSize
(
_basisSize
),
sparseRate
(
_sparseRate
),
retainedCornersFraction
(
_retainedCornersFraction
),
occlusionsThreshold
(
_occlusionsThreshold
)
occlusionsThreshold
(
_occlusionsThreshold
)
,
dampingFactor
(
_dampingFactor
)
{
{
CV_Assert
(
sparseRate
>
0
&&
sparseRate
<=
0.1
);
CV_Assert
(
sparseRate
>
0
&&
sparseRate
<=
0.1
);
CV_Assert
(
retainedCornersFraction
>=
0
&&
retainedCornersFraction
<=
1.0
);
CV_Assert
(
retainedCornersFraction
>=
0
&&
retainedCornersFraction
<=
1.0
);
...
@@ -216,13 +216,13 @@ void OpticalFlowPCAFlow::removeOcclusions( Mat &from, Mat &to, std::vector<Point
...
@@ -216,13 +216,13 @@ void OpticalFlowPCAFlow::removeOcclusions( Mat &from, Mat &to, std::vector<Point
calcOpticalFlowPyrLK
(
to
,
from
,
predictedFeatures
,
backwardFeatures
,
predictedStatus
,
predictedError
);
calcOpticalFlowPyrLK
(
to
,
from
,
predictedFeatures
,
backwardFeatures
,
predictedStatus
,
predictedError
);
size_t
j
=
0
;
size_t
j
=
0
;
const
float
threshold
=
occlusionsThreshold
*
from
.
size
().
area
(
);
const
float
threshold
=
occlusionsThreshold
*
sqrt
(
from
.
size
().
area
()
);
for
(
size_t
i
=
0
;
i
<
predictedFeatures
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
predictedFeatures
.
size
();
++
i
)
{
{
if
(
predictedStatus
[
i
]
)
if
(
predictedStatus
[
i
]
)
{
{
Point2f
flowDiff
=
features
[
i
]
-
backwardFeatures
[
i
];
Point2f
flowDiff
=
features
[
i
]
-
backwardFeatures
[
i
];
if
(
eNormSq
(
flowDiff
)
<
threshold
)
if
(
eNormSq
(
flowDiff
)
<
=
threshold
)
{
{
features
[
j
]
=
features
[
i
];
features
[
j
]
=
features
[
i
];
predictedFeatures
[
j
]
=
predictedFeatures
[
i
];
predictedFeatures
[
j
]
=
predictedFeatures
[
i
];
...
@@ -325,8 +325,8 @@ void OpticalFlowPCAFlow::calc( InputArray I0, InputArray I1, InputOutputArray fl
...
@@ -325,8 +325,8 @@ void OpticalFlowPCAFlow::calc( InputArray I0, InputArray I1, InputOutputArray fl
CV_Assert
(
from
.
channels
()
==
1
);
CV_Assert
(
from
.
channels
()
==
1
);
CV_Assert
(
to
.
channels
()
==
1
);
CV_Assert
(
to
.
channels
()
==
1
);
applyCLAHE
(
from
);
applyCLAHE
(
from
);
applyCLAHE
(
to
);
applyCLAHE
(
to
);
std
::
vector
<
Point2f
>
features
,
predictedFeatures
;
std
::
vector
<
Point2f
>
features
,
predictedFeatures
;
findSparseFeatures
(
from
,
to
,
features
,
predictedFeatures
);
findSparseFeatures
(
from
,
to
,
features
,
predictedFeatures
);
...
@@ -337,7 +337,6 @@ void OpticalFlowPCAFlow::calc( InputArray I0, InputArray I1, InputOutputArray fl
...
@@ -337,7 +337,6 @@ void OpticalFlowPCAFlow::calc( InputArray I0, InputArray I1, InputOutputArray fl
flowOut
.
create
(
size
,
CV_32FC2
);
flowOut
.
create
(
size
,
CV_32FC2
);
Mat
flow
=
flowOut
.
getMat
();
Mat
flow
=
flowOut
.
getMat
();
// interpolateSparseFlow(flow, features, predictedFeatures);
// for ( size_t i = 0; i < features.size(); ++i )
// for ( size_t i = 0; i < features.size(); ++i )
// flow.at<Point2f>( features[i].y, features[i].x ) = /*Point2f(10,10);*/ predictedFeatures[i] - features[i];
// flow.at<Point2f>( features[i].y, features[i].x ) = /*Point2f(10,10);*/ predictedFeatures[i] - features[i];
...
@@ -345,8 +344,8 @@ void OpticalFlowPCAFlow::calc( InputArray I0, InputArray I1, InputOutputArray fl
...
@@ -345,8 +344,8 @@ void OpticalFlowPCAFlow::calc( InputArray I0, InputArray I1, InputOutputArray fl
getSystem
(
A
,
b1
,
b2
,
features
,
predictedFeatures
,
size
);
getSystem
(
A
,
b1
,
b2
,
features
,
predictedFeatures
,
size
);
// solve( A1, b1, w1, DECOMP_CHOLESKY | DECOMP_NORMAL );
// solve( A1, b1, w1, DECOMP_CHOLESKY | DECOMP_NORMAL );
// solve( A2, b2, w2, DECOMP_CHOLESKY | DECOMP_NORMAL );
// solve( A2, b2, w2, DECOMP_CHOLESKY | DECOMP_NORMAL );
solveLSQR
(
A
,
b1
,
w1
,
0.00002
*
size
.
area
()
);
solveLSQR
(
A
,
b1
,
w1
,
dampingFactor
*
size
.
area
()
);
solveLSQR
(
A
,
b2
,
w2
,
0.00002
*
size
.
area
()
);
solveLSQR
(
A
,
b2
,
w2
,
dampingFactor
*
size
.
area
()
);
Mat
flowSmall
(
basisSize
*
16
,
CV_32FC2
);
Mat
flowSmall
(
basisSize
*
16
,
CV_32FC2
);
reduceToFlow
(
w1
,
w2
,
flowSmall
,
basisSize
);
reduceToFlow
(
w1
,
w2
,
flowSmall
,
basisSize
);
resize
(
flowSmall
,
flow
,
size
,
0
,
0
,
INTER_LINEAR
);
resize
(
flowSmall
,
flow
,
size
,
0
,
0
,
INTER_LINEAR
);
...
...
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