image_geometry
image_geometry simplifies interpreting images geometrically using the parameters from sensor_msgs/CameraInfo.
- class image_geometry.PinholeCameraModel[source]
A pinhole camera is an idealized monocular camera.
- fromCameraInfo(msg)[source]
- Parameters
msg (sensor_msgs.msg.CameraInfo) – camera parameters
Set the camera parameters from the
sensor_msgs.msg.CameraInfo
message.
- project3dToPixel(point)[source]
- Parameters
point ((x, y, z)) – 3D point
Returns the rectified pixel coordinates (u, v) of the 3D point, using the camera \(P\) matrix. This is the inverse of
projectPixelTo3dRay()
.
- projectPixelTo3dRay(uv)[source]
- Parameters
uv ((u, v)) – rectified pixel coordinates
Returns the unit vector which passes from the camera center to through rectified pixel (u, v), using the camera \(P\) matrix. This is the inverse of
project3dToPixel()
.
- rectifyImage(raw, rectified)[source]
- Parameters
raw (
CvMat
orIplImage
) – input imagerectified (
CvMat
orIplImage
) – rectified output image
Applies the rectification specified by camera parameters \(K\) and and \(D\) to image raw and writes the resulting image rectified.
- class image_geometry.StereoCameraModel[source]
An idealized stereo camera.
- fromCameraInfo(left_msg, right_msg)[source]
- Parameters
left_msg (sensor_msgs.msg.CameraInfo) – left camera parameters
right_msg (sensor_msgs.msg.CameraInfo) – right camera parameters
Set the camera parameters from the
sensor_msgs.msg.CameraInfo
messages.
- getDisparity(Z)[source]
- Parameters
Z (float) – Z (depth), in cartesian space
Returns the disparity observed for a point at depth Z. This is the inverse of
getZ()
.
- getZ(disparity)[source]
- Parameters
disparity (float) – disparity, in pixels
Returns the depth at which a point is observed with a given disparity. This is the inverse of
getDisparity()
.Note that a disparity of zero implies Z is infinite.
- project3dToPixel(point)[source]
- Parameters
point ((x, y, z)) – 3D point
Returns the rectified pixel coordinates (u, v) of the 3D point, for each camera, as ((u_left, v_left), (u_right, v_right)) using the cameras’ \(P\) matrices. This is the inverse of
projectPixelTo3d()
.
- projectPixelTo3d(left_uv, disparity)[source]
- Parameters
left_uv ((u, v)) – rectified pixel coordinates
disparity (float) – disparity, in pixels
Returns the 3D point (x, y, z) for the given pixel position, using the cameras’ \(P\) matrices. This is the inverse of
project3dToPixel()
.Note that a disparity of zero implies that the 3D point is at infinity.