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
422b967e
Commit
422b967e
authored
Aug 07, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix computeProjectionMatrix in Camera class, also check if there is principal point defined
parent
5335489d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
types.cpp
modules/viz/src/types.cpp
+24
-6
viz3d_impl.cpp
modules/viz/src/viz3d_impl.cpp
+1
-1
No files found.
modules/viz/src/types.cpp
View file @
422b967e
...
...
@@ -195,35 +195,53 @@ void cv::viz::Camera::setWindowSize(const Size &window_size)
// Horizontal field of view is expandable based on the aspect ratio
float
aspect_ratio_new
=
static_cast
<
float
>
(
window_size
.
width
)
/
static_cast
<
float
>
(
window_size
.
height
);
// Get the scale factor and update the principal points
if
(
window_size_
.
height
!=
0
)
{
float
aspect_ratio_old
=
window_size_
.
width
/
window_size_
.
height
;
float
expected_width
=
aspect_ratio_old
*
window_size
.
height
;
float
scale
=
window_size_
.
width
/
expected_width
;
principal_point_
[
0
]
*=
scale
;
principal_point_
[
1
]
*=
static_cast
<
float
>
(
window_size
.
height
)
/
static_cast
<
float
>
(
window_size_
.
height
);
}
if
(
principal_point_
[
0
]
<
0.0
f
)
fov_
[
0
]
=
2.
f
*
atan
(
tan
(
fov_
[
1
]
*
0.5
f
)
*
aspect_ratio_new
);
// This assumes that the lens is symmetric!
else
fov_
[
0
]
=
(
atan2
(
principal_point_
[
0
],
focal_
[
0
])
+
atan2
(
window_size
.
width
-
principal_point_
[
0
],
focal_
[
0
]));
// TODO I need to check this
fov_
[
0
]
=
(
atan2
(
principal_point_
[
0
],
focal_
[
0
])
+
atan2
(
window_size
.
width
-
principal_point_
[
0
],
focal_
[
0
]));
window_size_
=
window_size
;
}
void
cv
::
viz
::
Camera
::
computeProjectionMatrix
(
Matx44f
&
proj
)
const
{
// Symmetric case
double
top
=
clip_
[
0
]
*
tan
(
0.5
*
fov_
[
1
]);
double
left
=
-
(
top
*
window_size_
.
width
)
/
window_size_
.
height
;
double
right
=
-
left
;
double
bottom
=
-
top
;
// If principal point is defined
if
(
principal_point_
[
0
]
>
0.0
f
)
{
top
=
clip_
[
0
]
*
principal_point_
[
1
]
/
focal_
[
1
];
left
=
-
clip_
[
0
]
*
principal_point_
[
0
]
/
focal_
[
0
];
right
=
clip_
[
0
]
*
(
window_size_
.
width
-
principal_point_
[
0
])
/
focal_
[
0
];
bottom
=
-
clip_
[
0
]
*
(
window_size_
.
height
-
principal_point_
[
1
])
/
focal_
[
1
];
}
double
temp1
=
2.0
*
clip_
[
0
];
double
temp2
=
1.0
/
(
right
-
left
);
double
temp3
=
1.0
/
(
top
-
bottom
);
double
temp4
=
1.0
/
clip_
[
1
]
-
clip_
[
0
]
;
double
temp4
=
1.0
/
(
clip_
[
0
]
-
clip_
[
1
])
;
proj
=
Matx44d
::
zeros
();
proj
(
0
,
0
)
=
temp1
*
temp2
;
proj
(
1
,
1
)
=
temp1
*
temp3
;
proj
(
0
,
2
)
=
(
right
+
left
)
*
temp2
;
proj
(
1
,
2
)
=
(
top
+
bottom
)
*
temp3
;
proj
(
2
,
2
)
=
(
-
clip_
[
1
]
-
clip_
[
0
])
*
temp4
;
proj
(
2
,
2
)
=
(
clip_
[
1
]
+
clip_
[
0
])
*
temp4
;
proj
(
3
,
2
)
=
-
1.0
;
proj
(
2
,
3
)
=
(
-
temp1
*
clip_
[
1
])
*
temp4
;
proj
(
2
,
3
)
=
(
temp1
*
clip_
[
1
])
*
temp4
;
}
cv
::
viz
::
Camera
cv
::
viz
::
Camera
::
KinectCamera
(
const
Size
&
window_size
)
...
...
modules/viz/src/viz3d_impl.cpp
View file @
422b967e
...
...
@@ -572,7 +572,7 @@ void cv::viz::Viz3d::VizImpl::setCamera(const Camera &camera)
active_camera
.
SetUseHorizontalViewAngle
(
0
);
// Horizontal view angle is set based on the window size
active_camera
.
SetViewAngle
(
camera
.
getFov
()[
1
]
*
180.0
f
/
CV_PI
);
active_camera
.
SetClippingRange
(
camera
.
getClip
()[
0
],
camera
.
getClip
()[
1
]);
window_
->
SetSize
(
static_cast
<
int
>
(
camera
.
getWindowSize
().
width
),
static_cast
<
int
>
(
camera
.
getWindowSize
().
height
)
);
window_
->
SetSize
(
camera
.
getWindowSize
().
width
,
camera
.
getWindowSize
().
height
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
...
...
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