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 int main (int argc, char **argv) 00030 { 00031 ros::init (argc, argv, "image_publisher"); 00032 PVector vect; 00033 00034 ros::NodeHandle nh; 00035 image_transport::ImageTransport it (nh); 00036 00037 cv_bridge::CvImagePtr cv_ptr (new cv_bridge::CvImage); 00038 00039 string folder_path = ros::package::getPath("PedestrianDetect"); 00040 00041 vect.clear(); 00042 00043 00044 // GetFileList(folder_path, vect); 00045 00046 // cout<<"Numero de ficheiros"<<vect.size()<<endl; 00047 // 00048 // for(uint n=0; n<vect.size();n++) 00049 // 00050 // { 00051 // cout<<"directorio: "<<vect[n].string()<<endl; 00052 // } 00053 00054 00055 // string ImgPath=folder_path+"/640.png"; 00056 string ImgPath="/home/pedrobatista/workingcopy/lar3/perception/pedestrians/PedestrianDetect/human3.png"; 00057 00058 // cout<<"path: "<<path<<endl; 00059 00060 cv_ptr->image = cv::imread(ImgPath, CV_LOAD_IMAGE_COLOR); 00061 00062 image_transport::Publisher pub = it.advertise ("Image_In", 1); 00063 00064 sensor_msgs::ImagePtr msg = cv_ptr->toImageMsg (); 00065 00066 msg->encoding = "rgb8"; 00067 msg->header.frame_id = "Image_in"; 00068 00069 00070 // ROS_INFO("msg = %s", msg->encoding.c_str() ); 00071 00072 ros::Rate loop_rate (1); 00073 00074 while (nh.ok ()) 00075 { 00076 msg->header.stamp = ros::Time::now (); 00077 pub.publish (msg); 00078 ros::spinOnce (); 00079 loop_rate.sleep (); 00080 } 00081 00082 00083 }