00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00027 #include "peddetect.h" 00028 00029 00030 int main (int argc, char **argv) 00031 { 00032 ros::init (argc, argv, "image_publisher"); 00033 PVector vect; 00034 00035 ros::NodeHandle nh; 00036 image_transport::ImageTransport it (nh); 00037 image_transport::Publisher pub = it.advertise ("Image_In", 1); 00038 00039 cv_bridge::CvImagePtr cv_ptr (new cv_bridge::CvImage); 00040 00041 // string folder_path = ros::package::getPath("PedDetect"); 00042 00044 00045 // string folder_path= "/home/pedrobatista/Desktop/INRIAPerson/train_64x128_H96/pos"; // pos train windows 00046 // string folder_path= "/home/pedrobatista/Desktop/INRIAPerson/train_64x128_H96/neg"; // -< neg big train images 00047 // 00048 // string folder_path= "/home/pedrobatista/Desktop/INRIAPerson/test_64x128_H96/neg"; // < neg big test images 00049 // string folder_path= "/home/pedrobatista/Desktop/INRIAPerson/test_64x128_H96/pos"; // -< post test windows 00050 00052 00054 string folder_path="/home/pedrobatista/Desktop/AtlasDataset/BootData"; 00055 00056 00057 vect.clear(); 00058 00059 00060 GetFileList(folder_path, vect); 00061 00062 sensor_msgs::ImagePtr msg; 00063 00064 00065 ros::Rate loop_rate (0.04); 00066 00067 int nfiles = vect.size(); int n=0; 00068 00069 // cout<<"nfiles: "<<nfiles<<endl; 00070 00071 sleep(1); 00072 00073 while (nh.ok () && n<nfiles ) 00074 { 00075 string ImgPath=vect[n].string(); 00076 00077 if (strstr(vect[n].string().c_str(),".jpg") || strstr(vect[n].string().c_str(),".png")) 00078 { 00079 00080 cv_ptr->image = cv::imread(ImgPath, CV_LOAD_IMAGE_COLOR); 00081 00082 msg = cv_ptr->toImageMsg (); 00083 msg->header.frame_id = "Image_in"; 00084 msg->encoding = "rgb8"; 00085 msg->header.stamp = ros::Time::now (); 00086 00087 pub.publish (msg); 00088 n++; 00089 cout<<"nfiles: "<<n<<endl; 00090 } 00091 00092 ros::spinOnce (); 00093 00094 loop_rate.sleep (); 00095 } 00096 00097 00098 00099 } 00100