worldpointset

Manage 3-D to 2-D point correspondences

Description

The worldpointset object stores correspondences between 3-D world points and 2-D image points across camera views. You can use a worldpointset object with an imageviewset object to manage image and map data for structure-from-motion, visual odometry, and visual simultaneous localization and mapping (SLAM).

Creation

Description

example

wpSet = worldpointset creates a worldpointset object with default properties. Use the object functions to perform actions such as adding, modifying or removing correspondences, finding points in a view, and finding views of points.

Properties

expand all

This property is read-only.

3-D world points, specified as an M-by-3 matrix with rows containing [x y z] world points. M is the number of 3-D world points.

This property is read-only.

Identifiers for views associated with world points, specified as an N-element row vector of integers.

This property is read-only.

Number of 3-D world points, specified as a scalar.

This property is read-only.

3-D to 2-D point correspondences, specified as a three-column table.

ColumnDescription
PointIndexEach row contains the linear index of a world point.
ViewIdEach row contains a 1-by-N vector specifying the IDs of the views associated with the corresponding world points. N is the number of views associated with the world point.
FeatureIndexEach row contains a 1-by-N vector specifying the indices of the feature points that correspond to the world point. Each element is the index of the feature point in the view specified by the corresponding element in the ViewID cell.

Object Functions

addWorldPointsAdd world points to world point set
removeWorldPointsRemove world points from world point set
updateWorldPointsUpdate world points in world point set
addCorrespondencesUpdate world points in a world point set
removeCorrespondencesRemove 3-D to 2-D correspondences from world point set
updateCorrespondencesUpdate 3-D to 2-D correspondences in world point set
findViewsOfWorldPointFind views that observe a world point
findWorldPointsInTracksFind world points that correspond to point tracks
findWorldPointsInViewFind world points observed in view

Examples

collapse all

Load a MAT-file containing stereo parameters into the workspace.

load('webcamsSceneReconstruction.mat');

Read a stereo pair of images into the workspace.

I1 = imread('sceneReconstructionLeft.jpg');
I2 = imread('sceneReconstructionRight.jpg');

Undistort the images.

I1 = undistortImage(I1,stereoParams.CameraParameters1);
I2 = undistortImage(I2,stereoParams.CameraParameters2);

Define a rectangular region of interest (ROI), in the format [x y width height] .

roi = [30 30 size(I1,2)-30 size(I1,1)-30];

Detect and extract Speeded-Up Robust Features (SURF) from both images using the ROI.

imagePoints1 = detectSURFFeatures(rgb2gray(I1),'ROI',roi);
imagePoints2 = detectSURFFeatures(rgb2gray(I2),'ROI',roi);
  
[feature1,validPoints1] = extractFeatures(rgb2gray(I1),imagePoints1,'Upright',true);
[feature2,validPoints2] = extractFeatures(rgb2gray(I2),imagePoints2,'Upright',true);

Match the extracted features to each other.

indexPairs = matchFeatures(feature1,feature2);

Compute the 3-D world points.

matchedPoints1 = validPoints1(indexPairs(:,1));
matchedPoints2 = validPoints2(indexPairs(:,2));
worldPoints    = triangulate(matchedPoints1,matchedPoints2,stereoParams);

Create a worldpointset object to manage correspondences.

wpSet = worldpointset;

Add the world points to the worldpointset.

[wpSet,newPointIndices] = addWorldPoints(wpSet,worldPoints);

Add the 3-D to 2-D point correspondences to the worldpointset.

wpSet = addCorrespondences(wpSet,1,newPointIndices,indexPairs(:,1));
wpSet = addCorrespondences(wpSet,2,newPointIndices,indexPairs(:,2));

Display the world points.

pcshow(wpSet.WorldPoints,'VerticalAxis','y','VerticalAxisDir','down','MarkerSize',45)

Introduced in R2020b