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
3323ee9d
Commit
3323ee9d
authored
Mar 21, 2012
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added distance threshold argument into videostab sample
parent
8fc84b7a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
17 deletions
+35
-17
inpainting.hpp
modules/videostab/include/opencv2/videostab/inpainting.hpp
+5
-1
inpainting.cpp
modules/videostab/src/inpainting.cpp
+11
-5
videostab.cpp
samples/cpp/videostab.cpp
+19
-11
No files found.
modules/videostab/include/opencv2/videostab/inpainting.hpp
View file @
3323ee9d
...
...
@@ -137,6 +137,9 @@ public:
void
setFlowErrorThreshold
(
float
val
)
{
flowErrorThreshold_
=
val
;
}
float
flowErrorThreshold
()
const
{
return
flowErrorThreshold_
;
}
void
setDistThreshold
(
float
val
)
{
distThresh_
=
val
;
}
float
distThresh
()
const
{
return
distThresh_
;
}
void
setBorderMode
(
int
val
)
{
borderMode_
=
val
;
}
int
borderMode
()
const
{
return
borderMode_
;
}
...
...
@@ -146,6 +149,7 @@ private:
FastMarchingMethod
fmm_
;
Ptr
<
IDenseOptFlowEstimator
>
optFlowEstimator_
;
float
flowErrorThreshold_
;
float
distThresh_
;
int
borderMode_
;
Mat
frame1_
,
transformedFrame1_
;
...
...
@@ -184,7 +188,7 @@ CV_EXPORTS void calcFlowMask(
CV_EXPORTS
void
completeFrameAccordingToFlow
(
const
Mat
&
flowMask
,
const
Mat
&
flowX
,
const
Mat
&
flowY
,
const
Mat
&
frame1
,
const
Mat
&
mask1
,
Mat
&
frame0
,
Mat
&
mask0
);
float
distThresh
,
Mat
&
frame0
,
Mat
&
mask0
);
}
// namespace videostab
}
// namespace cv
...
...
modules/videostab/src/inpainting.cpp
View file @
3323ee9d
...
...
@@ -110,7 +110,7 @@ struct Pixel3
ConsistentMosaicInpainter
::
ConsistentMosaicInpainter
()
{
setStdevThresh
(
20
);
setStdevThresh
(
20
.
f
);
}
...
...
@@ -288,6 +288,7 @@ MotionInpainter::MotionInpainter()
CV_Error
(
CV_StsNotImplemented
,
"Current implementation of MotionInpainter requires GPU"
);
#endif
setFlowErrorThreshold
(
1e-4
f
);
setDistThreshold
(
5.
f
);
setBorderMode
(
BORDER_REPLICATE
);
}
...
...
@@ -353,7 +354,8 @@ void MotionInpainter::inpaint(int idx, Mat &frame, Mat &mask)
fmm_
.
run
(
flowMask_
,
body
);
completeFrameAccordingToFlow
(
flowMask_
,
flowX_
,
flowY_
,
transformedFrame1_
,
transformedMask1_
,
frame
,
mask
);
flowMask_
,
flowX_
,
flowY_
,
transformedFrame1_
,
transformedMask1_
,
distThresh_
,
frame
,
mask
);
}
}
...
...
@@ -446,7 +448,7 @@ void calcFlowMask(
void
completeFrameAccordingToFlow
(
const
Mat
&
flowMask
,
const
Mat
&
flowX
,
const
Mat
&
flowY
,
const
Mat
&
frame1
,
const
Mat
&
mask1
,
Mat
&
frame0
,
Mat
&
mask0
)
float
distThresh
,
Mat
&
frame0
,
Mat
&
mask0
)
{
CV_Assert
(
flowMask
.
type
()
==
CV_8U
);
CV_Assert
(
flowX
.
type
()
==
CV_32F
&&
flowX
.
size
()
==
flowMask
.
size
());
...
...
@@ -459,6 +461,7 @@ void completeFrameAccordingToFlow(
Mat_
<
uchar
>
flowMask_
(
flowMask
),
mask1_
(
mask1
),
mask0_
(
mask0
);
Mat_
<
float
>
flowX_
(
flowX
),
flowY_
(
flowY
);
//int count = 0;
for
(
int
y0
=
0
;
y0
<
frame0
.
rows
;
++
y0
)
{
for
(
int
x0
=
0
;
x0
<
frame0
.
cols
;
++
x0
)
...
...
@@ -468,14 +471,17 @@ void completeFrameAccordingToFlow(
int
x1
=
cvRound
(
x0
+
flowX_
(
y0
,
x0
));
int
y1
=
cvRound
(
y0
+
flowY_
(
y0
,
x0
));
if
(
x1
>=
0
&&
x1
<
frame1
.
cols
&&
y1
>=
0
&&
y1
<
frame1
.
rows
&&
mask1_
(
y1
,
x1
))
{
if
(
x1
>=
0
&&
x1
<
frame1
.
cols
&&
y1
>=
0
&&
y1
<
frame1
.
rows
&&
mask1_
(
y1
,
x1
)
&&
sqr
(
flowX_
(
y0
,
x0
))
+
sqr
(
flowY_
(
y0
,
x0
))
<
sqr
(
distThresh
))
{
frame0
.
at
<
Point3_
<
uchar
>
>
(
y0
,
x0
)
=
frame1
.
at
<
Point3_
<
uchar
>
>
(
y1
,
x1
);
mask0_
(
y0
,
x0
)
=
255
;
//count++;
}
}
}
}
//cout << count << endl;
}
}
// namespace videostab
...
...
samples/cpp/videostab.cpp
View file @
3323ee9d
...
...
@@ -57,40 +57,42 @@ void printHelp()
" Outliers ratio in motion estimation. 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
"
" but you may want to increase it.
\n
"
" but you may want to increase it.
\n
\n
"
" -r, --radius=<int_number>
\n
"
" Set smoothing radius. The default is 15.
\n
"
" --stdev=<float_number>
\n
"
" Set smoothing weights standard deviation. The default is sqrt(radius).
\n
"
" Set smoothing weights standard deviation. The default is sqrt(radius).
\n
\n
"
" --deblur=(yes|no)
\n
"
" Do deblurring.
\n
"
" --deblur-sens=<float_number>
\n
"
" Set deblurring sensitivity (from 0 to +inf). The default is 0.1.
\n
"
" Set deblurring sensitivity (from 0 to +inf). The default is 0.1.
\n
\n
"
" -t, --trim-ratio=<float_number>
\n
"
" Set trimming ratio (from 0 to 0.5). The default is 0.
\n
"
" Set trimming ratio (from 0 to 0.5). The default is 0.
0.
\n
"
" --est-trim=(yes|no)
\n
"
" Estimate trim ratio automatically. The default is yes (that leads to two passes,
\n
"
" you can turn it off if you want to use one pass only).
\n
"
" --incl-constr=(yes|no)
\n
"
" Ensure the inclusion constraint is always satisfied. The default is no.
\n
"
" Ensure the inclusion constraint is always satisfied. The default is no.
\n
\n
"
" --border-mode=(replicate|reflect|const)
\n
"
" Set border extrapolation mode. The default is replicate.
\n
"
" Set border extrapolation mode. The default is replicate.
\n
\n
"
" --mosaic=(yes|no)
\n
"
" Do consistent mosaicing. The default is no.
\n
"
" --mosaic-stdev=<float_number>
\n
"
" Consistent mosaicing stdev threshold. The default is 10.
\n
"
" Consistent mosaicing stdev threshold. The default is 10.
0.
\n
\n
"
" --motion-inpaint=(yes|no)
\n
"
" Do motion inpainting (requires GPU support). The default is no.
\n
"
" --dist-thresh=<float_number>
\n
"
" Estimated flow distance threshold for motion inpainting. The default is 5.0.
\n\n
"
" --color-inpaint=(no|average|ns|telea)
\n
"
" Do color inpainting. The defailt is no.
\n
"
" --color-inpaint-radius=<float_number>
\n
"
" Set color inpainting radius (for ns and telea options only).
\n
"
" Set color inpainting radius (for ns and telea options only).
\n
\n
"
" -o, --output=<file_path>
\n
"
" Set output file path explicitely. The default is stabilized.avi.
\n
"
" --fps=<int_number>
\n
"
" Set output video FPS explicitely. By default the source FPS is used.
\n
"
" -q, --quiet
\n
"
" Don't show output video frames.
\n
"
" Don't show output video frames.
\n
\n
"
" -h, --help
\n
"
" Print help.
\n
"
"
\n
"
;
...
...
@@ -117,6 +119,7 @@ int main(int argc, const char **argv)
"{ | mosaic | | }"
"{ | mosaic-stdev | | }"
"{ | motion-inpaint | | }"
"{ | dist-thresh | | }"
"{ | color-inpaint | no | }"
"{ | color-inpaint-radius | | }"
"{ o | output | stabilized.avi | }"
...
...
@@ -212,7 +215,12 @@ int main(int argc, const char **argv)
inpainters
->
pushBack
(
inpainter
);
}
if
(
cmd
.
get
<
string
>
(
"motion-inpaint"
)
==
"yes"
)
inpainters
->
pushBack
(
new
MotionInpainter
());
{
MotionInpainter
*
inpainter
=
new
MotionInpainter
();
if
(
!
cmd
.
get
<
string
>
(
"dist-thresh"
).
empty
())
inpainter
->
setDistThreshold
(
cmd
.
get
<
float
>
(
"dist-thresh"
));
inpainters
->
pushBack
(
inpainter
);
}
if
(
!
cmd
.
get
<
string
>
(
"color-inpaint"
).
empty
())
{
if
(
cmd
.
get
<
string
>
(
"color-inpaint"
)
==
"average"
)
...
...
@@ -254,7 +262,7 @@ int main(int argc, const char **argv)
}
catch
(
const
exception
&
e
)
{
cout
<<
e
.
what
()
<<
endl
;
cout
<<
"error: "
<<
e
.
what
()
<<
endl
;
stabilizer
.
release
();
return
-
1
;
}
...
...
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