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
00068 #include "tinyxml.h"
00069 #include "cob_vision_utils/CameraSensorTypes.h"
00070 #include "cob_vision_utils/VisionUtils.h"
00071 #else
00072 #include "cob_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorDefines.h"
00073
00074 #include "cob_vision/windows/src/extern/TinyXml/tinyxml.h"
00075 #include "cob_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorTypes.h"
00076 #include "cob_common/cob_vision_utils/common/include/cob_vision_utils/VisionUtils.h"
00077 #endif
00078
00079 #include <map>
00080 #include <iostream>
00081 #include <sstream>
00082
00083 #include <boost/shared_ptr.hpp>
00084
00085 namespace ipa_CameraSensors {
00086
00088 class CameraSensorToolbox;
00089 typedef boost::shared_ptr<CameraSensorToolbox> CameraSensorToolboxPtr;
00090
00095 class __DLL_LIBCAMERASENSORS__ CameraSensorToolbox
00096 {
00097 public:
00098 CameraSensorToolbox();
00099 ~CameraSensorToolbox();
00100
00101 CameraSensorToolbox(const CameraSensorToolbox& cameraSensorToolbox);
00102
00104 CameraSensorToolbox& operator= (const CameraSensorToolbox& cameraSensorToolbox);
00105
00108 virtual unsigned long Release();
00109
00117 virtual unsigned long Init(std::string directory, ipa_CameraSensors::t_cameraType cameraType, int cameraIndex, const CvSize imageSize);
00118
00128 virtual unsigned long Init(const std::map<std::string, cv::Mat>* intrinsicMatrices,
00129 const std::map<std::string, cv::Mat>* distortionParameters,
00130 const std::map<std::string, cv::Mat>* extrinsicMatrices,
00131 const std::map<std::string, cv::Mat>* undistortMapsX,
00132 const std::map<std::string, cv::Mat>* undistortMapY,
00133 const CvSize imageSize);
00134
00141 virtual cv::Mat GetExtrinsicParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00142
00151 virtual unsigned long SetExtrinsicParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00152 const cv::Mat& _rotation, const cv::Mat& _translation);
00153
00161 virtual unsigned long SetExtrinsicParameters(std::string key,
00162 const cv::Mat& _rotation, const cv::Mat& _translation);
00163
00168 virtual cv::Mat GetIntrinsicMatrix(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00169
00176 virtual cv::Mat GetDistortionParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00177
00183 virtual cv::Mat GetDistortionMapY(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00184
00190 virtual cv::Mat GetDistortionMapX(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00191
00203 virtual unsigned long SetIntrinsicParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00204 const cv::Mat& _intrinsicMatrix, const cv::Mat& _distortion_coeffs);
00205
00216 virtual unsigned long SetIntrinsicParameters(std::string key, const cv::Mat& _intrinsicMatrix, const cv::Mat& _distortion_coeffs);
00217
00225 virtual unsigned long RemoveDistortion(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00226 const cv::Mat& src, cv::Mat& dst);
00227
00238 virtual unsigned long ReprojectXYZ(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00239 double x, double y, double z, int& u, int& v);
00240
00241 private:
00242
00247 virtual unsigned long ConvertCameraTypeToString(ipa_CameraSensors::t_cameraType cameraType, std::string &cameraTypeString);
00248
00255 virtual unsigned long LoadParameters(const char* filename, ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00256
00257 bool m_Initialized;
00258
00259 std::map<std::string, cv::Mat> m_intrinsicMatrices;
00260 std::map<std::string, cv::Mat> m_distortionCoeffs;
00261 std::map<std::string, cv::Mat> m_extrinsicMatrices;
00262
00263
00264 std::map<std::string, cv::Mat> m_undistortMapsX;
00265 std::map<std::string, cv::Mat> m_undistortMapsY;
00266
00267 CvSize m_ImageSize;
00268 };
00269
00272 __DLL_LIBCAMERASENSORS__ CameraSensorToolboxPtr CreateCameraSensorToolbox();
00273
00274 }
00275 #endif // __IPA_CAMERASENSORTOOLBOX_H__