42 #include <std_srvs/Empty.h> 92 node_.
param(
"video_device", video_device_name_, std::string(
"/dev/video0"));
93 node_.
param(
"brightness", brightness_, -1);
94 node_.
param(
"contrast", contrast_, -1);
95 node_.
param(
"saturation", saturation_, -1);
96 node_.
param(
"sharpness", sharpness_, -1);
98 node_.
param(
"io_method", io_method_name_, std::string(
"mmap"));
99 node_.
param(
"image_width", image_width_, 640);
100 node_.
param(
"image_height", image_height_, 480);
101 node_.
param(
"framerate", framerate_, 30);
103 node_.
param(
"pixel_format", pixel_format_name_, std::string(
"mjpeg"));
105 node_.
param(
"autofocus", autofocus_,
false);
106 node_.
param(
"focus", focus_, -1);
108 node_.
param(
"autoexposure", autoexposure_,
true);
109 node_.
param(
"exposure", exposure_, 100);
110 node_.
param(
"gain", gain_, -1);
112 node_.
param(
"auto_white_balance", auto_white_balance_,
true);
113 node_.
param(
"white_balance", white_balance_, 4000);
116 node_.
param(
"camera_frame_id", img_.header.frame_id, std::string(
"head_camera"));
117 node_.
param(
"camera_name", camera_name_, std::string(
"head_camera"));
118 node_.
param(
"camera_info_url", camera_info_url_, std::string(
""));
126 if (!cinfo_->isCalibrated())
128 cinfo_->setCameraName(video_device_name_);
129 sensor_msgs::CameraInfo camera_info;
130 camera_info.header.frame_id = img_.header.frame_id;
133 cinfo_->setCameraInfo(camera_info);
137 ROS_INFO(
"Starting '%s' (%s) at %dx%d via %s (%s) at %i FPS", camera_name_.c_str(), video_device_name_.c_str(),
144 ROS_FATAL(
"Unknown IO method '%s'", io_method_name_.c_str());
153 ROS_FATAL(
"Unknown pixel format '%s'", pixel_format_name_.c_str());
163 if (brightness_ >= 0)
173 if (saturation_ >= 0)
189 if (auto_white_balance_)
235 sensor_msgs::CameraInfoPtr ci(
new sensor_msgs::CameraInfo(cinfo_->getCameraInfo()));
236 ci->header.frame_id = img_.header.frame_id;
237 ci->header.stamp = img_.header.stamp;
269 int main(
int argc,
char **argv)
bool take_and_send_image()
void publish(const sensor_msgs::Image &image, const sensor_msgs::CameraInfo &info) const
std::string pixel_format_name_
int main(int argc, char **argv)
void start_capturing(void)
void set_auto_focus(int value)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
void stop_capturing(void)
ros::ServiceServer service_stop_
static pixel_format pixel_format_from_string(const std::string &str)
CameraPublisher advertiseCamera(const std::string &base_topic, uint32_t queue_size, bool latch=false)
std::string io_method_name_
bool service_start_cap(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
std::string video_device_name_
image_transport::CameraPublisher image_pub_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
ros::ServiceServer service_start_
std::string camera_info_url_
void set_v4l_parameter(const std::string ¶m, int value)
static io_method io_method_from_string(const std::string &str)
bool service_stop_cap(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
boost::shared_ptr< camera_info_manager::CameraInfoManager > cinfo_
void grab_image(sensor_msgs::Image *image)
ROSCPP_DECL void spinOnce()
void start(const std::string &dev, io_method io, pixel_format pf, int image_width, int image_height, int framerate)