Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ACGL
acgl
Commits
580fc9c6
Commit
580fc9c6
authored
Mar 28, 2013
by
Robert Menzel
Browse files
added more options to set the focal length
parent
fbbddb3d
Changes
2
Show whitespace changes
Inline
Side-by-side
include/ACGL/Scene/GenericCamera.hh
View file @
580fc9c6
...
...
@@ -288,15 +288,25 @@ class GenericCamera
void
setStateFromString
(
const
std
::
string
&
_state
);
/// The focal length is coupled to the sensor size in real cameras. As this camera does not model a
/// sensor size, the focal length is given in pixels and is in relation to the viewports resolution.
/// sensor size
in mm
, the focal length is given in pixels and is in relation to the viewports resolution.
/// This model is also used by bundler.
/// Note that this gives only useful results if the viewports aspect ratio is the same as the
/// projections aspect ratio!
float
getFocalLenght
()
;
float
getFocalLenght
InPixel
()
const
;
/// Sets the focal length in pixel relative to the viewport dimension. This will change the FoV.
/// See getFocalLenght() for more information.
void
setFocalLength
(
float
_focalLengthInPixel
);
/// See getFocalLenghtInPixel() for more information.
void
setFocalLengthInPixel
(
float
_focalLengthInPixel
);
/// The focal length is coupled to the sensor size in real cameras. As this camera does not model a
/// sensor size in mm (yet), a 135 (35mm) film size is assumed (framesize of 36*24mm).
/// The assumed sensor size might change in case other formats get supported later on but
/// 24mm height should be the default.
float
getFocalLenghtInMM
()
const
;
/// Sets the focal length in mm assuming a 135 film. This will change the FoV.
/// See getFocalLenghtInMM() for more information.
void
setFocalLengthInMM
(
float
_focalLengthInMM
);
private:
/// the Matrix with the camera position/orientation.
...
...
src/ACGL/Scene/GenericCamera.cc
View file @
580fc9c6
...
...
@@ -485,14 +485,27 @@ void GenericCamera::setStateFromString( const std::string &_state )
mViewportSize
=
toUvec2
(
token
[
pos
++
]
);
}
float
GenericCamera
::
getFocalLenght
()
float
GenericCamera
::
getFocalLenght
InPixel
()
const
{
return
(
(
float
)
mViewportSize
.
y
)
/
(
2.0
f
*
tan
(
calcDegToRad
(
0.5
f
*
mHorizontalFieldOfView
)
)
);
return
(
(
float
)
mViewportSize
.
x
)
/
(
2.0
f
*
tan
(
calcDegToRad
(
0.5
f
*
mHorizontalFieldOfView
)
)
);
}
void
GenericCamera
::
setFocalLength
(
float
_focalLengthInPixel
)
void
GenericCamera
::
setFocalLength
InPixel
(
float
_focalLengthInPixel
)
{
float
hFoVrad
=
2.0
f
*
atan
(
(
0.5
f
*
mViewportSize
.
y
)
*
(
1.0
f
/
_focalLengthInPixel
)
);
float
hFoVrad
=
2.0
f
*
atan
(
(
0.5
f
*
mViewportSize
.
x
)
*
(
1.0
f
/
_focalLengthInPixel
)
);
setHorizontalFieldOfView
(
calcRadToDeg
(
hFoVrad
)
);
}
float
GenericCamera
::
getFocalLenghtInMM
()
const
{
glm
::
vec2
sensorSize
=
glm
::
vec2
(
36.0
f
/
mAspectRatio
,
24.0
f
);
// in mm
return
(
sensorSize
.
x
)
/
(
2.0
f
*
tan
(
calcDegToRad
(
0.5
f
*
mHorizontalFieldOfView
)
)
);
}
void
GenericCamera
::
setFocalLengthInMM
(
float
_focalLengthInMM
)
{
glm
::
vec2
sensorSize
=
glm
::
vec2
(
36.0
f
/
mAspectRatio
,
24.0
f
);
// in mm
float
hFoVrad
=
2.0
f
*
atan
(
(
0.5
f
*
sensorSize
.
x
)
*
(
1.0
f
/
_focalLengthInMM
)
);
setHorizontalFieldOfView
(
calcRadToDeg
(
hFoVrad
)
);
}
...
...
Write
Preview
Supports
Markdown
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