Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fhs41601
medien
Commits
773d3d7b
Commit
773d3d7b
authored
5 years ago
by
fhs41601
Browse files
Options
Downloads
Patches
Plain Diff
Implemented rectification
parent
4433eb3b
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MIF/LB02/02/b.cpp
+85
-0
MIF/LB02/02/b.cpp
with
85 additions
and
0 deletions
MIF/LB02/02/b.cpp
0 → 100644
+
85
−
0
View file @
773d3d7b
#include
<iostream>
#include
<map>
#include
<string>
#include
"opencv2/core.hpp"
#include
"opencv2/opencv.hpp"
#include
<opencv2/core/persistence.hpp>
using
namespace
std
;
using
namespace
cv
;
map
<
string
,
Mat
>
*
getProperties
(
const
char
*
filename
);
void
dumpMap
(
map
<
string
,
Mat
>
m
);
int
main
(
const
int
argc
,
const
char
*
const
argv
[])
{
map
<
string
,
Mat
>
*
mapInt
;
map
<
string
,
Mat
>
*
mapExt
;
if
(
argc
!=
5
)
{
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
"<input image 0> <input image 1> <intrinsic data file> <extrinsic data file>"
<<
endl
;
return
1
;
}
Mat
lImg
=
imread
(
argv
[
1
]);
Mat
rImg
=
imread
(
argv
[
2
]);
FileStorage
fsInt
(
argv
[
3
],
FileStorage
::
FORMAT_YAML
);
FileStorage
fsExt
(
argv
[
4
],
FileStorage
::
FORMAT_YAML
);
Mat
R1
,
R2
,
P1
,
P2
,
Q
;
// Get intrinsic
mapInt
=
getProperties
(
argv
[
3
]);
dumpMap
(
*
mapInt
);
cout
<<
"---
\n
"
;
mapExt
=
getProperties
(
argv
[
4
]);
dumpMap
(
*
mapExt
);
stereoRectify
(
(
*
mapInt
)[
"M1"
],
(
*
mapInt
)[
"D1"
],
(
*
mapInt
)[
"M2"
],
(
*
mapInt
)[
"D2"
],
lImg
.
size
(),
(
*
mapExt
)[
"R"
],
(
*
mapExt
)[
"T"
],
R1
,
R2
,
P1
,
P2
,
Q
);
return
0
;
}
map
<
string
,
Mat
>
*
getProperties
(
const
char
*
filename
)
{
map
<
string
,
Mat
>
*
propMap
=
new
map
<
string
,
Mat
>
();
FileStorage
fs
(
filename
,
FileStorage
::
FORMAT_YAML
);
// FileNodeIterator code adapted from
// https://stackoverflow.com/questions/16416763/how-to-retrieve-the-key-value-pairs-from-an-opencv-filenode-map/16435272
FileNode
fn
=
fs
.
root
();
for
(
FileNodeIterator
fit
=
fn
.
begin
();
fit
!=
fn
.
end
();
++
fit
)
{
FileNode
item
=
*
fit
;
Mat
tmp
;
item
>>
tmp
;
propMap
->
insert
({
item
.
name
(),
tmp
});
}
return
propMap
;
}
void
dumpMap
(
map
<
string
,
Mat
>
m
)
{
// Map iteration adapted from
// https://stackoverflow.com/questions/14070940/how-can-i-print-out-c-map-values/55278718
for
(
auto
&
i
:
m
)
{
cout
<<
i
.
first
<<
":
\n
"
;
cout
<<
i
.
second
<<
"
\n
"
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets