00001 #include "camera_calibration_parsers/parse.h"
00002 #include "camera_calibration_parsers/parse_ini.h"
00003 #include "camera_calibration_parsers/parse_yml.h"
00004
00005 #include <boost/algorithm/string/predicate.hpp>
00006
00007 namespace camera_calibration_parsers {
00008
00009 bool writeCalibration(const std::string& file_name, const std::string& camera_name,
00010 const sensor_msgs::CameraInfo& cam_info)
00011 {
00012 if (boost::iends_with(file_name, ".ini"))
00013 return writeCalibrationIni(file_name, camera_name, cam_info);
00014 if (boost::iends_with(file_name, ".yml") || boost::iends_with(file_name, ".yaml"))
00015 return writeCalibrationYml(file_name, camera_name, cam_info);
00016
00017 return false;
00018 }
00019
00020 bool readCalibration(const std::string& file_name, std::string& camera_name,
00021 sensor_msgs::CameraInfo& cam_info)
00022 {
00023 if (boost::iends_with(file_name, ".ini"))
00024 return readCalibrationIni(file_name, camera_name, cam_info);
00025 if (boost::iends_with(file_name, ".yml") || boost::iends_with(file_name, ".yaml"))
00026 return readCalibrationYml(file_name, camera_name, cam_info);
00027
00028 return false;
00029 }
00030
00031 bool parseCalibration(const std::string& buffer, const std::string& format,
00032 std::string& camera_name, sensor_msgs::CameraInfo& cam_info)
00033 {
00034 if (format != "ini")
00035 return false;
00036
00037 return parseCalibrationIni(buffer, camera_name, cam_info);
00038 }
00039
00040 }