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 <ros/ros.h> //Includes all the headers necessary to use the most common public pieces of the ROS system. 00028 #include <image_transport/image_transport.h> //Use image_transport for publishing and subscribing to images in ROS 00029 #include <cv_bridge/cv_bridge.h> //Use cv_bridge to convert between ROS and OpenCV Image formats 00030 #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. 00031 #include <opencv2/imgproc/imgproc.hpp> //Include headers for OpenCV Image processing 00032 #include <opencv2/highgui/highgui.hpp> //Include headers for OpenCV GUI handling 00033 #include <vector> 00034 #include <cmath> 00035 #include <iostream> 00036 #include <signal.h> 00037 #include <Eigen/Dense> 00038 00039 #include "rosbag/bag.h" 00040 #include <rosbag/view.h> 00041 #include <boost/foreach.hpp> 00042 #include <string> 00043 #include <std_msgs/String.h> 00044 #include <std_msgs/Int32.h> 00045 // #include <crpcut.hpp> 00046 00047 using namespace Eigen; 00048 using namespace std; 00049 using namespace cv; 00050 int main(void) 00051 { 00052 rosbag::Bag bag; 00053 bag.open("test.bag", rosbag::bagmode::Read); 00054 00055 std::vector<std::string> topics; 00056 topics.push_back(std::string("chatter")); 00057 topics.push_back(std::string("numbers")); 00058 00059 rosbag::View view(bag, rosbag::TopicQuery(topics)); 00060 00061 BOOST_FOREACH(rosbag::MessageInstance const m, view) 00062 { 00063 std_msgs::String::ConstPtr s = m.instantiate<std_msgs::String>(); 00064 // if (s != NULL) 00065 // ASSERT_EQ(s->data, std::string("foo")); 00066 00067 std_msgs::Int32::ConstPtr i = m.instantiate<std_msgs::Int32>(); 00068 // if (i != NULL) 00069 // ASSERT_EQ(i->data, 42); 00070 } 00071 00072 bag.close(); 00073 00074 00075 // Mat image= imread("/home/morais/Pictures/download.jpg"); 00076 // Mat out; 00077 00078 00079 /* 00080 watershed(image,out); 00081 imshow("result",out); 00082 waitKey(0); 00083 return 0; 00084 00085 00086 cvtColor(image,image,CV_RGB2GRAY,CV_8U); 00087 Mat clone = image(Range(50,image.rows),Range(0,image.cols)); 00088 00089 Mat clone_2 = clone.clone(); 00090 00091 imshow("Clone",clone); 00092 imshow("image clone_2",clone);*/ 00093 // cvtColor(image,image,CV_RGB2GRAY,CV_8U); 00094 // // int threshold=100; 00095 // // int colour=255; 00096 // threshold(image,out, 100,255,CV_THRESH_BINARY_INV); 00097 // imshow("imagem original",image); 00098 // imshow("imagem ivertida",out); 00099 // waitKey(0); 00100 00101 // MatrixXd m = MatrixXd::Random(3,3); 00102 // cout<<"inicial n"<<endl<<m<<endl; 00103 // // MatrixXd m_f; 00104 // 00105 // // m_f = m ; 00106 // MatrixXi::Index min_i, min_j; 00107 // double minOfM = m.minCoeff(&min_i,&min_j); 00108 // cv::Mat img(240,360,CV_8U,cv::Scalar(0)); 00109 // int lineType = 8; 00110 // Point rook_points[1][6]; 00111 // rook_points[0][0] = Point( 0, 120 ); 00112 // rook_points[0][1] = Point( 0, 120 ); 00113 // rook_points[0][2] = Point( 1, 239 ); 00114 // rook_points[0][3] = Point( 359, 239 ); 00115 // rook_points[0][4] = Point( 360, 158 ); 00116 // rook_points[0][5] = Point( 218, 121 ); 00117 // rook_points[0][6] = Point( 3*w/4.0, w/8.0 ); 00118 // rook_points[0][7] = Point( 26*w/40.0, w/8.0 ); 00119 // rook_points[0][8] = Point( 26*w/40.0, w/4.0 ); 00120 00121 // [0, 120] 00122 // [0, 120] 00123 // [1, 239] 00124 // // // [359, 239] 00125 // [360, 158] 00126 // [218, 121] 00127 // [0, 120] 00128 /* 00129 00130 const Point* ppt[1] = { rook_points[0] }; 00131 int npt[] = { 6 }; 00132 00133 fillPoly( img, 00134 ppt, 00135 npt, 00136 1, 00137 Scalar( 255, 255, 255 ), 00138 lineType ); 00139 00140 imshow("test",img); 00141 waitKey(0);*/ 00142 00143 // Match_dis(i) = minOfM; 00144 // rowInd = min_i; 00145 // colInd = min_j; 00146 00147 // R.col(j1).swap(mat1.col(j2)); 00148 00149 00150 // cout<<"mininmo ="<<minOfM<<" em "<<min_i<<" "<<min_j<<endl; 00151 // return 1; 00152 }