demo.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 <ros/ros.h> //Includes all the headers necessary to use the most common public pieces of the ROS system.
28 #include <image_transport/image_transport.h> //Use image_transport for publishing and subscribing to images in ROS
29 #include <cv_bridge/cv_bridge.h> //Use cv_bridge to convert between ROS and OpenCV Image formats
30 #include <sensor_msgs/image_encodings.h> //Include some useful constants for image encoding. Refer to: http://www.ros.org/doc/api/sensor_msgs/html/namespacesensor__msgs_1_1image__encodings.html for more info.
31 #include <opencv2/imgproc/imgproc.hpp> //Include headers for OpenCV Image processing
32 #include <opencv2/highgui/highgui.hpp> //Include headers for OpenCV GUI handling
33 #include <vector>
34 #include <cmath>
35 #include <iostream>
36 #include <signal.h>
37 #include <Eigen/Dense>
38 
39 #include "rosbag/bag.h"
40 #include <rosbag/view.h>
41 #include <boost/foreach.hpp>
42 #include <string>
43 #include <std_msgs/String.h>
44 #include <std_msgs/Int32.h>
45 // #include <crpcut.hpp>
46 
47 using namespace Eigen;
48 using namespace std;
49 using namespace cv;
50 int main(void)
51 {
52  rosbag::Bag bag;
53  bag.open("test.bag", rosbag::bagmode::Read);
54 
55  std::vector<std::string> topics;
56  topics.push_back(std::string("chatter"));
57  topics.push_back(std::string("numbers"));
58 
59  rosbag::View view(bag, rosbag::TopicQuery(topics));
60 
61  BOOST_FOREACH(rosbag::MessageInstance const m, view)
62  {
63  std_msgs::String::ConstPtr s = m.instantiate<std_msgs::String>();
64 // if (s != NULL)
65 // ASSERT_EQ(s->data, std::string("foo"));
66 
67  std_msgs::Int32::ConstPtr i = m.instantiate<std_msgs::Int32>();
68 // if (i != NULL)
69 // ASSERT_EQ(i->data, 42);
70  }
71 
72  bag.close();
73 
74 
75 // Mat image= imread("/home/morais/Pictures/download.jpg");
76 // Mat out;
77 
78 
79  /*
80  watershed(image,out);
81  imshow("result",out);
82  waitKey(0);
83  return 0;
84 
85 
86  cvtColor(image,image,CV_RGB2GRAY,CV_8U);
87  Mat clone = image(Range(50,image.rows),Range(0,image.cols));
88 
89  Mat clone_2 = clone.clone();
90 
91  imshow("Clone",clone);
92  imshow("image clone_2",clone);*/
93 // cvtColor(image,image,CV_RGB2GRAY,CV_8U);
94 // // int threshold=100;
95 // // int colour=255;
96 // threshold(image,out, 100,255,CV_THRESH_BINARY_INV);
97 // imshow("imagem original",image);
98 // imshow("imagem ivertida",out);
99 // waitKey(0);
100 
101 // MatrixXd m = MatrixXd::Random(3,3);
102 // cout<<"inicial n"<<endl<<m<<endl;
103 // // MatrixXd m_f;
104 //
105 // // m_f = m ;
106 // MatrixXi::Index min_i, min_j;
107 // double minOfM = m.minCoeff(&min_i,&min_j);
108 // cv::Mat img(240,360,CV_8U,cv::Scalar(0));
109 // int lineType = 8;
110 // Point rook_points[1][6];
111 // rook_points[0][0] = Point( 0, 120 );
112 // rook_points[0][1] = Point( 0, 120 );
113 // rook_points[0][2] = Point( 1, 239 );
114 // rook_points[0][3] = Point( 359, 239 );
115 // rook_points[0][4] = Point( 360, 158 );
116 // rook_points[0][5] = Point( 218, 121 );
117 // rook_points[0][6] = Point( 3*w/4.0, w/8.0 );
118 // rook_points[0][7] = Point( 26*w/40.0, w/8.0 );
119 // rook_points[0][8] = Point( 26*w/40.0, w/4.0 );
120 
121 // [0, 120]
122 // [0, 120]
123 // [1, 239]
124 // // // [359, 239]
125 // [360, 158]
126 // [218, 121]
127 // [0, 120]
128 /*
129 
130  const Point* ppt[1] = { rook_points[0] };
131  int npt[] = { 6 };
132 
133  fillPoly( img,
134  ppt,
135  npt,
136  1,
137  Scalar( 255, 255, 255 ),
138  lineType );
139 
140  imshow("test",img);
141  waitKey(0);*/
142 
143 // Match_dis(i) = minOfM;
144 // rowInd = min_i;
145 // colInd = min_j;
146 
147 // R.col(j1).swap(mat1.col(j2));
148 
149 
150 // cout<<"mininmo ="<<minOfM<<" em "<<min_i<<" "<<min_j<<endl;
151 // return 1;
152 }
int main(void)
Definition: demo.cpp:50


road_recognition
Author(s): Ricardo Morais
autogenerated on Mon Mar 2 2015 01:32:51