00001 /*************************************************************************** 00002 * Copyright (C) 2012 by Markus Bader * 00003 * markus.bader@tuwien.ac.at * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00021 00022 #ifndef V4R_CAM_NODE_H 00023 #define V4R_CAM_NODE_H 00024 00025 #include <ros/ros.h> 00026 #include <v4r_uvc/v4r_uvc.h> 00027 #include <v4r_uvc/Sphere.h> 00028 #include <opencv2/opencv.hpp> 00029 #include <image_transport/image_transport.h> 00030 #include <image_transport/camera_publisher.h> 00031 00033 class V4RCamNode : public V4RCam { 00034 public: 00035 static const int CONVERT_RAW = 0; 00036 static const int CONVERT_YUV422toRGB = 1; 00037 static const int CONVERT_YUV422toBGR = 2; 00038 static const int CONVERT_YUV422toGray = 3; 00039 00040 V4RCamNode ( ros::NodeHandle &n ); 00041 ~V4RCamNode(); 00042 void publishCamera(); 00043 void showCameraImage(); 00044 protected: 00045 ros::NodeHandle n_; 00046 ros::NodeHandle n_param_; 00047 image_transport::ImageTransport imageTransport_; 00048 image_transport::CameraPublisher cameraPublisher_; 00049 image_transport::Publisher cameraThumbnailPublisher_; 00050 sensor_msgs::CameraInfo cameraInfo_; 00051 sensor_msgs::Image cameraImage_; 00052 sensor_msgs::Image cameraThumbnail_; 00053 ros::Subscriber subSphere_; 00054 void callbackSphere (const v4r_uvc::SphereConstPtr& msg); 00055 bool generate_dynamic_reconfigure_; 00056 bool show_camera_image_; 00057 bool camera_freeze_; 00058 bool queueRosParamToV4LCommit_; 00059 bool showCameraImageThreadActive_; 00060 boost::thread showCameraImageThread_; 00061 protected: 00062 void readInitParams(); 00063 void commitRosParamsToV4L(bool force = false); 00064 void commitV4LToRosParams(); 00065 void loopCamera(); 00066 int convert_image_; 00067 int ratioThumbnail_; 00068 00073 void readCameraControls(); 00078 void writeCameraControls(); 00079 00084 void readControlEntryInfo ( ControlEntry *entry ); 00089 void updateControlEntry ( ControlEntry *entry ); 00093 void updateDynamicReconfigureFile ( const char* filename ) const; 00094 }; 00095 00096 #endif // V4R_CAM_NODE_H