Skip to content

gen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMapgen_image_to_world_plane_mapT_gen_image_to_world_plane_mapπŸ”—

Short descriptionπŸ”—

gen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMapgen_image_to_world_plane_mapT_gen_image_to_world_plane_map β€” Generate a projection map that describes the mapping between the image plane and the plane z=0 of a world coordinate system.

SignatureπŸ”—

gen_image_to_world_plane_map( out image Map, campar CameraParam, pose WorldPose, extent.x WidthIn, extent.y HeightIn, extent.x WidthMapped, extent.y HeightMapped, number Scale, string MapType )void GenImageToWorldPlaneMap( HObject* Map, const HTuple& CameraParam, const HTuple& WorldPose, const HTuple& WidthIn, const HTuple& HeightIn, const HTuple& WidthMapped, const HTuple& HeightMapped, const HTuple& Scale, const HTuple& MapType )static void HOperatorSet.GenImageToWorldPlaneMap( out HObject map, HTuple cameraParam, HTuple worldPose, HTuple widthIn, HTuple heightIn, HTuple widthMapped, HTuple heightMapped, HTuple scale, HTuple mapType )def gen_image_to_world_plane_map( camera_param: Sequence[Union[int, float, str]], world_pose: Sequence[Union[int, float]], width_in: int, height_in: int, width_mapped: int, height_mapped: int, scale: Union[int, float, str], map_type: str ) -> HObject

Herror T_gen_image_to_world_plane_map( Hobject* Map, const Htuple CameraParam, const Htuple WorldPose, const Htuple WidthIn, const Htuple HeightIn, const Htuple WidthMapped, const Htuple HeightMapped, const Htuple Scale, const Htuple MapType )

void HImage::GenImageToWorldPlaneMap( const HCamPar& CameraParam, const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HTuple& Scale, const HString& MapType )

void HImage::GenImageToWorldPlaneMap( const HCamPar& CameraParam, const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HString& Scale, const HString& MapType )

void HImage::GenImageToWorldPlaneMap( const HCamPar& CameraParam, const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const char* Scale, const char* MapType )

void HImage::GenImageToWorldPlaneMap( const HCamPar& CameraParam, const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const wchar_t* Scale, const wchar_t* MapType ) (Windows only)

HImage HCamPar::GenImageToWorldPlaneMap( const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HTuple& Scale, const HString& MapType ) const

HImage HCamPar::GenImageToWorldPlaneMap( const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HString& Scale, const HString& MapType ) const

HImage HCamPar::GenImageToWorldPlaneMap( const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const char* Scale, const char* MapType ) const

HImage HCamPar::GenImageToWorldPlaneMap( const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const wchar_t* Scale, const wchar_t* MapType ) const (Windows only)

HImage HPose::GenImageToWorldPlaneMap( const HCamPar& CameraParam, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HTuple& Scale, const HString& MapType ) const

HImage HPose::GenImageToWorldPlaneMap( const HCamPar& CameraParam, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HString& Scale, const HString& MapType ) const

HImage HPose::GenImageToWorldPlaneMap( const HCamPar& CameraParam, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const char* Scale, const char* MapType ) const

HImage HPose::GenImageToWorldPlaneMap( const HCamPar& CameraParam, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const wchar_t* Scale, const wchar_t* MapType ) const (Windows only)

void HImage.GenImageToWorldPlaneMap( HCamPar cameraParam, HPose worldPose, int widthIn, int heightIn, int widthMapped, int heightMapped, HTuple scale, string mapType )

void HImage.GenImageToWorldPlaneMap( HCamPar cameraParam, HPose worldPose, int widthIn, int heightIn, int widthMapped, int heightMapped, string scale, string mapType )

HImage HCamPar.GenImageToWorldPlaneMap( HPose worldPose, int widthIn, int heightIn, int widthMapped, int heightMapped, HTuple scale, string mapType )

HImage HCamPar.GenImageToWorldPlaneMap( HPose worldPose, int widthIn, int heightIn, int widthMapped, int heightMapped, string scale, string mapType )

HImage HPose.GenImageToWorldPlaneMap( HCamPar cameraParam, int widthIn, int heightIn, int widthMapped, int heightMapped, HTuple scale, string mapType )

HImage HPose.GenImageToWorldPlaneMap( HCamPar cameraParam, int widthIn, int heightIn, int widthMapped, int heightMapped, string scale, string mapType )

DescriptionπŸ”—

gen_image_to_world_plane_mapGenImageToWorldPlaneMap generates a projection map Mapmapmap, which describes the mapping between the image plane and the plane z=0 (plane of measurements) in a world coordinate system. This map can be used to rectify an image with the operator map_imageMapImage. The rectified image shows neither radial nor perspective distortions; it corresponds to an image acquired by a distortion-free camera that looks perpendicularly onto the plane of measurements. The world coordinate system (wcs) is chosen by passing its 3D pose relative to the camera coordinate system (ccs) in WorldPoseworldPoseworld_pose. Thus the pose is expected in the form \(\mvPoseVar{{ccs}}{wcs}\) (see Transformations / Poses and β€œSolution Guide III-C - 3D Vision”). In CameraParamcameraParamcamera_param you must pass the internal camera parameters (see Calibration for the sequence of the parameters and the underlying camera model).

In many cases CameraParamcameraParamcamera_param and WorldPoseworldPoseworld_pose are the result of calibrating the camera with the operator calibrate_camerasCalibrateCameras. See below for an example.

The size of the images to be mapped can be specified by the parameters WidthInwidthInwidth_in and HeightInheightInheight_in. The pixel position of the upper left corner of the output image is determined by the origin of the world coordinate system. The size of the output image can be chosen by the parameters WidthMappedwidthMappedwidth_mapped, HeightMappedheightMappedheight_mapped, and Scalescalescale. WidthMappedwidthMappedwidth_mapped and HeightMappedheightMappedheight_mapped must be given in pixels.

The parameter Scalescalescale can be used to specify the size of a pixel in the transformed image. There are two ways to use this parameter:

  • Scale pixels to metric units: Scale the image such that one pixel in the transformed image corresponds to a metric unit, e.g., setting 'mm'"mm" determines that a pixel in the transformed image corresponds to the area 1mm x 1mm in the plane of measurements. For this, the original unit needs to be meters. This is the case if you use a standard calibration plate.

    List of values: 'm'"m", 'cm'"cm", 'mm'"mm", 'microns'"microns", 'um'"um".

    Default: 'm'"m".

  • Control scaling manually: Scale the image by giving a number that determines the ratio of original unit length / desired number of pixels. E.g., if your original unit is meters and you want every pixel of your transformed image to represent 3mm x 3mm of the measuring plane, your scale is calculated \(\textrm{Scale} = 0.003 / 1 = 0.003\). If you want to perform a task like shape-based matching on your transformed image, it is useful to scale the image such that its content appears in a size similar to the original image.

    Restriction: Scalescalescale > 0.

The mapping function is stored in the output image Mapmapmap. Mapmapmap has the same size as the resulting images after the mapping. MapTypemapTypemap_type is used to specify the type of the output Mapmapmap. If 'nearest_neighbor'"nearest_neighbor" is chosen, Mapmapmap consists of one image containing one channel, in which for each pixel of the resulting image the linearized coordinate of the pixel of the input image is stored that is the nearest neighbor to the transformed coordinates. If 'bilinear'"bilinear" interpolation is chosen, Mapmapmap consists of one image containing five channels. In the first channel for each pixel in the resulting image the linearized coordinates of the pixel in the input image is stored that is in the upper left position relative to the transformed coordinates. The four other channels contain the weights of the four neighboring pixels of the transformed coordinates which are used for the bilinear interpolation, in the following order:

2 3
4 5

The second channel, for example, contains the weights of the pixels that lie to the upper left relative to the transformed coordinates. If 'coord_map_sub_pix'"coord_map_sub_pix" is chosen, Mapmapmap consists of one vector field image of the semantic type β€˜vector_field_absolute’, in which for each pixel of the resulting image the subpixel precise coordinates in the input image are stored.

If several images have to be mapped using the same camera parameters, gen_image_to_world_plane_mapGenImageToWorldPlaneMap in combination with map_imageMapImage is much more efficient than the operator image_to_world_planeImageToWorldPlane because the mapping function needs to be computed only once.

If you want to re-use the created map in another program, you can save it as a multi-channel image with the operator write_imageWriteImage, using the format 'tiff'"tiff".

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

ParametersπŸ”—

Mapmapmap (output_object) (multichannel-)image β†’ object (int4 / int8 / uint2 / vector_field)HObject (int4 / int8 / uint2 / vector_field)HImage (int4 / int8 / uint2 / vector_field)HObject (int4 / int8 / uint2 / vector_field)Hobject * (int4 / int8 / uint2 / vector_field)

Image containing the mapping data.

CameraParamcameraParamcamera_param (input_control) campar β†’ (real / integer / string)HTuple (double / Hlong / HString)HCamPar, HTuple (double / int / long / string)Sequence[Union[int, float, str]]Htuple (double / Hlong / char*)

Internal camera parameters.

WorldPoseworldPoseworld_pose (input_control) pose β†’ (real / integer)HTuple (double / Hlong)HPose, HTuple (double / int / long)Sequence[Union[int, float]]Htuple (double / Hlong)

3D pose of the world coordinate system in camera coordinates.

Number of elements: 7

WidthInwidthInwidth_in (input_control) extent.x β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Width of the images to be transformed.

Restriction: WidthIn >= 1

HeightInheightInheight_in (input_control) extent.y β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Height of the images to be transformed.

Restriction: HeightIn >= 1

WidthMappedwidthMappedwidth_mapped (input_control) extent.x β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Width of the resulting mapped images in pixels.

Restriction: WidthMapped >= 1

HeightMappedheightMappedheight_mapped (input_control) extent.y β†’ (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Height of the resulting mapped images in pixels.

Restriction: HeightMapped >= 1

Scalescalescale (input_control) number β†’ (string / integer / real)HTuple (HString / Hlong / double)HTuple (string / int / long / double)Union[int, float, str]Htuple (char* / Hlong / double)

Scale or unit.

Default: 'm'"m"
Suggested values: 'm', 'cm', 'mm', 'microns', 'um', 1.0, 0.01, 0.001, 1.0e-6, 0.0254, 0.3048, 0.9144"m", "cm", "mm", "microns", "um", 1.0, 0.01, 0.001, 1.0e-6, 0.0254, 0.3048, 0.9144
Restriction: Scale > 0

MapTypemapTypemap_type (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Type of the mapping.

Default: 'bilinear'"bilinear"
List of values: 'bilinear', 'coord_map_sub_pix', 'nearest_neighbor'"bilinear", "coord_map_sub_pix", "nearest_neighbor"

ExampleπŸ”—

(HDevelop)


* Calibrate camera.
calibrate_cameras (CalibDataID, Error)
* Obtain camera parameters.
get_calib_data (CalibDataID, 'camera', 0, 'params', CamParam)
* Example values, if no calibration data is available:
CamParam := ['area_scan_division', 0.0087, -1859, 8.65e-006, 8.6e-006, \
             362.5, 291.6, 768, 576]
* Get reference pose (pose 4 of calibration object 0).
get_calib_data (CalibDataID, 'calib_obj_pose',\
                [0,4], 'pose', Pose)
* Example values, if no calibration data is available:
Pose := [-0.11, -0.21, 2.51, 352.73, 346.73, 336.48, 0]
* Compensate thickness of plate.
set_origin_pose (Pose, -1.125, -1.0, 0, PoseNewOrigin)
* Transform the image into the world plane.
read_image (Image, 'calib/calib-3d-coord-04')
gen_image_to_world_plane_map (MapSingle, CamParam, PoseNewOrigin,\
                  CamParam[6], CamParam[7], 900, 800, 0.0025, 'bilinear')
map_image (Image, MapSingle, ImageMapped)

ResultπŸ”—

gen_image_to_world_plane_mapGenImageToWorldPlaneMap returns 2 (H_MSG_TRUE) if all parameter values are correct. If necessary, an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

create_poseCreatePose, hom_mat3d_to_poseHomMat3dToPose, camera_calibrationCameraCalibration, hand_eye_calibrationHandEyeCalibration, set_origin_poseSetOriginPose

Possible successors

map_imageMapImage

Alternatives

image_to_world_planeImageToWorldPlane

See also

map_imageMapImage, contour_to_world_plane_xldContourToWorldPlaneXld, image_points_to_world_planeImagePointsToWorldPlane

ModuleπŸ”—

Calibration