00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00059
00060 #ifndef __IPA_CAMERASENSORTOOLBOX_H__
00061 #define __IPA_CAMERASENSORTOOLBOX_H__
00062
00063
00064
00065 #ifdef __LINUX__
00066 #include "cob_vision_utils/CameraSensorDefines.h"
00067 #include "cob_vision_utils/CameraSensorTypes.h"
00068 #else
00069 #include "cob_perception_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorDefines.h"
00070 #include "cob_perception_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorTypes.h"
00071 #endif
00072
00073 #include <opencv/cv.h>
00074 #include <map>
00075 #include <boost/shared_ptr.hpp>
00076
00077 namespace ipa_CameraSensors {
00078
00080 class CameraSensorToolbox;
00081 typedef boost::shared_ptr<CameraSensorToolbox> CameraSensorToolboxPtr;
00082
00087 class __DLL_LIBCAMERASENSORS__ CameraSensorToolbox
00088 {
00089 public:
00090 CameraSensorToolbox();
00091 ~CameraSensorToolbox();
00092
00093 CameraSensorToolbox(const CameraSensorToolbox& cameraSensorToolbox);
00094
00096 CameraSensorToolbox& operator= (const CameraSensorToolbox& cameraSensorToolbox);
00097
00100 virtual unsigned long Release();
00101
00109 virtual unsigned long Init(std::string directory, ipa_CameraSensors::t_cameraType cameraType, int cameraIndex, const CvSize imageSize);
00110
00120 virtual unsigned long Init(const std::map<std::string, cv::Mat>* intrinsicMatrices,
00121 const std::map<std::string, cv::Mat>* distortionParameters,
00122 const std::map<std::string, cv::Mat>* extrinsicMatrices,
00123 const std::map<std::string, cv::Mat>* undistortMapsX,
00124 const std::map<std::string, cv::Mat>* undistortMapY,
00125 const CvSize imageSize);
00126
00133 virtual cv::Mat GetExtrinsicParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00134
00143 virtual unsigned long SetExtrinsicParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00144 const cv::Mat& _rotation, const cv::Mat& _translation);
00145
00153 virtual unsigned long SetExtrinsicParameters(std::string key,
00154 const cv::Mat& _rotation, const cv::Mat& _translation);
00155
00160 virtual cv::Mat GetIntrinsicMatrix(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00161
00168 virtual cv::Mat GetDistortionParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00169
00175 virtual cv::Mat GetDistortionMapY(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00176
00182 virtual cv::Mat GetDistortionMapX(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00183
00195 virtual unsigned long SetIntrinsicParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00196 const cv::Mat& _intrinsicMatrix, const cv::Mat& _distortion_coeffs);
00197
00208 virtual unsigned long SetIntrinsicParameters(std::string key, const cv::Mat& _intrinsicMatrix, const cv::Mat& _distortion_coeffs);
00209
00217 virtual unsigned long RemoveDistortion(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00218 const cv::Mat& src, cv::Mat& dst);
00219
00230 virtual unsigned long ReprojectXYZ(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00231 double x, double y, double z, int& u, int& v);
00232
00233 private:
00234
00239 virtual unsigned long ConvertCameraTypeToString(ipa_CameraSensors::t_cameraType cameraType, std::string &cameraTypeString);
00240
00247 virtual unsigned long LoadParameters(const char* filename, ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00248
00249 bool m_Initialized;
00250
00251 std::map<std::string, cv::Mat> m_intrinsicMatrices;
00252 std::map<std::string, cv::Mat> m_distortionCoeffs;
00253 std::map<std::string, cv::Mat> m_extrinsicMatrices;
00254
00255
00256 std::map<std::string, cv::Mat> m_undistortMapsX;
00257 std::map<std::string, cv::Mat> m_undistortMapsY;
00258
00259 CvSize m_ImageSize;
00260 };
00261
00264 __DLL_LIBCAMERASENSORS__ CameraSensorToolboxPtr CreateCameraSensorToolbox();
00265
00266 }
00267 #endif // __IPA_CAMERASENSORTOOLBOX_H__