Цель состоит в том, чтобы преобразовать функцию обратного вызова в ROS следующим образом:
Код: Выделить всё
void imageCallback(const sensor_msgs::ImageConstPtr &msg)
{
try
{
cv::Mat im = cv_bridge::toCvShare(msg, "rgb8")->image;
}
catch (cv_bridge::Exception &e)
{
ROS_ERROR("Could not convert from '%s' to 'rgb8'.", msg->encoding.c_str());
}
}
int main()
{
//...
image_transport::Subscriber subIm = it.subscribe("dvs_rendering", 1, imageCallback);
//...
}
Код: Выделить всё
void imageCallback(const sensor_msgs::ImageConstPtr &msg, cv::Mat im2)
{
try
{
im2 = cv_bridge::toCvCopy(msg, "rgb8")->image; // This is where I add my data in the picture
cv::Mat im = cv_bridge::toCvShare(msg, "rgb8")->image;
}
catch (cv_bridge::Exception &e)
{
ROS_ERROR("Could not convert from '%s' to 'rgb8'.", msg->encoding.c_str());
}
}
int main()
{
//...
image_transport::Subscriber subIm = it.subscribe("dvs_rendering", 1, imageCallback(_,im2));
//...
}
The names of the functions are indicative and they have no intention of defining exactly my case.
All I want to know is if I can parse selectively the arguments in the function.
Example:
Код: Выделить всё
int functionToCall(int &a, int &b)
{
int a += b;
// ..
return a;
}
int main()
{
int num1 = 1;
int num2 = functionToCall(_, num1);
return 0;
}
Источник: https://stackoverflow.com/questions/781 ... ction-in-c
Мобильная версия