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
b5a1bad7
Commit
b5a1bad7
authored
Apr 11, 2012
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more flags for motion estimation in videostab sample
parent
b549900f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
3 deletions
+40
-3
global_motion.hpp
...les/videostab/include/opencv2/videostab/global_motion.hpp
+4
-0
global_motion.cpp
modules/videostab/src/global_motion.cpp
+16
-0
stabilizer.cpp
modules/videostab/src/stabilizer.cpp
+1
-0
videostab.cpp
samples/cpp/videostab.cpp
+19
-3
No files found.
modules/videostab/include/opencv2/videostab/global_motion.hpp
View file @
b5a1bad7
...
...
@@ -148,6 +148,9 @@ public:
void
setMinInlierRatio
(
float
val
)
{
minInlierRatio_
=
val
;
}
float
minInlierRatio
()
const
{
return
minInlierRatio_
;
}
void
setGridSize
(
Size
val
)
{
gridSize_
=
val
;
}
Size
gridSize
()
const
{
return
gridSize_
;
}
virtual
Mat
estimate
(
const
Mat
&
frame0
,
const
Mat
&
frame1
,
bool
*
ok
=
0
);
private
:
...
...
@@ -160,6 +163,7 @@ private:
std
::
vector
<
Point2f
>
pointsPrevGood_
,
pointsGood_
;
float
maxRmse_
;
float
minInlierRatio_
;
Size
gridSize_
;
};
CV_EXPORTS
Mat
getMotion
(
int
from
,
int
to
,
const
std
::
vector
<
Mat
>
&
motions
);
...
...
modules/videostab/src/global_motion.cpp
View file @
b5a1bad7
...
...
@@ -344,6 +344,7 @@ PyrLkRobustMotionEstimator::PyrLkRobustMotionEstimator(MotionModel model)
setRansacParams
(
RansacParams
::
homography2dMotionStd
());
setMaxRmse
(
0.5
f
);
setMinInlierRatio
(
0.1
f
);
setGridSize
(
Size
(
0
,
0
));
}
...
...
@@ -351,6 +352,21 @@ Mat PyrLkRobustMotionEstimator::estimate(const Mat &frame0, const Mat &frame1, b
{
detector_
->
detect
(
frame0
,
keypointsPrev_
);
// add extra keypoints
if
(
gridSize_
.
width
>
0
&&
gridSize_
.
height
>
0
)
{
float
dx
=
(
float
)
frame0
.
cols
/
(
gridSize_
.
width
+
1
);
float
dy
=
(
float
)
frame0
.
rows
/
(
gridSize_
.
height
+
1
);
for
(
int
x
=
0
;
x
<
gridSize_
.
width
;
++
x
)
for
(
int
y
=
0
;
y
<
gridSize_
.
height
;
++
y
)
keypointsPrev_
.
push_back
(
KeyPoint
((
x
+
1
)
*
dx
,
(
y
+
1
)
*
dy
,
0.
f
));
}
/*Mat img;
drawKeypoints(frame0, keypointsPrev_, img);
imshow("frame0_keypoints", img);
waitKey(3);*/
pointsPrev_
.
resize
(
keypointsPrev_
.
size
());
for
(
size_t
i
=
0
;
i
<
keypointsPrev_
.
size
();
++
i
)
pointsPrev_
[
i
]
=
keypointsPrev_
[
i
].
pt
;
...
...
modules/videostab/src/stabilizer.cpp
View file @
b5a1bad7
...
...
@@ -375,6 +375,7 @@ void TwoPassStabilizer::runPrePassIfNecessary()
motionStabilizer_
->
stabilize
(
frameCount_
,
motions_
,
make_pair
(
0
,
frameCount_
-
1
),
&
stabilizationMotions_
[
0
]);
// save motions
/*ofstream fm("log_motions.csv");
for (int i = 0; i < frameCount_ - 1; ++i)
{
...
...
samples/cpp/videostab.cpp
View file @
b5a1bad7
...
...
@@ -68,9 +68,13 @@ void printHelp()
" -m, --model=(transl|transl_and_scale|linear_sim|affine|homography)
\n
"
" Set motion model. The default is affine.
\n
"
" --outlier-ratio=<float_number>
\n
"
" Motion estimation outlier ratio hypothesis. The default is 0.5."
" Motion estimation outlier ratio hypothesis. The default is 0.5.
\n
"
" --min-inlier-ratio=<float_number>
\n
"
" Minimum inlier ratio to decide if estimated motion is OK. The default is 0.1.
\n\n
"
" Minimum inlier ratio to decide if estimated motion is OK. The default is 0.1.
\n
"
" --nkps=<int_number>
\n
"
" Number of keypoints to find in each frame. The default is 1000.
\n
"
" --extra-kps=<int_number>
\n
"
" Extra keypoint grid size for motion estimation. The default is 0.
\n\n
"
" -sm, --save-motions=(<file_path>|no)
\n
"
" Save estimated motions into file. The default is no.
\n
"
" -lm, --load-motions=(<file_path>|no)
\n
"
...
...
@@ -116,6 +120,10 @@ void printHelp()
" Minimum inlier ratio to decide if estimated motion is OK. The default is 0.1.
\n
"
" --ws-outlier-ratio=<float_number>
\n
"
" Motion estimation outlier ratio hypothesis. The default is 0.5.
\n
"
" --ws-nkps=<int_number>
\n
"
" Number of keypoints to find in each frame. The default is 1000.
\n
"
" --ws-extra-kps=<int_number>
\n
"
" Extra keypoint grid size for motion estimation. The default is 0.
\n\n
"
" -sm2, --save-motions2=(<file_path>|no)
\n
"
" Save motions estimated for wobble suppression. The default is no.
\n
"
" -lm2, --load-motions2=(<file_path>|no)
\n
"
...
...
@@ -141,6 +149,8 @@ int main(int argc, const char **argv)
"{ m | model | affine| }"
"{ | min-inlier-ratio | 0.1 | }"
"{ | outlier-ratio | 0.5 | }"
"{ | nkps | 1000 | }"
"{ | extra-kps | 0 | }"
"{ sm | save-motions | no | }"
"{ lm | load-motions | no | }"
"{ r | radius | 15 | }"
...
...
@@ -162,6 +172,8 @@ int main(int argc, const char **argv)
"{ | ws-model | homography | }"
"{ | ws-min-inlier-ratio | 0.1 | }"
"{ | ws-outlier-ratio | 0.5 | }"
"{ | ws-nkps | 1000 | }"
"{ | ws-extra-kps | 0 | }"
"{ sm2 | save-motions2 | no | }"
"{ lm2 | load-motions2 | no | }"
"{ o | output | stabilized.avi | }"
...
...
@@ -216,11 +228,13 @@ int main(int argc, const char **argv)
throw
runtime_error
(
"unknown wobble suppression motion model: "
+
arg
(
"ws-model"
));
}
est
->
setDetector
(
new
GoodFeaturesToTrackDetector
(
argi
(
"ws-nkps"
)));
RansacParams
ransac
=
est
->
ransacParams
();
ransac
.
eps
=
argf
(
"ws-outlier-ratio"
);
est
->
setRansacParams
(
ransac
);
est
->
setMinInlierRatio
(
argf
(
"ws-min-inlier-ratio"
));
ws
->
setMotionEstimator
(
est
);
est
->
setGridSize
(
Size
(
argi
(
"ws-extra-kps"
),
argi
(
"ws-extra-kps"
)));
ws
->
setMotionEstimator
(
est
);
MotionModel
model
=
est
->
motionModel
();
if
(
arg
(
"load-motions2"
)
!=
"no"
)
...
...
@@ -272,10 +286,12 @@ int main(int argc, const char **argv)
throw
runtime_error
(
"unknown motion model: "
+
arg
(
"model"
));
}
est
->
setDetector
(
new
GoodFeaturesToTrackDetector
(
argi
(
"nkps"
)));
RansacParams
ransac
=
est
->
ransacParams
();
ransac
.
eps
=
argf
(
"outlier-ratio"
);
est
->
setRansacParams
(
ransac
);
est
->
setMinInlierRatio
(
argf
(
"min-inlier-ratio"
));
est
->
setGridSize
(
Size
(
argi
(
"extra-kps"
),
argi
(
"extra-kps"
)));
stabilizer
->
setMotionEstimator
(
est
);
MotionModel
model
=
stabilizer
->
motionEstimator
()
->
motionModel
();
...
...
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