ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello there,

I think by following these steps you might achieve results according to your requirement.

a) First you have to subscribe to camera_info, pixel_coordinate, and point cloud topic.

b) Then use image_geometry.PinholeCameraModel() and give your camera information by calling this function image_geometry.PinholeCameraModel().fromCameraInfo(__Camera_INFO__DATA). Note: this function should be called once.

c) Call get_depth function for obtaining the distance of that pixel into the point cloud.

def get_depth(self, x, y):
    gen = pc2.read_points(self.pc, field_names='z', skip_nans=False, uvs=[(x, y)])
    return next(gen)

d) Call camera_model.projectPixelTo3dRay((U,V)) this function and you will get output into vector. Note Z will be always 1.

e) you will have to normalize Z and then after from that vector multiply get_depth function result(distance) with the vector X and Y value.

For more information please refer to this post

Hello there,

I think by following these steps you might achieve results according to your requirement.

a) First you have to subscribe to camera_info, pixel_coordinate, and point cloud topic.

b) Then use image_geometry.PinholeCameraModel() and give your camera information by calling this function image_geometry.PinholeCameraModel().fromCameraInfo(__Camera_INFO__DATA). Note: this function should be called once.

c) Call get_depth function for obtaining the distance of that pixel into the point cloud.

def get_depth(self, x, y):
    gen = pc2.read_points(self.pc, field_names='z', skip_nans=False, uvs=[(x, y)])
    return next(gen)

d) Call camera_model.projectPixelTo3dRay((U,V)) this function and you will get output into vector. Note Z will be always 1.

e) you will have to normalize Z and then after from that vector multiply get_depth function result(distance) with the vector X and Y value.

For more information please refer to this post

It seems that they don't have the same resolution either, the image is 640x480 whereas the pointcloud is 1280x720.

When you will subscribe to camera info node and image_geometry.PinholeCameraModel().fromCameraInfo() I think that this will handle your all different resolution of point cloud and color image.

Hello there,

I think by following these steps you might achieve results according to your requirement.

a) First you have to subscribe to camera_info, pixel_coordinate, and point cloud topic.

b) Then use image_geometry.PinholeCameraModel() and give your camera information by calling this function image_geometry.PinholeCameraModel().fromCameraInfo(__Camera_INFO__DATA). Note: this function should be called once.

c) Call get_depth function for obtaining the distance of that pixel into the point cloud.

def get_depth(self, x, y):
    gen = pc2.read_points(self.pc, field_names='z', skip_nans=False, uvs=[(x, y)])
    return next(gen)

d) Call camera_model.projectPixelTo3dRay((U,V)) this function and you will get output into vector. Note Z will be always 1.

e) you will have to normalize Z and then after from that vector multiply get_depth function result(distance) with the vector X and Y value.

For more information please refer to this post

It seems that they don't have the same resolution either, the image is 640x480 whereas the pointcloud is 1280x720.

When you will subscribe to camera info node and image_geometry.PinholeCameraModel().fromCameraInfo() I think that this will handle your all different resolution of point cloud and color image.