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
24206bd1
Commit
24206bd1
authored
Dec 21, 2010
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added more controls into gpu stereo sample
parent
5bfb44f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
15 deletions
+112
-15
stereo_match.cpp
samples/gpu/stereo_match.cpp
+112
-15
No files found.
samples/gpu/stereo_match.cpp
View file @
24206bd1
...
...
@@ -17,7 +17,17 @@ struct Params
string
left
;
string
right
;
string
method_str
;
string
method_str
()
const
{
switch
(
method
)
{
case
BM
:
return
"BM"
;
case
BP
:
return
"BP"
;
case
CSBP
:
return
"CSBP"
;
}
return
""
;
}
enum
{
BM
,
BP
,
CSBP
}
method
;
int
ndisp
;
// Max disparity + 1
};
...
...
@@ -28,6 +38,7 @@ struct App
App
(
const
Params
&
p
);
void
run
();
void
handleKey
(
char
key
);
void
printParams
()
const
;
void
workBegin
()
{
work_begin
=
getTickCount
();
}
void
workEnd
()
...
...
@@ -40,7 +51,7 @@ struct App
string
text
()
const
{
stringstream
ss
;
ss
<<
"("
<<
p
.
method_str
<<
") FPS: "
<<
setiosflags
(
ios
::
left
)
<<
setprecision
(
4
)
<<
work_fps
;
ss
<<
"("
<<
p
.
method_str
()
<<
") FPS: "
<<
setiosflags
(
ios
::
left
)
<<
setprecision
(
4
)
<<
work_fps
;
return
ss
.
str
();
}
private
:
...
...
@@ -80,6 +91,7 @@ int main(int argc, char** argv)
Params
::
Params
()
{
method
=
BM
;
ndisp
=
64
;
}
...
...
@@ -100,7 +112,6 @@ Params Params::read(int argc, char** argv)
else
if
(
val
==
"BP"
)
p
.
method
=
BP
;
else
if
(
val
==
"CSBP"
)
p
.
method
=
CSBP
;
else
throw
runtime_error
(
"unknown stereo match method: "
+
val
);
p
.
method_str
=
val
;
}
else
if
(
key
==
"-ndisp"
)
p
.
ndisp
=
atoi
(
val
.
c_str
());
else
throw
runtime_error
(
"unknown key: "
+
key
);
...
...
@@ -116,8 +127,12 @@ App::App(const Params& p)
cout
<<
"stereo_match_gpu sample
\n
"
;
cout
<<
"
\n
Controls:
\n
"
<<
"
\t
esc - exit
\n
"
<<
"
\t
p - print current parameters
\n
"
<<
"
\t
m - change stereo match method
\n
"
<<
"
\t
1/q - increase/decrease max disprity
\n
"
;
<<
"
\t
1/q - increase/decrease maximum disparity
\n
"
<<
"
\t
2/w - increase/decrease window size (for BM only)
\n
"
<<
"
\t
3/e - increase/decrease iteration count (for BP and CSBP only)
\n
"
<<
"
\t
4/r - increase/decrease level count (for BP and CSBP only)
\n
"
;
}
...
...
@@ -149,11 +164,8 @@ void App::run()
Mat
disp
(
left
.
size
(),
CV_8U
);
gpu
::
GpuMat
d_disp
(
left
.
size
(),
CV_8U
);
// Show initial parameters
cout
<<
"
\n
Initial Params:
\n
"
<<
"
\t
image_size: ("
<<
left
.
cols
<<
", "
<<
left
.
rows
<<
")
\n
"
<<
"
\t
method: "
<<
p
.
method_str
<<
endl
<<
"
\t
ndisp: "
<<
p
.
ndisp
<<
endl
<<
endl
;
cout
<<
"
\n
image_size: ("
<<
left
.
cols
<<
", "
<<
left
.
rows
<<
")
\n
"
;
printParams
();
running
=
true
;
while
(
running
)
...
...
@@ -177,6 +189,29 @@ void App::run()
}
void
App
::
printParams
()
const
{
cout
<<
"--- Parameters ---
\n
"
;
cout
<<
"method: "
<<
p
.
method_str
()
<<
endl
<<
"ndisp: "
<<
p
.
ndisp
<<
endl
;
switch
(
p
.
method
)
{
case
Params
:
:
BM
:
cout
<<
"win_size: "
<<
bm
.
winSize
<<
endl
;
break
;
case
Params
:
:
BP
:
cout
<<
"iter_count: "
<<
bp
.
iters
<<
endl
;
cout
<<
"level_count: "
<<
bp
.
levels
<<
endl
;
break
;
case
Params
:
:
CSBP
:
cout
<<
"iter_count: "
<<
csbp
.
iters
<<
endl
;
cout
<<
"level_count: "
<<
csbp
.
levels
<<
endl
;
break
;
}
cout
<<
endl
;
}
void
App
::
handleKey
(
char
key
)
{
switch
(
key
)
...
...
@@ -184,37 +219,99 @@ void App::handleKey(char key)
case
27
:
running
=
false
;
break
;
case
'p'
:
case
'P'
:
printParams
();
break
;
case
'm'
:
case
'M'
:
switch
(
p
.
method
)
{
case
Params
:
:
BM
:
p
.
method
=
Params
::
BP
;
p
.
method_str
=
"BP"
;
break
;
case
Params
:
:
BP
:
p
.
method
=
Params
::
CSBP
;
p
.
method_str
=
"CSBP"
;
break
;
case
Params
:
:
CSBP
:
p
.
method
=
Params
::
BM
;
p
.
method_str
=
"BM"
;
break
;
}
cout
<<
"method: "
<<
p
.
method_str
<<
endl
;
cout
<<
"method: "
<<
p
.
method_str
()
<<
endl
;
break
;
case
'1'
:
p
.
ndisp
=
p
.
ndisp
==
1
?
8
:
p
.
ndisp
+
8
;
cout
<<
"ndisp: "
<<
p
.
ndisp
<<
endl
;
bm
.
ndisp
=
p
.
ndisp
;
bp
.
ndisp
=
p
.
ndisp
;
csbp
.
ndisp
=
p
.
ndisp
;
cout
<<
"ndisp: "
<<
p
.
ndisp
<<
endl
;
break
;
case
'q'
:
case
'Q'
:
p
.
ndisp
=
max
(
p
.
ndisp
-
8
,
1
);
cout
<<
"ndisp: "
<<
p
.
ndisp
<<
endl
;
bm
.
ndisp
=
p
.
ndisp
;
bp
.
ndisp
=
p
.
ndisp
;
csbp
.
ndisp
=
p
.
ndisp
;
cout
<<
"ndisp: "
<<
p
.
ndisp
<<
endl
;
break
;
case
'2'
:
if
(
p
.
method
==
Params
::
BM
)
{
bm
.
winSize
+=
1
;
cout
<<
"win_size: "
<<
bm
.
winSize
<<
endl
;
}
break
;
case
'w'
:
case
'W'
:
if
(
p
.
method
==
Params
::
BM
)
{
bm
.
winSize
=
max
(
bm
.
winSize
-
1
,
2
);
cout
<<
"win_size: "
<<
bm
.
winSize
<<
endl
;
}
break
;
case
'3'
:
if
(
p
.
method
==
Params
::
BP
)
{
bp
.
iters
+=
1
;
cout
<<
"iter_count: "
<<
bp
.
iters
<<
endl
;
}
else
if
(
p
.
method
==
Params
::
CSBP
)
{
csbp
.
iters
+=
1
;
cout
<<
"iter_count: "
<<
csbp
.
iters
<<
endl
;
}
break
;
case
'e'
:
case
'E'
:
if
(
p
.
method
==
Params
::
BP
)
{
bp
.
iters
=
max
(
bp
.
iters
-
1
,
1
);
cout
<<
"iter_count: "
<<
bp
.
iters
<<
endl
;
}
else
if
(
p
.
method
==
Params
::
CSBP
)
{
csbp
.
iters
=
max
(
csbp
.
iters
-
1
,
1
);
cout
<<
"iter_count: "
<<
csbp
.
iters
<<
endl
;
}
break
;
case
'4'
:
if
(
p
.
method
==
Params
::
BP
)
{
bp
.
levels
+=
1
;
cout
<<
"level_count: "
<<
bp
.
levels
<<
endl
;
}
else
if
(
p
.
method
==
Params
::
CSBP
)
{
csbp
.
levels
+=
1
;
cout
<<
"level_count: "
<<
csbp
.
levels
<<
endl
;
}
break
;
case
'r'
:
case
'R'
:
if
(
p
.
method
==
Params
::
BP
)
{
bp
.
levels
=
max
(
bp
.
levels
-
1
,
1
);
cout
<<
"level_count: "
<<
bp
.
levels
<<
endl
;
}
else
if
(
p
.
method
==
Params
::
CSBP
)
{
csbp
.
levels
=
max
(
csbp
.
levels
-
1
,
1
);
cout
<<
"level_count: "
<<
csbp
.
levels
<<
endl
;
}
break
;
}
}
...
...
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