Go to the documentation of this file.00001 #include "image_recorder_alg_node.h"
00002
00003 ImageRecorderAlgNode::ImageRecorderAlgNode(void) :
00004 algorithm_base::IriBaseAlgorithm<ImageRecorderAlgorithm>(),
00005 iit_database(0),
00006 list_pointer(0)
00007 {
00008
00009
00010
00011
00012
00013
00014 this->input_subscriber_ = this->public_node_handle_.subscribe("image", 100, &ImageRecorderAlgNode::input_callback, this);
00015
00016
00017
00018
00019
00020
00021
00022
00023 }
00024
00025 ImageRecorderAlgNode::~ImageRecorderAlgNode(void)
00026 {
00027
00028 }
00029
00030 void ImageRecorderAlgNode::mainNodeThread(void)
00031 {
00032
00033
00034
00035
00036
00037
00038
00039 }
00040
00041
00042 void ImageRecorderAlgNode::input_callback(const sensor_msgs::ImageConstPtr& msg)
00043 {
00044 ROS_INFO("ImageRecorderAlgNode::input_callback: New Message Received");
00045
00046
00047
00048
00049 iit_database ++;
00050
00051 std::string fileString = path + "/list.lst";
00052 ROS_INFO("path=%s",path.c_str());
00053 FILE * file_out;
00054 file_out = fopen ( fileString.c_str() , "r");
00055 fseek(file_out , list_pointer*(iit_database -1) , SEEK_SET );
00056 char file_name[64];
00057 if (fscanf(file_out, "%s\n" , file_name) != EOF) {
00058 std::string string_file_name = file_name;
00059 fileString = path + string_file_name;
00060
00062 IplImage *img = 0;
00063 std::string cv_encoding="passthrough";
00064 sensor_msgs::CvBridge bridge;
00065 img = bridge.imgMsgToCv(msg, cv_encoding);
00066 IplImage *frame = img;
00068
00069
00070
00071 cvSaveImage(fileString.c_str(),frame);
00072
00073
00074
00075 }
00076
00077 if (list_pointer == 0)
00078 list_pointer = strlen(file_name) + 1;
00079 fclose(file_out);
00080
00081
00082
00083
00084 }
00085
00086
00087
00088
00089
00090
00091
00092 void ImageRecorderAlgNode::node_config_update(Config &config, uint32_t level)
00093 {
00094 this->alg_.lock();
00095 path = config.images_path;
00096 this->alg_.unlock();
00097 }
00098
00099 void ImageRecorderAlgNode::addNodeDiagnostics()
00100 {
00101 }
00102
00103
00104
00105 int main(int argc,char *argv[])
00106 {
00107 return algorithm_base::main<ImageRecorderAlgNode>(argc, argv, "image_recorder_alg_node");
00108 }