Subversion Repositories seema-scanner

Rev

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

Rev 214 Rev 215
Line 43... Line 43...
43
    scanDir = strsplit(initialAlign(i).FileName, '/');
43
    scanDir = strsplit(initialAlign(i).FileName, '/');
44
    scanDir = fullfile(scanDir{1:end-1});
44
    scanDir = fullfile(scanDir{1:end-1});
45
    frame0 = imread(fullfile(scanDir, ['sequence_' idString], 'frames0_0.png'));
45
    frame0 = imread(fullfile(scanDir, ['sequence_' idString], 'frames0_0.png'));
46
    frame1 = imread(fullfile(scanDir, ['sequence_' idString], 'frames1_0.png'));
46
    frame1 = imread(fullfile(scanDir, ['sequence_' idString], 'frames1_0.png'));
47
 
47
 
48
    %e0Coords = autoDetectMarkers(frame0, P0, Q);
48
    e0Coords = autoDetectMarkers(frame0, P0, Q);
49
    %e1Coords = autoDetectMarkers(frame1, P1, Q);
49
    e1Coords = autoDetectMarkers(frame1, P1, Q);
50
    
50
    
51
    e0Coords = manuallyDetectMarkers(frame0, P0, Q);
51
    %e0Coords = manuallyDetectMarkers(frame0, P0, Q);
52
    e1Coords = manuallyDetectMarkers(frame1, P1, Q);
52
    %e1Coords = manuallyDetectMarkers(frame1, P1, Q);
53
    
53
    
54
    e0Coords = undistortPoints(e0Coords, camParams0);
54
    e0Coords = undistortPoints(e0Coords, camParams0);
55
    e1Coords = undistortPoints(e1Coords, camParams1);
55
    e1Coords = undistortPoints(e1Coords, camParams1);
56
 
56
 
57
    % match ellipse candidates between cameras based on projection
57
    % match ellipse candidates between cameras based on projection
Line 93... Line 93...
93
    % fix Ri to be orthogonal
93
    % fix Ri to be orthogonal
94
    [U,~,V] = svd(initialAlign(i).Rotation);
94
    [U,~,V] = svd(initialAlign(i).Rotation);
95
    Ri = U*V';
95
    Ri = U*V';
96
    
96
    
97
    % bring point cloud into initial alignment
97
    % bring point cloud into initial alignment
98
    pc = pcread(fullfile(scanDir, initialAlign(i).FileName));
98
    pc = pcread(initialAlign(i).FileName);
99
    tform = affine3d([Ri' [0;0;0]; initialAlign(i).Translation' 1]);
99
    tform = affine3d([Ri' [0;0;0]; initialAlign(i).Translation' 1]);
100
    pcg = pctransform(pc, tform);
100
    pcg = pctransform(pc, tform);
101
   
101
   
102
    pcshow(pcg);
102
    pcshow(pcg);
103
    xlabel('x');
103
    xlabel('x');
Line 146... Line 146...
146
    Ti = alignment(i).Translation;
146
    Ti = alignment(i).Translation;
147
    
147
    
148
    Ea = E{i}*Ri' + repmat(Ti', size(E{i}, 1), 1);
148
    Ea = E{i}*Ri' + repmat(Ti', size(E{i}, 1), 1);
149
    
149
    
150
    % bring point cloud into optimized alignment
150
    % bring point cloud into optimized alignment
151
    pc = pcread(fullfile(scanDir, initialAlign(i).FileName));
151
    pc = pcread(initialAlign(i).FileName);
152
    tform = affine3d([Ri' [0;0;0]; initialAlign(i).Translation' 1]);
152
    tform = affine3d([Ri' [0;0;0]; initialAlign(i).Translation' 1]);
153
    pcg = pctransform(pc, tform);
153
    pcg = pctransform(pc, tform);
154
   
154
   
155
    pcshow(pcg);
155
    pcshow(pcg);
156
    xlabel('x');
156
    xlabel('x');
Line 248... Line 248...
248
        
248
        
249
        % determine 3D points that are part of the marker
249
        % determine 3D points that are part of the marker
250
        % note: we should probably undistort labelMask
250
        % note: we should probably undistort labelMask
251
        pointMask = false(size(q, 1), 1);
251
        pointMask = false(size(q, 1), 1);
252
        for j=1:size(q,1)
252
        for j=1:size(q,1)
-
 
253
            if(round(q(j,2)) > size(labelMask, 1) || round(q(j,1)) > size(labelMask, 2) || round(q(j,2)) < 1 || round(q(j,1)) < 1)
-
 
254
                continue;
-
 
255
            end
-
 
256
            
253
            if(labelMask(round(q(j,2)), round(q(j,1))))
257
            if(labelMask(round(q(j,2)), round(q(j,1))))
254
                pointMask(j) = true;
258
                pointMask(j) = true;
255
            end
259
            end
256
        end
260
        end
257
        
261
        
258
        if(sum(pointMask)) < 50
262
        if(sum(pointMask)) < 10
259
            continue;
263
            continue;
260
        end
264
        end
261
        
265
        
262
        % project 3D points onto local plane
266
        % project 3D points onto local plane
263
        [~, sc, ~] = pca(Q(pointMask, :));
267
        [~, sc, ~] = pca(Q(pointMask, :));