serverimg_folder.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
27 #include "peddetect.h"
28 
29 
30 int main (int argc, char **argv)
31 {
32  ros::init (argc, argv, "image_publisher");
33  PVector vect;
34 
35  ros::NodeHandle nh;
36  image_transport::ImageTransport it (nh);
37  image_transport::Publisher pub = it.advertise ("Image_In", 1);
38 
39  cv_bridge::CvImagePtr cv_ptr (new cv_bridge::CvImage);
40 
41 // string folder_path = ros::package::getPath("PedDetect");
42 
44 
45 // string folder_path= "/home/pedrobatista/Desktop/INRIAPerson/train_64x128_H96/pos"; // pos train windows
46 // string folder_path= "/home/pedrobatista/Desktop/INRIAPerson/train_64x128_H96/neg"; // -< neg big train images
47 //
48 // string folder_path= "/home/pedrobatista/Desktop/INRIAPerson/test_64x128_H96/neg"; // < neg big test images
49 // string folder_path= "/home/pedrobatista/Desktop/INRIAPerson/test_64x128_H96/pos"; // -< post test windows
50 
52 
54  string folder_path="/home/pedrobatista/Desktop/AtlasDataset/BootData";
55 
56 
57  vect.clear();
58 
59 
60  GetFileList(folder_path, vect);
61 
62  sensor_msgs::ImagePtr msg;
63 
64 
65  ros::Rate loop_rate (0.04);
66 
67  int nfiles = vect.size(); int n=0;
68 
69 // cout<<"nfiles: "<<nfiles<<endl;
70 
71  sleep(1);
72 
73  while (nh.ok () && n<nfiles )
74  {
75  string ImgPath=vect[n].string();
76 
77  if (strstr(vect[n].string().c_str(),".jpg") || strstr(vect[n].string().c_str(),".png"))
78  {
79 
80  cv_ptr->image = cv::imread(ImgPath, CV_LOAD_IMAGE_COLOR);
81 
82  msg = cv_ptr->toImageMsg ();
83  msg->header.frame_id = "Image_in";
84  msg->encoding = "rgb8";
85  msg->header.stamp = ros::Time::now ();
86 
87  pub.publish (msg);
88  n++;
89  cout<<"nfiles: "<<n<<endl;
90  }
91 
92  ros::spinOnce ();
93 
94  loop_rate.sleep ();
95  }
96 
97 
98 
99 }
100 
int main(int argc, char **argv)
void GetFileList(string folder_path, PVector &dest_vect)
Definition: pedfuncs.cpp:153
vector< path > PVector
Definition: peddetect.h:88


pedestrian_detect
Author(s): Pedro Batista
autogenerated on Mon Mar 2 2015 01:32:33