Updated value in Parameter server not reflecting in real time Camera
Hi all,
I am using two cameras and I have a .yaml file having the parameter list like fps, Width and length of the image, Pixels and few more.
I have created a parameter server and have stored the parameters to access it in real time.
The problem is that I am able to change the parameters in real time but is not getting reflected in the camera output feed.
For example...If my camera is producing output at 30 fps and I have changed my fps to 10 in real time so there is a significant difference between the fps but this is not being reflected in the output but my paramter server is getting updated.
How to update the camera parameters in real time.
I am using getParam() to read the values.
Below is my Publisher code.
#include "ros/ros.h"
#include "usb_cam/usb_cam.h"
#include "image_transport/image_transport.h"
#include "camera_info_manager/camera_info_manager.h"
#include "sstream"
#include <std_srvs/Empty.h>
namespace usb_cam {
class UsbCamNode
{
public:
// private ROS node handle
ros::NodeHandle node_;
// shared image message
sensor_msgs::Image img_;
image_transport::CameraPublisher image_pub_;
// parameters
std::string video_device_name_, io_method_name_, pixel_format_name_, camera_name_, camera_info_url_;
//std::string start_service_name_, start_service_name_;
bool streaming_status_;
int image_width_, image_height_, framerate_, exposure_, brightness_, contrast_, saturation_, sharpness_, focus_, white_balance_, gain_;
bool autofocus_, autoexposure_, auto_white_balance_;
boost::shared_ptr<camera_info_manager::CameraInfoManager> cinfo_;
UsbCam cam_;
ros::ServiceServer service_start_, service_stop_;
bool service_start_cap(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res )
{
cam_.start_capturing();
return true;
}
bool service_stop_cap( std_srvs::Empty::Request &req, std_srvs::Empty::Response &res )
{
cam_.stop_capturing();
return true;
}
UsbCamNode() :
node_("~")
{
// advertise the main image topic
image_transport::ImageTransport it(node_);
image_pub_ = it.advertiseCamera("image_raw", 0);
// grab the parameters
node_.param("video_device", video_device_name_, std::string("/dev/video0"));
node_.param("brightness", brightness_, -1); //0-255, -1 "leave alone"
node_.param("contrast", contrast_, -1); //0-255, -1 "leave alone"
node_.param("saturation", saturation_, -1); //0-255, -1 "leave alone"
node_.param("sharpness", sharpness_, -1); //0-255, -1 "leave alone"
// possible values: mmap, read, userptr
// node_.getParam("/io_method", io_method_name_, std::string("mmap"));
node_.getParam("/io_method", io_method_name_);
node_.getParam("/image_width", image_width_);
node_.getParam("/image_height", image_height_);
//node_.param("framerate", framerate_, 20);
node_.getParam("/framerate", framerate_);
// possible values: yuyv, uyvy, mjpeg, yuvmono10, rgb24
// node_.param("/pixel_format", pixel_format_name_, std::string("mjpeg"));
node_.getParam("/pixel_format", pixel_format_name_);
// enable/disable autofocus
// enable/disable autofocus
node_.param("autofocus", autofocus_, false);
node_.param("focus", focus_, -1); //0-255, -1 "leave alone"
// enable/disable autoexposure
node_.param("autoexposure", autoexposure_, true);
node_.param("exposure", exposure_, 100);
node_.param("gain", gain_, -1); //0-100?, -1 "leave alone"
// enable/disable auto white balance temperature
node_.param("auto_white_balance", auto_white_balance_, true);
node_.param("white_balance", white_balance_, 4000);
// load the camera info
node_.param("camera_frame_id", img_.header.frame_id, std::string("head_camera"));
node_.param("camera_name", camera_name_, std::string("head_camera"));
node_.param("camera_info_url", camera_info_url_, std::string(""));
cinfo_.reset(new camera_info_manager::CameraInfoManager(node_, camera_name_, camera_info_url_));
// create Services
service_start_ = node_.advertiseService("start_capture", &UsbCamNode::service_start_cap, this);
service_stop_ = node_.advertiseService("stop_capture", &UsbCamNode::service_stop_cap, this);
// check for default camera info
if (!cinfo_->isCalibrated())
{
cinfo_->setCameraName(video_device_name_);
sensor_msgs::CameraInfo camera_info;
camera_info.header.frame_id = img_.header.frame_id;
camera_info.width = image_width_;
camera_info.height = image_height_;
cinfo_- ...
Please take 5 minutes to properly format your code. As-is, this is unreadable. There are plenty of websites available that run your code through a code pretty printer. I'd recommend to use one of those.
Thanks you for your advice....I have formatted my code. Kindly do the needful.