Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 1dc429fc0da4cc5ff4f62617760447613f85980b authored by vbhandawat on 01 February 2021, 13:54:09 UTC, committed by GitHub on 01 February 2021, 13:54:09 UTC
Add files via upload
1 parent 17f20a6
  • Files
  • Changes
  • 345c390
  • /
  • Tracking
  • /
  • other files
  • /
  • errorCorrection.m
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:1dc429fc0da4cc5ff4f62617760447613f85980b
directory badge Iframe embedding
swh:1:dir:6c650caa1361c9e7053c995baf6e4c78a2fa2aac
content badge Iframe embedding
swh:1:cnt:2ea213fd71247186dbdc0e1dca0de2fe0ca7a859
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
errorCorrection.m


pathToMatlab = strcat(extractBefore(pwd,'MATLAB'),'MATLAB');
addpath(genpath(pathToMatlab));

pathToAnalysedData = strcat(extractBefore(pwd,'MATLAB'),'Analysis');
d=pathToAnalysedData;
%Creating '\**\shot.mat' for windows and '/**/shot.mat' for matlab
findThis = [filesep '**' filesep 'shot.mat'];
%shotDir = dir(strcat(d,'\**\shot.mat'));
shotDir = dir(strcat(d,findThis));

for i = 1:length(shotDir)
    
    shotName = strcat(shotDir(i).folder,filesep,shotDir(i).name);
    load(shotName);

    if isfield(shot.com.side,'oldError')
        continue
    end
    
    if isfield(shot.com.side,'markers')

        vidFolder = shotDir(i).folder;
        shotPath = strcat(shotDir(i).folder,'\',shotDir(i).name);
        vidDir = strcat(erase(shotPath, '\shot.mat'),'.mat');
        vidDir = strrep(vidDir, 'Analysis', 'Data');
        vidDir = strrep(vidDir,'C:\Users\cc583\Dropbox (Duke Bio_Ea)\Bhandawat Lab\Chun', 'E:\CHUN');
        M = load(vidDir);
        M.data.frames = M.data.frames(:,:,:,shot.frame);
        M.data.timeStamp = M.data.timeStamp(shot.frame);
        
        %vidStartFrame = shot.frame(1);
        sideCoM = [shot.com.bottom.location(:,1), shot.com.worldinfo.floorY - shot.com.side.location(:,2)];
        bottomCoM = shot.com.bottom.location;
        
        errorSide = zeros(size(sideCoM,1),1);
        errorBottom = zeros(size(bottomCoM,1),1);
        for f = 2:size(sideCoM,1)-1 %I am subtracting 1 because shot.com.side/bottom.markers did not contain the data for the markers in the last frame.
            comFuture = sideCoM(f,:);
            markerFuture = shot.com.side.markers{f}';
            comTrackBack=backTraceCoM(M,f,comFuture,markerFuture);
            errorSide(f)=sqrt(sum((sideCoM(f-1,:)-comTrackBack).^2));
            
            if isnan(comTrackBack)
                shotName
                f
            end
            
            comFuture = bottomCoM(f,:);
            markerFuture = shot.com.bottom.markers{f}';
            comTrackBack=backTraceCoM(M,f,comFuture,markerFuture);
            errorBottom(f)=sqrt(sum((bottomCoM(f-1,:)-comTrackBack).^2));
            
            if isnan(comTrackBack)
                shotName
                f
            end
            
        end
        errorSide(1) = errorSide(2);
        errorBottom(1) = errorBottom(2);
        errorSide(end) = errorSide(end-1);
        errorBottom(end) = errorBottom(end-1);
        
        shot.com.side.oldError = shot.com.side.error;
        shot.com.side.oldUncty = shot.com.side.uncty;
        shot.com.side.error = errorSide;
        shot.com.side = rmfield(shot.com.side,'uncty');
        
        shot.com.bottom.oldError = shot.com.bottom.error;
        shot.com.bottom.oldUncty = shot.com.bottom.uncty;
        shot.com.bottom.error = errorBottom;
        shot.com.bottom = rmfield(shot.com.bottom,'uncty');
        
         save(shotName,'shot')
        
    end
    disp([num2str(i/length(shotDir)*100) '%'])
end


function comTrackBack=backTraceCoM(M,fframe,comFuture,markerFuture)

objectFrame = M.data.frames(:,:,:,fframe);%now at frBegin(th) frame

tracker = vision.PointTracker('NumPyramidLevels',3,'MaxBidirectionalError',1);

%COM side view
points = markerFuture;
initialize(tracker,points,objectFrame);

oldPoints = points;

cframe = fframe-1;

frame = M.data.frames(:,:,:,cframe);%-background; %now at frBegin+1

[points, isFound] = step(tracker,frame);

visiblePoints = points(isFound,:);
oldInliers = oldPoints(isFound,:);

if size(visiblePoints, 1) >= 2 % need at least 2 points
    % Estimate the geomatric transformation between the old points
    ...and the new points and eliminate outliers
        [xform, oldInliers, visiblePoints] = estimateGeometricTransform(...
        oldInliers, visiblePoints, 'similarity', 'MaxDistance', 1);
    % Apply the transformation to the COM!
    comTrackBack = transformPointsForward(...
        xform, comFuture);
else
    comTrackBack = NaN;
    disp('Incomplete');
end

clear comTrack errr oriPoints markers
release(tracker);

end
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top