ClassesClassesClassesClasses | | | | Operators

gen_image_to_world_plane_mapT_gen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap (Operator)

Name

gen_image_to_world_plane_mapT_gen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap — Generate a projection map that describes the mapping between the image plane and a the plane z=0 of a world coordinate system.

Signature

gen_image_to_world_plane_map( : Map : CameraParam, WorldPose, WidthIn, HeightIn, WidthMapped, HeightMapped, Scale, MapType : )

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)

Herror 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)

HImage HImage::GenImageToWorldPlaneMap(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 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)

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

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

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

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

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

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

void HOperatorSetX.GenImageToWorldPlaneMap(
[out] IHUntypedObjectX*Map, [in] VARIANT CameraParam, [in] VARIANT WorldPose, [in] VARIANT WidthIn, [in] VARIANT HeightIn, [in] VARIANT WidthMapped, [in] VARIANT HeightMapped, [in] VARIANT Scale, [in] VARIANT MapType)

void HImageX.GenImageToWorldPlaneMap(
[in] VARIANT CameraParam, [in] VARIANT WorldPose, [in] Hlong WidthIn, [in] Hlong HeightIn, [in] Hlong WidthMapped, [in] Hlong HeightMapped, [in] VARIANT Scale, [in] BSTR MapType)

IHImageX* HPoseX.GenImageToWorldPlaneMap(
[in] VARIANT CameraParam, [in] VARIANT WorldPose, [in] Hlong WidthIn, [in] Hlong HeightIn, [in] Hlong WidthMapped, [in] Hlong HeightMapped, [in] VARIANT Scale, [in] BSTR MapType)

static void HOperatorSet.GenImageToWorldPlaneMap(out HObject map, HTuple cameraParam, HTuple worldPose, HTuple widthIn, HTuple heightIn, HTuple widthMapped, HTuple heightMapped, HTuple scale, HTuple mapType)

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

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

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

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

Description

gen_image_to_world_plane_mapgen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap generates a projection map MapMapMapMapMapmap, 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_imagemap_imageMapImagemap_imageMapImageMapImage. 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 is chosen by passing its 3D pose relative to the camera coordinate system in WorldPoseWorldPoseWorldPoseWorldPoseWorldPoseworldPose. In CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam you must pass the internal camera parameters (see calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras for the sequence of the parameters and the underlying camera model).

In many cases CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam and WorldPoseWorldPoseWorldPoseWorldPoseWorldPoseworldPose are the result of calibrating the camera with the operator calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras. See below for an example.

The size of the images to be mapped can be specified by the parameters WidthInWidthInWidthInWidthInWidthInwidthIn and HeightInHeightInHeightInHeightInHeightInheightIn. 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 WidthMappedWidthMappedWidthMappedWidthMappedWidthMappedwidthMapped, HeightMappedHeightMappedHeightMappedHeightMappedHeightMappedheightMapped, and ScaleScaleScaleScaleScalescale. WidthMappedWidthMappedWidthMappedWidthMappedWidthMappedwidthMapped and HeightMappedHeightMappedHeightMappedHeightMappedHeightMappedheightMapped must be given in pixels.

With the parameter ScaleScaleScaleScaleScalescale you can specify the size of a pixel in the transformed image. There are two typical scenarios: First, you can scale the image such that pixel coordinates in the transformed image directly correspond to metric units, e.g., that one pixel corresponds to one micron. This is useful if you want to perform measurements in the transformed image which will then directly result in metric results. The second scenario is to scale the image such that its content appears in a size similar to the original image. This is useful, e.g., if you want to perform shape-based matching in the transformed image.

ScaleScaleScaleScaleScalescale must be specified as the ratio desired pixel size/original unit. A pixel size of 1um means that a pixel in the transformed image corresponds to the area 1um x 1um in the plane of measurements. The original unit is determined by the coordinates of the calibration object. If the original unit is meters (which is the case if you use the standard calibration plate), you can use the parameter values 'm'"m""m""m""m""m", 'cm'"cm""cm""cm""cm""cm", 'mm'"mm""mm""mm""mm""mm", 'microns'"microns""microns""microns""microns""microns", or 'um'"um""um""um""um""um" to directly set the unit of pixel coordinates in the transformed image.

The mapping function is stored in the output image MapMapMapMapMapmap. MapMapMapMapMapmap has the same size as the resulting images after the mapping. MapTypeMapTypeMapTypeMapTypeMapTypemapType is used to specify the type of the output MapMapMapMapMapmap. If 'nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor" is chosen, MapMapMapMapMapmap 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""bilinear""bilinear""bilinear""bilinear" interpolation is chosen, MapMapMapMapMapmap 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 'coordinate_map_sub_pix'"coordinate_map_sub_pix""coordinate_map_sub_pix""coordinate_map_sub_pix""coordinate_map_sub_pix""coordinate_map_sub_pix" is chosen, MapMapMapMapMapmap 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_mapgen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap in combination with map_imagemap_imageMapImagemap_imageMapImageMapImage is much more efficient than the operator image_to_world_planeimage_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane 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_imagewrite_imageWriteImagewrite_imageWriteImageWriteImage, using the format 'tiff'"tiff""tiff""tiff""tiff""tiff".

Parallelization

Parameters

MapMapMapMapMapmap (output_object)  (multichannel-)image objectHImageHImageHImageHImageXHobject * (int4 / int8 / uint2 / vector_field)

Image containing the mapping data.

CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam (input_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Internal camera parameters.

Number of elements: CameraParam == 8 || CameraParam == 10 || CameraParam == 11 || CameraParam == 12 || CameraParam == 14

WorldPoseWorldPoseWorldPoseWorldPoseWorldPoseworldPose (input_control)  pose HPose, HTupleHTupleHTupleHPoseX, VARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

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

Number of elements: 7

WidthInWidthInWidthInWidthInWidthInwidthIn (input_control)  extent.x HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Width of the images to be transformed.

Restriction: WidthIn >= 1

HeightInHeightInHeightInHeightInHeightInheightIn (input_control)  extent.y HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Height of the images to be transformed.

Restriction: HeightIn >= 1

WidthMappedWidthMappedWidthMappedWidthMappedWidthMappedwidthMapped (input_control)  extent.x HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Width of the resulting mapped images in pixels.

Restriction: WidthMapped >= 1

HeightMappedHeightMappedHeightMappedHeightMappedHeightMappedheightMapped (input_control)  extent.y HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Height of the resulting mapped images in pixels.

Restriction: HeightMapped >= 1

ScaleScaleScaleScaleScalescale (input_control)  number HTupleHTupleHTupleVARIANTHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double) (BSTR / Hlong / double) (char* / Hlong / double)

Scale or unit.

Default value: 'm' "m" "m" "m" "m" "m"

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

MapTypeMapTypeMapTypeMapTypeMapTypemapType (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Type of the mapping.

Default value: 'bilinear' "bilinear" "bilinear" "bilinear" "bilinear" "bilinear"

List of values: 'bilinear'"bilinear""bilinear""bilinear""bilinear""bilinear", 'coord_map_sub_pix'"coord_map_sub_pix""coord_map_sub_pix""coord_map_sub_pix""coord_map_sub_pix""coord_map_sub_pix", 'nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""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:=[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)
* Cleanup
clear_calib_data (CalibDataID)

Result

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

Possible Predecessors

create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose, hom_mat3d_to_posehom_mat3d_to_poseHomMat3dToPosehom_mat3d_to_poseHomMat3dToPoseHomMat3dToPose, camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration, hand_eye_calibrationhand_eye_calibrationHandEyeCalibrationhand_eye_calibrationHandEyeCalibrationHandEyeCalibration, set_origin_poseset_origin_poseSetOriginPoseset_origin_poseSetOriginPoseSetOriginPose

Possible Successors

map_imagemap_imageMapImagemap_imageMapImageMapImage

Alternatives

image_to_world_planeimage_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane

See also

map_imagemap_imageMapImagemap_imageMapImageMapImage, contour_to_world_plane_xldcontour_to_world_plane_xldContourToWorldPlaneXldcontour_to_world_plane_xldContourToWorldPlaneXldContourToWorldPlaneXld, image_points_to_world_planeimage_points_to_world_planeImagePointsToWorldPlaneimage_points_to_world_planeImagePointsToWorldPlaneImagePointsToWorldPlane

Module

Calibration


ClassesClassesClassesClasses | | | | Operators