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
99f29b75
Commit
99f29b75
authored
Mar 30, 2012
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added linear similarity estimation into videostab module
parent
1af9b8ec
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
5 deletions
+46
-5
global_motion.hpp
...les/videostab/include/opencv2/videostab/global_motion.hpp
+5
-3
global_motion.cpp
modules/videostab/src/global_motion.cpp
+37
-0
stabilizer.cpp
modules/videostab/src/stabilizer.cpp
+1
-1
videostab.cpp
samples/cpp/videostab.cpp
+3
-1
No files found.
modules/videostab/include/opencv2/videostab/global_motion.hpp
View file @
99f29b75
...
...
@@ -57,7 +57,8 @@ enum MotionModel
{
TRANSLATION
=
0
,
TRANSLATION_AND_SCALE
=
1
,
AFFINE
=
2
LINEAR_SIMILARITY
=
2
,
AFFINE
=
3
};
CV_EXPORTS
Mat
estimateGlobalMotionLeastSquares
(
...
...
@@ -74,9 +75,10 @@ struct CV_EXPORTS RansacParams
RansacParams
(
int
size
,
float
thresh
,
float
eps
,
float
prob
)
:
size
(
size
),
thresh
(
thresh
),
eps
(
eps
),
prob
(
prob
)
{}
static
RansacParams
affine2dMotionStd
()
{
return
RansacParams
(
6
,
0.5
f
,
0.5
f
,
0.99
f
);
}
static
RansacParams
translationAndScale2dMotionStd
()
{
return
RansacParams
(
3
,
0.5
f
,
0.5
f
,
0.99
f
);
}
static
RansacParams
translationMotionStd
()
{
return
RansacParams
(
2
,
0.5
f
,
0.5
f
,
0.99
f
);
}
static
RansacParams
translationAndScale2dMotionStd
()
{
return
RansacParams
(
3
,
0.5
f
,
0.5
f
,
0.99
f
);
}
static
RansacParams
linearSimilarityMotionStd
()
{
return
RansacParams
(
4
,
0.5
f
,
0.5
f
,
0.99
f
);
}
static
RansacParams
affine2dMotionStd
()
{
return
RansacParams
(
6
,
0.5
f
,
0.5
f
,
0.99
f
);
}
};
CV_EXPORTS
Mat
estimateGlobalMotionRobust
(
...
...
modules/videostab/src/global_motion.cpp
View file @
99f29b75
...
...
@@ -107,6 +107,41 @@ static Mat estimateGlobMotionLeastSquaresTranslationAndScale(
}
static
Mat
estimateGlobMotionLeastSquaresLinearSimilarity
(
int
npoints
,
const
Point2f
*
points0
,
const
Point2f
*
points1
,
float
*
rmse
)
{
Mat_
<
float
>
A
(
2
*
npoints
,
4
),
b
(
2
*
npoints
,
1
);
float
*
a0
,
*
a1
;
Point2f
p0
,
p1
;
for
(
int
i
=
0
;
i
<
npoints
;
++
i
)
{
a0
=
A
[
2
*
i
];
a1
=
A
[
2
*
i
+
1
];
p0
=
points0
[
i
];
p1
=
points1
[
i
];
a0
[
0
]
=
p0
.
x
;
a0
[
1
]
=
p0
.
y
;
a0
[
2
]
=
1
;
a0
[
3
]
=
0
;
a1
[
0
]
=
p0
.
y
;
a1
[
1
]
=
-
p0
.
x
;
a1
[
2
]
=
0
;
a1
[
3
]
=
1
;
b
(
2
*
i
,
0
)
=
p1
.
x
;
b
(
2
*
i
+
1
,
0
)
=
p1
.
y
;
}
Mat_
<
float
>
sol
;
solve
(
A
,
b
,
sol
,
DECOMP_SVD
);
if
(
rmse
)
*
rmse
=
static_cast
<
float
>
(
norm
(
A
*
sol
,
b
,
NORM_L2
)
/
sqrt
(
static_cast
<
double
>
(
npoints
)));
Mat_
<
float
>
M
=
Mat
::
eye
(
3
,
3
,
CV_32F
);
M
(
0
,
0
)
=
M
(
1
,
1
)
=
sol
(
0
,
0
);
M
(
0
,
1
)
=
sol
(
1
,
0
);
M
(
1
,
0
)
=
-
sol
(
1
,
0
);
M
(
0
,
2
)
=
sol
(
2
,
0
);
M
(
1
,
2
)
=
sol
(
3
,
0
);
return
M
;
}
static
Mat
estimateGlobMotionLeastSquaresAffine
(
int
npoints
,
const
Point2f
*
points0
,
const
Point2f
*
points1
,
float
*
rmse
)
{
...
...
@@ -149,6 +184,7 @@ Mat estimateGlobalMotionLeastSquares(
typedef
Mat
(
*
Impl
)(
int
,
const
Point2f
*
,
const
Point2f
*
,
float
*
);
static
Impl
impls
[]
=
{
estimateGlobMotionLeastSquaresTranslation
,
estimateGlobMotionLeastSquaresTranslationAndScale
,
estimateGlobMotionLeastSquaresLinearSimilarity
,
estimateGlobMotionLeastSquaresAffine
};
int
npoints
=
static_cast
<
int
>
(
points0
.
size
());
...
...
@@ -165,6 +201,7 @@ Mat estimateGlobalMotionRobust(
typedef
Mat
(
*
Impl
)(
int
,
const
Point2f
*
,
const
Point2f
*
,
float
*
);
static
Impl
impls
[]
=
{
estimateGlobMotionLeastSquaresTranslation
,
estimateGlobMotionLeastSquaresTranslationAndScale
,
estimateGlobMotionLeastSquaresLinearSimilarity
,
estimateGlobMotionLeastSquaresAffine
};
const
int
npoints
=
static_cast
<
int
>
(
points0
.
size
());
...
...
modules/videostab/src/stabilizer.cpp
View file @
99f29b75
...
...
@@ -266,7 +266,7 @@ void OnePassStabilizer::stabilizeFrame()
TwoPassStabilizer
::
TwoPassStabilizer
()
{
setMotionStabilizer
(
new
GaussianMotionFilter
());
setEstimateTrimRatio
(
tru
e
);
setEstimateTrimRatio
(
fals
e
);
resetImpl
();
}
...
...
samples/cpp/videostab.cpp
View file @
99f29b75
...
...
@@ -121,7 +121,7 @@ void printHelp()
cout
<<
"OpenCV video stabilizer.
\n
"
"Usage: videostab <file_path> [arguments]
\n\n
"
"Arguments:
\n
"
" -m, --model=(transl|transl_and_scale|affine)
\n
"
" -m, --model=(transl|transl_and_scale|
linear_sim|
affine)
\n
"
" Set motion model. The default is affine.
\n
"
" --outlier-ratio=<float_number>
\n
"
" Outliers ratio in motion estimation. The default is 0.5.
\n
"
...
...
@@ -259,6 +259,8 @@ int main(int argc, const char **argv)
motionEstimator
->
setMotionModel
(
TRANSLATION
);
else
if
(
cmd
.
get
<
string
>
(
"model"
)
==
"transl_and_scale"
)
motionEstimator
->
setMotionModel
(
TRANSLATION_AND_SCALE
);
else
if
(
cmd
.
get
<
string
>
(
"model"
)
==
"linear_sim"
)
motionEstimator
->
setMotionModel
(
LINEAR_SIMILARITY
);
else
if
(
cmd
.
get
<
string
>
(
"model"
)
==
"affine"
)
motionEstimator
->
setMotionModel
(
AFFINE
);
else
if
(
!
cmd
.
get
<
string
>
(
"model"
).
empty
())
...
...
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