/*======================================================================================

	Program:		Range Imaging Toolkit (RITK)
	Module:			ritkCameraParameters.h
	Version:		$Revision: 1817 $
	Date:			$Date: 2011-09-30 16:52:28 +0200 (Fri, 30 Sep 2011) $

	Copyright (c) 2010-2011
	Pattern Recognition Lab, 
    University Erlangen-Nuremberg, Germany
    All rights reserved.

	This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
	See RITKCopyright.txt for more information.

	http://www5.informatik.uni-erlangen.de/research/software/ritk

========================================================================================*/

#ifndef CAMERAPARAMETERS_H__
#define CAMERAPARAMETERS_H__

#include "ritkCommon.h"

#include <iostream>
#include <itkMacro.h>
#include <itkFixedArray.h>

namespace ritk
{

/**	@ingroup	Common
 *	@class		CameraParameters
 *	@author		Jakob Wasza
 *	@brief		Parameters for a camera
 *
 *	@details
 *	This class provides a wrapper/container for camera parameters. This base class only provides parameters for a pinhole camera model
 *	as the relationship between the radial distances and the 3D world coordinates are described by such camera model. Thus, the parameters are as follows: \n
 *		SX	Size (in pixel) in x-direction \n
 *		SY	Size (in pixel) in y-direction \n
 *		CX	Detector center (in pixel) in x-direction \n
 *		CY	Detector center (in pixel) in y-direction \n
  *		FX	Focal length (in mm) in x-direction \n
 *		FY	Focal lenght (in mm) in y-direction \n
 *	Optional, K1,K2 and K3 are provided if a lense distortion is required. If a subclass requires more parameters, one should employ the following scheme: 
 * \code
 * enum NewParams
 * {
 *  NewParam1 = PARAM_LAST,
 *  NewParam2,
 *  PARAM_LAST
 * };
 * \endcode
 *
 *	@todo Note that this class only supports floating point values as camera parameters. This should be changed in future versions!
 */
class COMMON_EXPORT CameraParameters
{
public:
	/// Constructor
	CameraParameters();
	/// Destructor
	~CameraParameters();

	/// Enumeration of the different parameters
	enum Params
	{
		SX,
		SY,
		CX,
		CY,
		FX,
		FY,
		K1,
		K2,
		K3,
		P1,
		P2,
		PARAM_LAST
	};

	/// Number of parameters
	itkStaticConstMacro(NumCameraParameters, unsigned int, PARAM_LAST);

	/**	@name Type of the parameters */
	//@{
	typedef float CameraParameterValueType;
	typedef itk::FixedArray<CameraParameterValueType,NumCameraParameters>	CameraParametersType;
	//@}
	
	/**	@name Access the camera parameters */
	//@{
	CameraParameterValueType& operator[](unsigned int index);
	const CameraParameterValueType& operator[](unsigned int index) const;
	CameraParametersType& ToArray();
	const CameraParametersType& ToArray() const;
	//@}


protected:	
	/// The actual parameters 
	CameraParametersType m_Params;
};


/// For convenience. Write the parameters separated by a whitespace
COMMON_EXPORT std::ostream & operator<<(std::ostream& os, const CameraParameters &Params);
/// For convenience. Read the parameters (have to be separated by a whitespace)
COMMON_EXPORT std::istream & operator>>(std::istream& is, CameraParameters &Params);

} // end namespace ritk

#endif // CAMERAPARAMETERS_H__