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 <opencv2/imgproc/imgproc.hpp> //Include headers for OpenCV Image processing
28 #include <opencv2/highgui/highgui.hpp> //Include headers for OpenCV GUI handling
29 #include <iostream>
30 #include <stdio.h>
31 #include <ros/ros.h>
32 #include <sensor_msgs/Image.h>
33 #include <sensor_msgs/CameraInfo.h>
34 #include <image_transport/image_transport.h>
35 #include <signal.h>
36 
37 using namespace std;
38 using namespace cv;
42 void sighandler(int sig)
43 {
44  ROS_ERROR("Signal %d caught...",sig);
45  cout<<"Shuting down road_recognition"<<endl;
46  exit(0);
47 }
48 
49 void Callback(const sensor_msgs::CameraInfoPtr& cam_info)
50 {
51  cout<<"---> Camera configurations"<<endl;
52  cout<<"imge size "<<endl<<"\t"<<cam_info->height<<" x "<<cam_info->width<<endl;
53  cout<<"distortion_model:"<<endl<<"\t"<<cam_info->distortion_model<<endl;
54 
55 // cout<<"\tbinning_x = "<<cam_info->binning_x<<endl;
56 // cout<<"\tbinning_y = "<<cam_info->binning_y<<endl;
57 
58  cout<<"focal lengths"<<endl<<"\t fx ="<<cam_info->K[0]<<" fy = "<<cam_info->K[4]<<endl;
59  cout<<"principal point"<<endl<<"\t cx ="<<cam_info->K[2]<<" cy = "<<cam_info->K[5]<<endl;
60 
61 
62  cout<<"---> Camera configurations Updated"<<endl;
63  exit(0);
64 }
65 
66 int main(int argc, char **argv)
67 {
68  ros::init(argc, argv, "demo");
69 
70  /* Obter as definições das cameras do Atlas e guardar para ficheiro */
71  ros::NodeHandle nh;
72  signal(SIGINT, &sighandler);
73 
74  /* Create an ImageTransport instance, initializing it with our NodeHandle. */
75 // image_transport::ImageTransport it(nh);
76  ros::Subscriber sub = nh.subscribe("/snr/scam/wide/left/camera_info", 1, Callback);
77  ros::spin();
78  ROS_INFO("Caltech::main.cpp::No error.");
79 // /* carregar a imagem */
80 // Mat image,eq_image,gray_image;
81 // image = imread("src/src.png", CV_LOAD_IMAGE_COLOR);
82 // cvtColor(image,gray_image,CV_RGB2GRAY);
83 //
84 // equalizeHist( gray_image, eq_image );
85 //
86 //
87 // imshow( "Original img", image );
88 // imshow( "Eq img", eq_image );
89 // imshow( "gray_image",gray_image);
90 // waitKey(0);
91 
92 // return 0;
93 }
94 
95 
int main(int argc, char **argv)
Definition: demo.cpp:66
void sighandler(int sig)
Definition: demo.cpp:42
void Callback(const sensor_msgs::CameraInfoPtr &cam_info)
Definition: demo.cpp:49


caltech_lanes
Author(s): Ricardo Morais
autogenerated on Mon Mar 2 2015 01:31:31