00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __IPA_CAMERASENSORTOOLBOX_H__
00019 #define __IPA_CAMERASENSORTOOLBOX_H__
00020
00021 #ifdef __LINUX__
00022 #include "cob_vision_utils/CameraSensorDefines.h"
00023 #include "cob_vision_utils/CameraSensorTypes.h"
00024 #else
00025 #include "cob_perception_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorDefines.h"
00026 #include "cob_perception_common/cob_vision_utils/common/include/cob_vision_utils/CameraSensorTypes.h"
00027 #endif
00028
00029 #include <opencv2/core/core.hpp>
00030 #include <map>
00031 #include <boost/shared_ptr.hpp>
00032
00033 namespace ipa_CameraSensors {
00034
00036 class CameraSensorToolbox;
00037 typedef boost::shared_ptr<CameraSensorToolbox> CameraSensorToolboxPtr;
00038
00043 class __DLL_LIBCAMERASENSORS__ CameraSensorToolbox
00044 {
00045 public:
00046 CameraSensorToolbox();
00047 ~CameraSensorToolbox();
00048
00049 CameraSensorToolbox(const CameraSensorToolbox& cameraSensorToolbox);
00050
00052 CameraSensorToolbox& operator= (const CameraSensorToolbox& cameraSensorToolbox);
00053
00056 virtual unsigned long Release();
00057
00065 virtual unsigned long Init(std::string directory, ipa_CameraSensors::t_cameraType cameraType, int cameraIndex, const CvSize imageSize);
00066
00076 virtual unsigned long Init(const std::map<std::string, cv::Mat>* intrinsicMatrices,
00077 const std::map<std::string, cv::Mat>* distortionParameters,
00078 const std::map<std::string, cv::Mat>* extrinsicMatrices,
00079 const std::map<std::string, cv::Mat>* undistortMapsX,
00080 const std::map<std::string, cv::Mat>* undistortMapY,
00081 const CvSize imageSize);
00082
00089 virtual cv::Mat GetExtrinsicParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00090
00099 virtual unsigned long SetExtrinsicParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00100 const cv::Mat& _rotation, const cv::Mat& _translation);
00101
00109 virtual unsigned long SetExtrinsicParameters(std::string key,
00110 const cv::Mat& _rotation, const cv::Mat& _translation);
00111
00116 virtual cv::Mat GetIntrinsicMatrix(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00117
00124 virtual cv::Mat GetDistortionParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00125
00131 virtual cv::Mat GetDistortionMapY(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00132
00138 virtual cv::Mat GetDistortionMapX(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00139
00151 virtual unsigned long SetIntrinsicParameters(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00152 const cv::Mat& _intrinsicMatrix, const cv::Mat& _distortion_coeffs);
00153
00164 virtual unsigned long SetIntrinsicParameters(std::string key, const cv::Mat& _intrinsicMatrix, const cv::Mat& _distortion_coeffs);
00165
00173 virtual unsigned long RemoveDistortion(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00174 const cv::Mat& src, cv::Mat& dst);
00175
00186 virtual unsigned long ReprojectXYZ(ipa_CameraSensors::t_cameraType cameraType, int cameraIndex,
00187 double x, double y, double z, int& u, int& v);
00188
00189 private:
00190
00195 virtual unsigned long ConvertCameraTypeToString(ipa_CameraSensors::t_cameraType cameraType, std::string &cameraTypeString);
00196
00203 virtual unsigned long LoadParameters(const char* filename, ipa_CameraSensors::t_cameraType cameraType, int cameraIndex);
00204
00205 bool m_Initialized;
00206
00207 std::map<std::string, cv::Mat> m_intrinsicMatrices;
00208 std::map<std::string, cv::Mat> m_distortionCoeffs;
00209 std::map<std::string, cv::Mat> m_extrinsicMatrices;
00210
00211
00212 std::map<std::string, cv::Mat> m_undistortMapsX;
00213 std::map<std::string, cv::Mat> m_undistortMapsY;
00214
00215 CvSize m_ImageSize;
00216 };
00217
00220 __DLL_LIBCAMERASENSORS__ CameraSensorToolboxPtr CreateCameraSensorToolbox();
00221
00222 }
00223 #endif // __IPA_CAMERASENSORTOOLBOX_H__