KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
kjb::Turntable_camera Class Reference

#include <turntable_camera.h>

Public Member Functions

 Turntable_camera ()
 
 Turntable_camera (const Perspective_camera &cam, const Vector &rotation_axis, const Vector &turntable_origin, int num_positions, bool clockwise=true)
 
template<typename Iterator >
 Turntable_camera (const Perspective_camera &cam, const Vector &rotation_axis, const Vector &turntable_origin, Iterator angles_begin, Iterator angles_end)
 
 Turntable_camera (const Turntable_camera &other)
 
Turntable_cameraoperator= (const Turntable_camera &other)
 
virtual void swap (Turntable_camera &other)
 
const Vectorget_principal_point () const
 
void set_principal_point (const Vector &pt)
 
void set_active_camera (size_t i) const
 
void set_next ()
 
void set_previous ()
 
void pass_to_opengl (bool clean_buffers=false) const
 
const Perspective_cameraget_neutral_camera () const
 
const Vectorget_origin () const
 
const Vectorget_rotation_axis () const
 
const std::vector< double > & get_angles () const
 
size_t get_current_index () const
 
const Perspective_cameraget_current_camera () const
 
size_t size () const
 
const std::vector< size_t > & index_list ()
 
void set_index_list (const Index_range &indices)
 If not all angles should be used, use this to specify the indices of angles to use. More...
 
void evenly_space_cameras (size_t n)
 
virtual const Perspective_camera operator[] (int i) const
 
std::vector< Perspective_camerato_cameras () const
 

Detailed Description

A class representing a collection of cameras, oriented in a turntable-style configuration.

This class is based on a set of assumptions that are true in turntable scenarios:

 * All cameras have same intrinsic parameters
 * All cameras positions are related by pure rotation around the same axis.
 * All camera orientations are related by rotation around the same axis.
 

This could also apply to a robot turning an object in it's hand.

Author
Kyle Simek

Constructor & Destructor Documentation

kjb::Turntable_camera::Turntable_camera ( )

Create a null Turntable camera. Attempting to use this camera as-is will result in an abort (in DEVELOPMENT mode) or undefined behavior (in PRODUCTION mode). As such, it must be initialized to a valid camera using the assignment operator before using.

kjb::Turntable_camera::Turntable_camera ( const Perspective_camera cam,
const Vector rotation_axis,
const Vector turntable_origin,
int  num_positions,
bool  clockwise = true 
)

Create a turntable camera assuming equal spacing of cameras.

The "Neutral" camera, i.e. camera at position 0 A direction vector representing the turntable's rotation axis. A position vector representing the turntable's origin, i.e. the center of rotation. This can be any point lying on the rotation line. The number of positions where images were captured, a.k.a "number of cameras". This number of cameras will be evenly spaced around the 390 degree circle. Whether or not turntable rotation is clockwise. Clockwise-ness is determined by looking in the direction of the rotation axis. Flipping the direction of the rotation axis will require flipping the clockwise boolean.

Precondition
rotation_axis.size() == turntable_origin.size() == 3
template<typename Iterator >
kjb::Turntable_camera::Turntable_camera ( const Perspective_camera cam,
const Vector rotation_axis,
const Vector turntable_origin,
Iterator  angles_begin,
Iterator  angles_end 
)
inline

Create a turntable camera from an arbitrary collection of angles. Angles are relative to the rotation axis direction, following a right-handed convention; i.e. positive angles correspond to counter-clockwise rotation when looking in the direction of the axis vector.

The call below will create a configuration with the world origin coinciding with the turntable origin; the turntable axis pointing upward; using the angles stored in the collection "angles":

Perspective_camera cam0;
cam0.set_intrinsic_parameters(...);
cam0.set_camera_centre(...);
cam0.set_orientation(Quaternion(...));
Vector angles(4);
angles[0] = 0.0;
angles[1] = M_PI / 2;
angles[2] = 2 * M_PI / 2;
angles[3] = 3 * M_PI / 2;
Turntable_camera my_camera(
cam0,
Vector(0.0,0.0,1.0),
Vector(3, 0.0),
angles.begin(),
angles.end();
Parameters
camThe "Neutral" camera, i.e. camera at position 0
rotation_axisA direction vector representing the turntable's rotation axis.
turntable_originA position vector representing the turntable's origin, i.e. the center of rotation. This can be any point lying on the rotation line.
angles_beginAn iterator representing the beginning of a sequence of angles.
angles_endAn iterator representing one-past-the-end of a sequence of angles.
Precondition
rotation_axis.size() == turntable_origin.size() == 3
kjb::Turntable_camera::Turntable_camera ( const Turntable_camera other)

Standard copy constructor.

Member Function Documentation

void kjb::Turntable_camera::evenly_space_cameras ( size_t  n)
const std::vector<double>& kjb::Turntable_camera::get_angles ( ) const
inline
const Perspective_camera& kjb::Turntable_camera::get_current_camera ( ) const
inline
size_t kjb::Turntable_camera::get_current_index ( ) const
inline
const Perspective_camera& kjb::Turntable_camera::get_neutral_camera ( ) const
inline

Returns the neutral camera, a.k.a. camera 0

const Vector& kjb::Turntable_camera::get_origin ( ) const
inline
const Vector& kjb::Turntable_camera::get_principal_point ( ) const
inline

Returns the principal point of the camera. Same for all cameras.

const Vector& kjb::Turntable_camera::get_rotation_axis ( ) const
inline
const std::vector<size_t>& kjb::Turntable_camera::index_list ( )
inline
Turntable_camera& kjb::Turntable_camera::operator= ( const Turntable_camera other)
inline

Simple assignment

const Perspective_camera kjb::Turntable_camera::operator[] ( int  i) const
virtual
void kjb::Turntable_camera::pass_to_opengl ( bool  clean_buffers = false) const
inline

Send modelview and projection matrices to opengl corresponding to the active camera's extrinsic and intrinsic parameters.

Exceptions
Missing_dependencyif code was compiled without OpenGL.
Precondition
Object is not a null camera
void kjb::Turntable_camera::set_active_camera ( size_t  i) const

Set the i-th camera to be active.

Precondition
This camera has been initialized (is not a Default-constructed camera).
This camera has at least one angle.
Exceptions
Index_out_of_boundsif i exceeds the number of turntable angles.
void kjb::Turntable_camera::set_index_list ( const Index_range indices)

If not all angles should be used, use this to specify the indices of angles to use.

void kjb::Turntable_camera::set_next ( )

Set the next camera to be active, or if the last camera is active, activate the first camera.

Precondition
Object is not a null camera.
void kjb::Turntable_camera::set_previous ( )

Set the previous camera to be active, or if the first camera is active, activate the last camera.

Precondition
Object is not a null camera.
void kjb::Turntable_camera::set_principal_point ( const Vector pt)
inline

Set the principal point of all cameras.

size_t kjb::Turntable_camera::size ( ) const
inline
void kjb::Turntable_camera::swap ( Turntable_camera other)
virtual

Swap state with another Turntable_camera. Running time is O(c).

std::vector< Perspective_camera > kjb::Turntable_camera::to_cameras ( ) const

The documentation for this class was generated from the following files: