Info

This question is closed. Reopen it to edit or answer.

I want to estimate the hieght of buliding using triangulate function in Matlab. can anyone short out this problem matlab

2 views (last 30 days)
clc; close all; clearvars
I1Color=imread('DSC_0132.jpg');
I2Color=imread('DSC_0133.jpg');
I1=rgb2gray(I1Color);
I2=rgb2gray(I2Color);
figure;subplot(121);imshow(I1);subplot(122); imshow(I2);
figure;
points1 = detectSURFFeatures(I1,'MetricThreshold',1000);
points2 = detectSURFFeatures(I2,'MetricThreshold',1000);
%%Extract features.
[f1, vpts1] = extractFeatures(I1, points1);
[f2, vpts2] = extractFeatures(I2, points2);
%%Match features.
indexPairs = matchFeatures(f1, f2, 'MaxRatio',0.4,'Unique',true) ;
matchedPoints1 = vpts1(indexPairs(:, 1));
matchedPoints2 = vpts2(indexPairs(:, 2));
%Visualize candidate matches.
f=18e-3/3.92e-6;
intrinsics = cameraIntrinsics([4591.8 4591.8],[3000 2000],size(I1));
cameraParams = cameraParameters('IntrinsicMatrix',intrinsics.IntrinsicMatrix);
%[tform,inlierpoints1,inlierpoints2] = estimateGeometricTransform(matchedPoints2, matchedPoints1,'projective');
[E,inliersIndex] = estimateEssentialMatrix(matchedPoints1,matchedPoints2,cameraParams);
inliers1=matchedPoints1(inliersIndex);
inliers2=matchedPoints2(inliersIndex);
[relativeOrientation,relativeLocation] = relativeCameraPose(E,cameraParams,inliers1,inliers2);
stereoParams = stereoParameters(cameraParams,cameraParams,relativeOrientation,relativeLocation*8);
point3d = triangulate([3628 2779;2664 628], [3165 2630;3221 509], stereoParams);
distanceInMeters = norm(point3d)/1000;
distanceAsString = sprintf('%0.2f meters', distanceInMeters);

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!