Update connection between views in a view set
specifies the indices of matched points between two views in addition to any of the input
argument combinations in previous syntaxes.
vSet = addConnection(___,'Matches',
Update Connection in Image View Set
Create an empty image view set.
vSet = imageviewset;
Read two images into the workspace.
imageDir= fullfile(toolboxdir("vision"),"visiondata","structureFromMotion"); I1 = im2gray(imread(fullfile(imageDir,"image1.jpg"))); I2 = im2gray(imread(fullfile(imageDir,"image2.jpg")));
Detect interest points in each image.
points1 = detectSURFFeatures(I1); points2 = detectSURFFeatures(I2);
Extract feature descriptors from the interest points.
[features1,validPoints1] = extractFeatures(I1,points1); [features2,validPoints2] = extractFeatures(I2,points2);
Add features and the points for the two images to the image view set.
vSet = addView(vSet,1,Features=features1,Points=validPoints1); vSet = addView(vSet,2,Features=features2,Points=validPoints2);
Match the features between the two images. Then, store the matched features as a connection in the image view set.
indexPairs = matchFeatures(features1,features2); vSet = addConnection(vSet,1,2,Matches=indexPairs);
Create a relative pose between the views. Then,update the connection in the image view set.
theta = 30; % degrees rot = [ cosd(theta) -sind(theta) 0; ... sind(theta) cosd(theta) 0; ... 0 0 1]; trans = [2 3 4]; tform = rigidtform3d(rot,trans); vSet = updateConnection(vSet,1,2,tform);
viewId1 — View identifier 1
View identifier 1, specified as an integer. View identifiers are unique to a specific view.
viewId2 — View identifier 2
View identifier 2, specified as an integer. View identifiers are unique to a specific view.
relPose — Relative pose
rigidtform3d object |
Relative pose of
viewId2 with respect to
viewId1, specified as a
infoMat — Information matrix
6-by-6 numeric matrix
Information matrix associated with the connection, specified as a 6-by-6 numeric matrix.
featureMatches — Indices of matched points between two views
Indices of matched points between two views, specified as an M-b-2 matrix.
vSet — View set with updated connections
View set with updated connections, returned as an
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version HistoryIntroduced in R2020a
R2022b: Supports premultiply geometric transformation convention
Starting in R2022b, most Computer Vision Toolbox™ functions create and perform geometric transformations using the premultiply
convention. Accordingly, you can now specify the
relPose argument as a
object, which use the premultiply convention.
Although you can still specify
relPose as a
affine3d object, these objects are not recommended because they use the
postmultiply convention. The
updateConnection function automatically
converts the relative pose to the premultiply convention and returns an
imageviewset object that represents the pose as a