# Revision history [back]

### Image_transport using member function as callback function

Hello!

I am trying to set up an image transport subscriber which should use a member function as callback method.

I have tried the following standard approach:

class A{
public:
void camCallback1(const sensor_msgs::ImageConstPtr &msg) {
// do something
}

int main(int argc, char **argv) {

ros::init(argc, argv, "test_node");
ros::NodeHandle nh;
A a;
image_transport::ImageTransport it(nh);

image_transport::Subscriber subCam1 = it.subscribe("/raspi_cam1/image_raw", 2,
&A::camCallback1,
&a);
}


like here

This is the only of many methods i have tried that would compile for me. However the callback is never thrown.

I hope can somebody help me out here since I can not find anything regarding this particular problem in the image_transport documentation

### Image_transport using member function as callback function

Hello!

I am trying to set up an image transport subscriber which should use a member function as callback method.

I have tried the following standard approach:

class A{
public:
void camCallback1(const sensor_msgs::ImageConstPtr &msg) {
// do something
}

int main(int argc, char **argv) {

ros::init(argc, argv, "test_node");
ros::NodeHandle nh;
A a;
image_transport::ImageTransport it(nh);

image_transport::Subscriber subCam1 = it.subscribe("/raspi_cam1/image_raw", 2,
&A::camCallback1,
&a);
ros::spin()
}


like here

This is the only of many methods i have tried that would compile for me. However the callback is never thrown.

I hope can somebody help me out here since I can not find anything regarding this particular problem in the image_transport documentation