-
Notifications
You must be signed in to change notification settings - Fork 2
/
slit_scan.m
101 lines (88 loc) · 2.87 KB
/
slit_scan.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
function slit_scan()
clc; clear; close all; imaqreset;
% To specify the number of images to be taken as the slit sweeps over the
% surface of the object.
prompt = {'Enter the number of images to be taken:'};
dlg_title = 'Input';
num_lines = 1;
answer = inputdlg(prompt,dlg_title,num_lines);
if isempty(answer)
return;
end
num = str2double(answer{1});
% Connect to cameras
v1 = imaq.VideoDevice('pointgrey',1);
v2 = imaq.VideoDevice('pointgrey',2);
release(v1); release(v2);
v1.VideoFormat = 'F7_RGB_1288x964_Mode0';
v2.VideoFormat = 'F7_RGB_1288x964_Mode0';
pause(0.75);
% Creating folders for the images.
disp('Creating folders');
mkdir('Recons_Images')
f = get(0,'ScreenSize');
% Creating an object with it's dimensions same as the dimensions of the
% screen which will be projected on the surface of the object.
im = zeros(f(4),f(3),3);
l = (f(4)) / num;
im(1,:,2) = 1;
k = 0;
% Moving the slit from top to bottom at equal
for i = 1:ceil(l):f(4)
if i ~= 1
im(1:i,:,2) = 0;
end
im(i,:,2) = 1;
% im(:,:,2) = circshift(im(:,:,2),ceil(l));
k = k + 1;
im1(k,:) = {im};
end
disp('Press enter to start taking the images after a blank screen appears');
pause(2);
% Adjusting the size and position of the figure handle
hFig = figure('Menubar','none', 'Units','normalized', 'Position',[0 0 1 1]);
set(hFig, 'Units','pixels')
p = get(hFig, 'Position');
set(hFig, 'Position', [f(3)+1 31 f(3) f(4)]);
img = im1{1};
fpos = get(hFig,'Position');
axOffset = (fpos(3:4)-[size(img,2) size(img,1)])/2;
ha = axes('Parent',hFig,'Units','pixels','Position',[axOffset size(img,2) size(img,1)]);
imshow(im1{1},'Parent',ha);
pause;
% Capturing images as the slit is moving
for i = 1 : length(im1)
imshow(im1{i}, 'Parent', ha);
[im_l, im_r] = cam_images(v1, v2);
iml(i,:) = {im_l};
imr(i,:) = {im_r};
clear im_l; clear im_r;
pause(0.001);
end
pause(0.75); close all
% Uncomment the below to save the images
% disp('Saving the images');
% for num = 1 : length(im1)
% fn1 = sprintf('cam--1-%d.tiff', num); % Left
% fn2 = sprintf('cam--0-%d.tiff', num); % Right
% file1 = fullfile('.\Recons_Images\',fn1);
% file2 = fullfile('.\Recons_Images\',fn2);
% imwrite(im2double(iml{num}), file1);
% imwrite(im2double(imr{num}), file2);
% end
disp('Done!');
%% Reconstruction
disp('Reconstrucion');
% base_folder = 'C:\Users\croma\Documents\DivyaASI';
plyfile = 'plyfile.ply';
step = 1;
start = 20;
final = 40;
% Calibration
% Load the mat file obtained after calibration
load('C:\Users\croma\Documents\DivyaASI\calibrationSession3.mat');
stereoParams = calibrationSession.CameraParameters;
% calculating F matrix
F = stereoParams.FundamentalMatrix;
eyeRecons(F, start, final, iml, imr, plyfile, step, stereoParams);
disp('Reconstruction done, please check the PLY file');