pointsToWorld
(Not recommended) Determine world coordinates of image points
pointsToWorld is not recommended. Use the img2world2d function instead. For more information, see Version History.
Syntax
Description
maps undistorted image points worldPoints = pointsToWorld(intrinsics,tform,imagePoints)imagePoints, onto points on the
X-Y plane in world coordinates,
worldPoints using the rigid3d
transformation tform.
returns world points on the X-Y plane, which
correspond to the input image points. Points are converted using the input rotation
matrix, translation vector, and camera intrinsics.worldPoints = pointsToWorld(intrinsics,rotationMatrix,translationVector,imagePoints)
Examples
Map the points of a fisheye image to world coordinates and compare these points to the ground truth points. A series of checkerboard pattern images are used to estimate the fisheye parameters and calibrate the camera.
Create a set of checkerboard calibration images.
images = imageDatastore(fullfile(toolboxdir('vision'),'visiondata' ,... 'calibration','gopro'));
Detect the checkerboard corners in the images. Leave the last image for testing.
[imagePoints,boardSize] = detectCheckerboardPoints(images.Files(1:end-1));
Generate the world coordinates of the checkerboard corners in the pattern-centric coordinate system, with the upper-left corner at (0,0).
squareSize = 29; % millimeters worldPoints = patternWorldPoints('checkerboard',boardSize,squareSize);
Estimate the fisheye camera parameters from the image and world points. Use the first image to get image size.
I = imread(images.Files{end});
imageSize = [size(I,1) size(I,2)];
fisheyeParams = estimateFisheyeParameters(imagePoints,worldPoints,imageSize);
intrinsics = fisheyeParams.Intrinsics;Find the reference object in the new image.
imagePoints = detectCheckerboardPoints(I, 'PartialDetections', false);Compute new extrinsics.
[R,t] = extrinsics(imagePoints,worldPoints,intrinsics);
Map image points to world coordinates in the X-Y plane.
newWorldPoints = pointsToWorld(intrinsics,R,t,imagePoints);
Compare estimated world points to the ground truth points.
plot(worldPoints(:,1),worldPoints(:,2),'gx'); hold on plot(newWorldPoints(:,1),newWorldPoints(:,2),'ro'); legend('Ground Truth','Estimates'); hold off

Input Arguments
Camera parameters, specified as a cameraIntrinsics or a fisheyeIntrinsics object. The objects store information about
a camera’s intrinsic calibration parameters, including the lens distortion
parameters.
Transformation of the camera in world coordinates, specified as a rigid3d object.
3-D rotation of the world coordinates relative to the image coordinates,
specified as a 3-by-3 matrix. The rotation matrix, together with the
translation vector, enable you to transform points from the world coordinate
system to the camera coordinate system. The
rotationMatrix and
translationVector inputs must be the same data type.

Data Types: double | single
3-D translation of the world coordinates relative to the image
coordinates, specified as a 1-by-3 vector. The translation vector, together
with the rotation matrix, enable you to transform points from the world
coordinate system to the camera coordinate system. The
rotationMatrix and
translationVector inputs must be the same data type.

Data Types: double | single
Image points, specified as an M-by-2 matrix containing M [x, y] coordinates of image points.
When using the cameraParameters object as the
cameraParams input,
pointsToWorld does not account for lens distortion.
Therefore, the imagePoints input must contain image
points detected in the undistorted image, or they must be undistorted using
the undistortPoints function.
For a fisheyeIntrinsics object, the image points are
distorted.
Output Arguments
World coordinates, returned as an M-by-2 matrix. M represents the number of undistorted points in [x, y] world coordinates.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2016aStarting in R2022b, most Computer Vision Toolbox™ functions create and perform geometric transformations using the
premultiply convention. However, the pointsToWorld function
uses the postmultiply convention. Although there are no plans to remove
pointsToWorld at this time, you can streamline your
geometric transformation workflows by switching to the img2world2d function, which supports the premultiply convention. For
more information, see Migrate Geometric Transformations to Premultiply Convention.
To update your code:
Change instances of the function name
pointsToWorldtoimg2world2d.Switch the order of the
intrinsicsand theimagePointsarguments.Specify the transformation as a
rigidtform3dobject using thetformargument.img2world2ddoes not support therotationMatrixandtranslationVectorinput arguments. Note that you create therigidtform3dobject using the transpose ofrotationMatrixor the transpose of the transformation matrix in theTproperty oftform.
| Discouraged Usage | Recommended Replacement |
|---|---|
This example specifies the transformation as a rotation
matrix and a translation vector, then determines the world
coordinates of image points using the
worldPoints = pointsToWorld(intrinsics, ...
rotationMatrix,translationVector,imagePoints) | This example specifies the transformation as a
tform = rigidtform3d(rotationMatrix',translationVector); worldPoints = img2world2d(imagePoints,tform,intrinsics); |
This example specifies the transformation as a
A = [1 0 0 0; 0 1 0 0; 0 0 1 -10; 0 0 0 1]; tformOld = rigid3d(A'); worldPoints = pointsToWorld(intrinsics,tformOld,imagePoints); | This example specifies the transformation as a
A = [1 0 0 0; 0 1 0 0; 0 0 1 -10; 0 0 0 1]; tform = rigidtform3d(A); worldPoints = img2world2d(imagePoints,tform,intrinsics); If
instead you start with an existing T = tformOld.T; tform = rigidtform3d(T'); worldPoints = img2world2d(imagePoints,tform,intrinsics); |
See Also
Apps
Functions
img2world2d|world2img|undistortImage|undistortPoints|estimateCameraParameters|estimateExtrinsics|extr2pose|pose2extr|estworldpose|estrelpose
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)