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
b4f17ab7
Commit
b4f17ab7
authored
Dec 22, 2011
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated motions estimators in the stitching module to be able to set camera intrinsics manually
parent
893f7544
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
19 deletions
+33
-19
motion_estimators.hpp
...ng/include/opencv2/stitching/detail/motion_estimators.hpp
+3
-1
motion_estimators.cpp
modules/stitching/src/motion_estimators.cpp
+30
-18
No files found.
modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp
View file @
b4f17ab7
...
...
@@ -69,7 +69,9 @@ protected:
class
CV_EXPORTS
HomographyBasedEstimator
:
public
Estimator
{
public
:
HomographyBasedEstimator
()
:
is_focals_estimated_
(
false
)
{}
HomographyBasedEstimator
(
bool
is_focals_estimated
=
false
)
:
is_focals_estimated_
(
is_focals_estimated
)
{}
bool
isFocalsEstimated
()
const
{
return
is_focals_estimated_
;
}
private
:
...
...
modules/stitching/src/motion_estimators.cpp
View file @
b4f17ab7
...
...
@@ -65,16 +65,17 @@ struct CalcRotation
{
int
pair_idx
=
edge
.
from
*
num_images
+
edge
.
to
;
double
f_from
=
cameras
[
edge
.
from
].
focal
;
double
f_to
=
cameras
[
edge
.
to
].
focal
;
Mat
K_from
=
Mat
::
eye
(
3
,
3
,
CV_64F
);
K_from
.
at
<
double
>
(
0
,
0
)
=
f_from
;
K_from
.
at
<
double
>
(
1
,
1
)
=
f_from
;
Mat
K_to
=
Mat
::
eye
(
3
,
3
,
CV_64F
);
K_to
.
at
<
double
>
(
0
,
0
)
=
f_to
;
K_to
.
at
<
double
>
(
1
,
1
)
=
f_to
;
Mat_
<
double
>
K_from
=
Mat
::
eye
(
3
,
3
,
CV_64F
);
K_from
(
0
,
0
)
=
cameras
[
edge
.
from
].
focal
;
K_from
(
1
,
1
)
=
cameras
[
edge
.
from
].
focal
*
cameras
[
edge
.
from
].
aspect
;
K_from
(
0
,
2
)
=
cameras
[
edge
.
from
].
ppx
;
K_from
(
0
,
2
)
=
cameras
[
edge
.
from
].
ppy
;
Mat_
<
double
>
K_to
=
Mat
::
eye
(
3
,
3
,
CV_64F
);
K_to
(
0
,
0
)
=
cameras
[
edge
.
to
].
focal
;
K_to
(
1
,
1
)
=
cameras
[
edge
.
to
].
focal
*
cameras
[
edge
.
to
].
aspect
;
K_to
(
0
,
2
)
=
cameras
[
edge
.
to
].
ppx
;
K_to
(
0
,
2
)
=
cameras
[
edge
.
to
].
ppy
;
Mat
R
=
K_from
.
inv
()
*
pairwise_matches
[
pair_idx
].
H
.
inv
()
*
K_to
;
cameras
[
edge
.
to
].
R
=
cameras
[
edge
.
from
].
R
*
R
;
...
...
@@ -129,12 +130,23 @@ void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, c
}
#endif
// Estimate focal length and set it for all cameras
vector
<
double
>
focals
;
estimateFocal
(
features
,
pairwise_matches
,
focals
);
cameras
.
assign
(
num_images
,
CameraParams
());
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
cameras
[
i
].
focal
=
focals
[
i
];
if
(
!
is_focals_estimated_
)
{
// Estimate focal length and set it for all cameras
vector
<
double
>
focals
;
estimateFocal
(
features
,
pairwise_matches
,
focals
);
cameras
.
assign
(
num_images
,
CameraParams
());
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
cameras
[
i
].
focal
=
focals
[
i
];
}
else
{
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
{
cameras
[
i
].
ppx
-=
0.5
*
features
[
i
].
img_size
.
width
;
cameras
[
i
].
ppy
-=
0.5
*
features
[
i
].
img_size
.
height
;
}
}
// Restore global motion
Graph
span_tree
;
...
...
@@ -145,8 +157,8 @@ void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, c
// As calculations were performed under assumption that p.p. is in image center
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
{
cameras
[
i
].
ppx
=
0.5
*
features
[
i
].
img_size
.
width
;
cameras
[
i
].
ppy
=
0.5
*
features
[
i
].
img_size
.
height
;
cameras
[
i
].
ppx
+
=
0.5
*
features
[
i
].
img_size
.
width
;
cameras
[
i
].
ppy
+
=
0.5
*
features
[
i
].
img_size
.
height
;
}
LOGLN
(
"Estimating rotations, time: "
<<
((
getTickCount
()
-
t
)
/
getTickFrequency
())
<<
" sec"
);
...
...
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