Subversion Repositories seema-scanner

Rev

Rev 216 | Rev 219 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 216 Rev 218
Line 53... Line 53...
53
    e1Coords = autoDetectMarkers(frame1, P1, Q);
53
    e1Coords = autoDetectMarkers(frame1, P1, Q);
54
    
54
    
55
    %e0Coords = manuallyDetectMarkers(frame0, P0, Q);
55
    %e0Coords = manuallyDetectMarkers(frame0, P0, Q);
56
    %e1Coords = manuallyDetectMarkers(frame1, P1, Q);
56
    %e1Coords = manuallyDetectMarkers(frame1, P1, Q);
57
    
57
    
58
    e0Coords = undistortPoints(e0Coords, camParams0);
58
    %e0Coords = undistortPoints(e0Coords, camParams0);
59
    e1Coords = undistortPoints(e1Coords, camParams1);
59
    %e1Coords = undistortPoints(e1Coords, camParams1);
60
 
60
 
61
    % match ellipse candidates between cameras based on projection
61
    % match ellipse candidates between cameras based on projection
62
    E0 = projectOntoPointCloud(e0Coords, P0, Q);
62
    E0 = projectOntoPointCloud(e0Coords, P0, Q);
63
    E1 = projectOntoPointCloud(e1Coords, P1, Q);
63
    E1 = projectOntoPointCloud(e1Coords, P1, Q);
64
 
64
 
Line 78... Line 78...
78
    end
78
    end
79
    matchedPairs = matchedPairs(1:nMatchedPairs, :);
79
    matchedPairs = matchedPairs(1:nMatchedPairs, :);
80
    
80
    
81
    % triangulate marker centers (lens correction has been performed)
81
    % triangulate marker centers (lens correction has been performed)
82
    [E{i}, e] = triangulate(e0Coords(matchedPairs(:, 1),:), e1Coords(matchedPairs(:, 2),:), camStereoParams);
82
    [E{i}, e] = triangulate(e0Coords(matchedPairs(:, 1),:), e1Coords(matchedPairs(:, 2),:), camStereoParams);
83
    E{i} = E{i}(e<1.0, :);
83
    E{i} = E{i}(e<3.0, :);
-
 
84
    display(e);
84
    
85
    
85
    % write point cloud with marker (debugging)
86
    % write point cloud with marker (debugging)
86
    pcDebug = pointCloud([pc.Location; E{i}], 'Color', [pc.Color; repmat([255, 0, 0], size(E{i}, 1), 1)]);
87
    pcDebug = pointCloud([pc.Location; E{i}], 'Color', [pc.Color; repmat([255, 0, 0], size(E{i}, 1), 1)]);
87
    pcwrite(pcDebug, 'pcDebug.ply');
88
    pcwrite(pcDebug, 'pcDebug.ply');
88
    
89
    
Line 148... Line 149...
148
 
149
 
149
% show found markers in optimized alignment
150
% show found markers in optimized alignment
150
figure;
151
figure;
151
hold('on');
152
hold('on');
152
for i=1:nSubScans
153
for i=1:nSubScans
-
 
154
    % fix Ri to be orthogonal
153
    Ri = alignment(i).Rotation;
155
    [U,~,V] = svd(alignment(i).Rotation);
-
 
156
    Ri = U*V';
154
    Ti = alignment(i).Translation;
157
    Ti = alignment(i).Translation;
155
    
158
    
156
    Ea = E{i}*Ri' + repmat(Ti', size(E{i}, 1), 1);
159
    Ea = E{i}*Ri' + repmat(Ti', size(E{i}, 1), 1);
157
    
160
    
158
    % bring point cloud into optimized alignment
161
    % bring point cloud into optimized alignment
Line 295... Line 298...
295
        %figure; imshowpair(imMarkerSpace, m);
298
        %figure; imshowpair(imMarkerSpace, m);
296
        
299
        
297
        % perform image registration
300
        % perform image registration
298
        % might be better off using subpixel image correlation
301
        % might be better off using subpixel image correlation
299
        [opt, met] = imregconfig('multimodal');
302
        [opt, met] = imregconfig('multimodal');
300
        T = imregtform(m, imMarkerSpace, 'translation', opt, met, 'DisplayOptimization', true);
303
        T = imregtform(m, imMarkerSpace, 'translation', opt, met, 'DisplayOptimization', false);
301
        
304
        
302
        rege = imwarp(m, T, 'OutputView', imref2d(size(m)));
305
        rege = imwarp(m, T, 'OutputView', imref2d(size(m)));
303
        %figure; imshowpair(imMarkerSpace, rege);
306
        %figure; imshowpair(imMarkerSpace, rege);
304
        
307
        
305
        % measure of correlation
308
        % measure of correlation