-
Notifications
You must be signed in to change notification settings - Fork 0
/
two_cameras.m
47 lines (29 loc) · 1.05 KB
/
two_cameras.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
clear;
cam = webcam(1);
calib_image = rgb2gray(snapshot(cam));
[r,c]=size(calib_image);
original=calib_image(:,1:700);
distorted=calib_image(:,400:end);
ptsOriginal = detectSURFFeatures(original);
ptsDistorted = detectSURFFeatures(distorted);
[featuresOriginal, validPtsOriginal] = extractFeatures(original, ptsOriginal);
[featuresDistorted, validPtsDistorted] = extractFeatures(distorted, ptsDistorted);
indexPairs = matchFeatures(featuresOriginal, featuresDistorted);
matchedOriginal = validPtsOriginal(indexPairs(:,1));
matchedDistorted = validPtsDistorted(indexPairs(:,2));
[tform, inlierDistorted, inlierOriginal] = estimateGeometricTransform(...
matchedDistorted, matchedOriginal, 'similarity');
% figure(1)
% imshow(original)
% figure(2)
% imshow(distorted)
% figure(3)
% b=imwarp(distorted,tt);
%
% b2=imresize(b,[size(original,1) size(original,2)]);
% imshow([original distorted])
tt=affine2d([1 0 0; 0 1 0; 1000 0 1]);
figure(4)
imshow(imwarp(distorted,tt))
figure(5)
imshow(distorted)