Ask Your Question
1

Tree frames tf

asked 2012-10-02 07:04:29 -0500

Alberto Martín gravatar image

Hi,

This is my scenario:

image description

In a node I publish the webcam image and retrieve the coordinates x,y when the user clicks on the screen. After I publish the coordinates.

void my_mouse_callback( int event, int x, int y, int flags, void* param ){

switch( event ){
    case CV_EVENT_MOUSEMOVE: 
        break;
    case CV_EVENT_LBUTTONDOWN:
        break;
    case CV_EVENT_LBUTTONUP:
        //publicamos x e y
        geometry_msgs::PointStamped pixel;
        pixel.header.frame_id = "webcam";
        pixel.header.stamp = ros::Time();       
        pixel.point.x = x;
        pixel.point.y = y;
        pixel.point.z = 0.0;        
        pub.publish(pixel); 
        break;
}

}

In the other node I subscribe to the coordinates and I calculate the ray of pixel with projectPixelTo3dRay().

void point_callback(const geometry_msgs::PointStampedConstPtr& p){
     tf::TransformListener listener;
     cv::Point2d pixel(p->point.x,p->point.y);
     ROS_INFO("Pixel (%.f,%.f)",pixel.x,pixel.y);
     cv::Point3d ray=model.projectPixelTo3dRay(pixel);
     ROS_INFO("ray.x: %.5f ray.y: %.5f ray.z: %.5f\n",ray.x,ray.y,ray.z);

}

As the camera is on the table, I want to calculate 3d point in the world with Z=0. I want to use tf, but do not know how to create the tree to make the transformations.

What tree should I create?

World-->base_camera-->optic_centre

World-->camera

...

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2012-10-02 16:38:08 -0500

jbohren gravatar image

updated 2012-10-02 16:39:07 -0500

One motivation to have distinct "optical" frames and "camera" frames comes from a matter of modularity. As you know, there are certain assumptions about the orientation of an "optical" frame (z out, x right, y down) with respect to the image data and projection, and this projection is almost always generated from a calibration routine, and needs to be with respect to some reference frame. It's good practice to perform this calibration with respect to some frame that is rigidly attached to the camera. If this reference frame is something like the "world" frame, then you can't change the pose of the camera based on a pose estimator or articulated base. In your case, it looks like the camera is basically fixed to the world, so you won't really get any benefit from doing this, but one more transform in the tree won't hurt, so you might as well calibrate it to a rigid "camera" frame.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-10-02 07:04:29 -0500

Seen: 517 times

Last updated: Oct 02 '12