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
36ef5998
Commit
36ef5998
authored
Apr 23, 2012
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed trim ratio estimation for the case of homographies motion model (videostab)
parent
ae8d3775
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
18 deletions
+30
-18
motion_stabilizing.cpp
modules/videostab/src/motion_stabilizing.cpp
+15
-3
videostab.cpp
samples/cpp/videostab.cpp
+15
-15
No files found.
modules/videostab/src/motion_stabilizing.cpp
View file @
36ef5998
...
...
@@ -616,11 +616,15 @@ static inline bool isGoodMotion(const float M[], float w, float h, float dx, flo
{
Point2f
pt
[
4
]
=
{
Point2f
(
0
,
0
),
Point2f
(
w
,
0
),
Point2f
(
w
,
h
),
Point2f
(
0
,
h
)};
Point2f
Mpt
[
4
];
float
z
;
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
Mpt
[
i
].
x
=
M
[
0
]
*
pt
[
i
].
x
+
M
[
1
]
*
pt
[
i
].
y
+
M
[
2
];
Mpt
[
i
].
y
=
M
[
3
]
*
pt
[
i
].
x
+
M
[
4
]
*
pt
[
i
].
y
+
M
[
5
];
z
=
M
[
6
]
*
pt
[
i
].
x
+
M
[
7
]
*
pt
[
i
].
y
+
M
[
8
];
Mpt
[
i
].
x
/=
z
;
Mpt
[
i
].
y
/=
z
;
}
pt
[
0
]
=
Point2f
(
dx
,
dy
);
...
...
@@ -640,6 +644,9 @@ static inline void relaxMotion(const float M[], float t, float res[])
res
[
3
]
=
M
[
3
]
*
(
1.
f
-
t
);
res
[
4
]
=
M
[
4
]
*
(
1.
f
-
t
)
+
t
;
res
[
5
]
=
M
[
5
]
*
(
1.
f
-
t
);
res
[
6
]
=
M
[
6
]
*
(
1.
f
-
t
);
res
[
7
]
=
M
[
7
]
*
(
1.
f
-
t
);
res
[
8
]
=
M
[
8
]
*
(
1.
f
-
t
)
+
t
;
}
...
...
@@ -651,11 +658,12 @@ Mat ensureInclusionConstraint(const Mat &M, Size size, float trimRatio)
const
float
h
=
static_cast
<
float
>
(
size
.
height
);
const
float
dx
=
floor
(
w
*
trimRatio
);
const
float
dy
=
floor
(
h
*
trimRatio
);
const
float
srcM
[
6
]
=
const
float
srcM
[]
=
{
M
.
at
<
float
>
(
0
,
0
),
M
.
at
<
float
>
(
0
,
1
),
M
.
at
<
float
>
(
0
,
2
),
M
.
at
<
float
>
(
1
,
0
),
M
.
at
<
float
>
(
1
,
1
),
M
.
at
<
float
>
(
1
,
2
)};
M
.
at
<
float
>
(
1
,
0
),
M
.
at
<
float
>
(
1
,
1
),
M
.
at
<
float
>
(
1
,
2
),
M
.
at
<
float
>
(
2
,
0
),
M
.
at
<
float
>
(
2
,
1
),
M
.
at
<
float
>
(
2
,
2
)};
float
curM
[
6
];
float
curM
[
9
];
float
t
=
0
;
relaxMotion
(
srcM
,
t
,
curM
);
if
(
isGoodMotion
(
curM
,
w
,
h
,
dx
,
dy
))
...
...
@@ -687,11 +695,15 @@ float estimateOptimalTrimRatio(const Mat &M, Size size)
Point2f
pt
[
4
]
=
{
Point2f
(
0
,
0
),
Point2f
(
w
,
0
),
Point2f
(
w
,
h
),
Point2f
(
0
,
h
)};
Point2f
Mpt
[
4
];
float
z
;
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
Mpt
[
i
].
x
=
M_
(
0
,
0
)
*
pt
[
i
].
x
+
M_
(
0
,
1
)
*
pt
[
i
].
y
+
M_
(
0
,
2
);
Mpt
[
i
].
y
=
M_
(
1
,
0
)
*
pt
[
i
].
x
+
M_
(
1
,
1
)
*
pt
[
i
].
y
+
M_
(
1
,
2
);
z
=
M_
(
2
,
0
)
*
pt
[
i
].
x
+
M_
(
2
,
1
)
*
pt
[
i
].
y
+
M_
(
2
,
2
);
Mpt
[
i
].
x
/=
z
;
Mpt
[
i
].
y
/=
z
;
}
float
l
=
0
,
r
=
0.5
f
;
...
...
samples/cpp/videostab.cpp
View file @
36ef5998
...
...
@@ -95,15 +95,15 @@ void printHelp()
" (i.e. sqrt(radius)).
\n
"
" -lps, --lin-prog-stab=(yes|no)
\n
"
" Turn on/off linear programming based stabilization method.
\n
"
" --lp-trim-ratio=(<float_number>|auto)
\n
"
" --lp
s
-trim-ratio=(<float_number>|auto)
\n
"
" Trimming ratio used in linear programming based method.
\n
"
" --lp-w1=(<float_number>|1)
\n
"
" --lp
s
-w1=(<float_number>|1)
\n
"
" 1st derivative weight. The default is 1.
\n
"
" --lp-w2=(<float_number>|10)
\n
"
" --lp
s
-w2=(<float_number>|10)
\n
"
" 2nd derivative weight. The default is 10.
\n
"
" --lp-w3=(<float_number>|100)
\n
"
" --lp
s
-w3=(<float_number>|100)
\n
"
" 3rd derivative weight. The default is 100.
\n
"
" --lp-w4=(<float_number>|100)
\n
"
" --lp
s
-w4=(<float_number>|100)
\n
"
" Non-translation motion components weight. The default is 100.
\n\n
"
" --deblur=(yes|no)
\n
"
" Do deblurring.
\n
"
...
...
@@ -185,11 +185,11 @@ int main(int argc, const char **argv)
"{ r | radius | 15 | }"
"{ | stdev | auto | }"
"{ lps | lin-prog-stab | no | }"
"{ | lp-trim-ratio | auto | }"
"{ | lp-w1 | 1 | }"
"{ | lp-w2 | 10 | }"
"{ | lp-w3 | 100 | }"
"{ | lp-w4 | 100 | }"
"{ | lp
s
-trim-ratio | auto | }"
"{ | lp
s
-w1 | 1 | }"
"{ | lp
s
-w2 | 10 | }"
"{ | lp
s
-w3 | 100 | }"
"{ | lp
s
-w4 | 100 | }"
"{ | deblur | no | }"
"{ | deblur-sens | 0.1 | }"
"{ et | est-trim | yes | }"
...
...
@@ -260,11 +260,11 @@ int main(int argc, const char **argv)
{
LpMotionStabilizer
*
stab
=
new
LpMotionStabilizer
();
stab
->
setFrameSize
(
Size
(
source
->
width
(),
source
->
height
()));
stab
->
setTrimRatio
(
arg
(
"lp
-trim-ratio"
)
==
"auto"
?
argf
(
"trim-ratio"
)
:
argf
(
"lp
-trim-ratio"
));
stab
->
setWeight1
(
argf
(
"lp-w1"
));
stab
->
setWeight2
(
argf
(
"lp-w2"
));
stab
->
setWeight3
(
argf
(
"lp-w3"
));
stab
->
setWeight4
(
argf
(
"lp-w4"
));
stab
->
setTrimRatio
(
arg
(
"lp
s-trim-ratio"
)
==
"auto"
?
argf
(
"trim-ratio"
)
:
argf
(
"lps
-trim-ratio"
));
stab
->
setWeight1
(
argf
(
"lp
s
-w1"
));
stab
->
setWeight2
(
argf
(
"lp
s
-w2"
));
stab
->
setWeight3
(
argf
(
"lp
s
-w3"
));
stab
->
setWeight4
(
argf
(
"lp
s
-w4"
));
twoPassStabilizer
->
setMotionStabilizer
(
stab
);
}
else
if
(
arg
(
"stdev"
)
==
"auto"
)
...
...
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