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
c8b7a8c8
Commit
c8b7a8c8
authored
Aug 23, 2012
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added median-based version of global motion estimation (videostab)
parent
6a5d996c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
3 deletions
+73
-3
global_motion.hpp
...les/videostab/include/opencv2/videostab/global_motion.hpp
+4
-1
global_motion.cpp
modules/videostab/src/global_motion.cpp
+68
-2
precomp.hpp
modules/videostab/src/precomp.hpp
+1
-0
No files found.
modules/videostab/include/opencv2/videostab/global_motion.hpp
View file @
c8b7a8c8
...
...
@@ -66,7 +66,10 @@ CV_EXPORTS Mat estimateGlobalMotionLeastSquares(
InputOutputArray
points0
,
InputOutputArray
points1
,
int
model
=
MM_AFFINE
,
float
*
rmse
=
0
);
CV_EXPORTS
Mat
estimateGlobalMotionRobust
(
CV_EXPORTS
Mat
estimateGlobalMotionMedian
(
InputArray
points0
,
InputArray
points1
,
int
model
,
int
size
,
int
niters
);
CV_EXPORTS
Mat
estimateGlobalMotionRansac
(
InputArray
points0
,
InputArray
points1
,
int
model
=
MM_AFFINE
,
const
RansacParams
&
params
=
RansacParams
::
default2dMotion
(
MM_AFFINE
),
float
*
rmse
=
0
,
int
*
ninliers
=
0
);
...
...
modules/videostab/src/global_motion.cpp
View file @
c8b7a8c8
...
...
@@ -305,7 +305,73 @@ Mat estimateGlobalMotionLeastSquares(
}
Mat
estimateGlobalMotionRobust
(
Mat
estimateGlobalMotionMedian
(
InputArray
points0
,
InputArray
points1
,
int
model
,
int
size
,
int
niters
)
{
// perform 'niters' iterations over points subsets ('size' elements each) estimating
// motions, after that select median motion parameters from the distribution
CV_Assert
(
model
<=
MM_AFFINE
);
CV_Assert
(
points0
.
type
()
==
points1
.
type
());
const
int
npoints
=
points0
.
getMat
().
checkVector
(
2
);
CV_Assert
(
points1
.
getMat
().
checkVector
(
2
)
==
npoints
);
const
Point2f
*
points0_
=
points0
.
getMat
().
ptr
<
Point2f
>
();
const
Point2f
*
points1_
=
points1
.
getMat
().
ptr
<
Point2f
>
();
// all estimated motions
vector
<
float
>
Ms
[
3
][
3
];
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
j
=
0
;
j
<
3
;
++
j
)
Ms
[
i
][
j
].
resize
(
niters
);
// current hypothesis
vector
<
int
>
indices
(
size
);
vector
<
Point2f
>
subset0
(
size
);
vector
<
Point2f
>
subset1
(
size
);
RNG
rng
(
0
);
for
(
int
iter
=
0
;
iter
<
niters
;
++
iter
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
bool
ok
=
false
;
while
(
!
ok
)
{
ok
=
true
;
indices
[
i
]
=
static_cast
<
unsigned
>
(
rng
)
%
npoints
;
for
(
int
j
=
0
;
j
<
i
;
++
j
)
if
(
indices
[
i
]
==
indices
[
j
])
{
ok
=
false
;
break
;
}
}
}
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
subset0
[
i
]
=
points0_
[
indices
[
i
]];
subset1
[
i
]
=
points1_
[
indices
[
i
]];
}
Mat_
<
float
>
M
=
estimateGlobalMotionLeastSquares
(
subset0
,
subset1
,
model
,
0
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
j
=
0
;
j
<
3
;
++
j
)
Ms
[
i
][
j
][
iter
]
=
M
(
i
,
j
);
}
Mat_
<
float
>
medianM
(
3
,
3
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
j
=
0
;
j
<
3
;
++
j
)
{
nth_element
(
Ms
[
i
][
j
].
begin
(),
Ms
[
i
][
j
].
begin
()
+
niters
/
2
,
Ms
[
i
][
j
].
end
());
medianM
(
i
,
j
)
=
Ms
[
i
][
j
][
niters
/
2
];
}
return
medianM
;
}
Mat
estimateGlobalMotionRansac
(
InputArray
points0
,
InputArray
points1
,
int
model
,
const
RansacParams
&
params
,
float
*
rmse
,
int
*
ninliers
)
{
...
...
@@ -424,7 +490,7 @@ Mat MotionEstimatorRansacL2::estimate(InputArray points0, InputArray points1, bo
Mat_
<
float
>
M
;
if
(
motionModel
()
!=
MM_HOMOGRAPHY
)
M
=
estimateGlobalMotionR
obust
(
M
=
estimateGlobalMotionR
ansac
(
points0
,
points1
,
motionModel
(),
ransacParams_
,
0
,
&
ninliers
);
else
{
...
...
modules/videostab/src/precomp.hpp
View file @
c8b7a8c8
...
...
@@ -50,6 +50,7 @@
#include <stdexcept>
#include <iostream>
#include <ctime>
#include <algorithm>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/video.hpp"
...
...
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