Skip to content

Commit

Permalink
Merge pull request #9 from maljoras/development
Browse files Browse the repository at this point in the history
bug fixes
  • Loading branch information
maljoras committed Jul 11, 2016
2 parents 935b625 + 24b6d34 commit 0344557
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 37 deletions.
3 changes: 3 additions & 0 deletions +fish/+stimulus/@Presenter/Presenter.m
Expand Up @@ -85,7 +85,10 @@ function initProgressBar(self)
'Name',sprintf('%s progress..',class(self)));

set(self.progressBarH,'CloseRequestFcn',@closereqfun);
else
self.closeProgressBar();
end

end


Expand Down
2 changes: 1 addition & 1 deletion +fish/+stimulus/PresenterTrackTextures.m
Expand Up @@ -168,7 +168,7 @@ function reset(self)
end

if any(self.stmVelThres)
v = self.trackVelocity;
v = sqrt(sum(self.trackVelocity.^2,2));
stmmsk = stmmsk & v>self.stmVelThres(1);
if length(self.stmVelThres)>1
stmmsk = stmmsk & v<self.stmVelThres(2);
Expand Down
54 changes: 33 additions & 21 deletions +fish/@Tracker/Tracker.m
Expand Up @@ -384,13 +384,14 @@
opts = [];
opts.nfish = 4;
opts.fishlength = 100;
opts.fishwidth = 30;
opts.fishwidth = 50;
opts.stmif = 1;
opts.stimulus.presenter = 'fish.stimulus.PresenterCalibration';
opts.stimulus.screen = screenIdx;
opts.classifier.timeToInit = Inf;
opts.detector.inverted = 1;
opts.tracks.useDagResults = 0;
opts.tracks.initBackground = 0;

ft = fish.Tracker({camIdx,''},opts);

Expand All @@ -400,7 +401,7 @@

if plotif>1
ft.setDisplay(1);
ft.setDisplay('tracks',1);
ft.setDisplay('tracks',1,'stimulusProgress',0);
else
ft.setDisplay(0);
end
Expand All @@ -410,6 +411,7 @@
ft.stimulusPresenter.width = 50; % maybe needs to be adjusted
ft.stimulusPresenter.tmax = 30;
ft.stimulusPresenter.freq = 0.2;


fish.helper.verbose(['\n\n****** \tStarting calibration. ' ...
'Make sure that the IR filter is NOT ' ...
Expand All @@ -422,9 +424,8 @@

res = ft.getTrackingResults();

pos = ft.deleteInvisible(res,'pos');
bbox = ft.deleteInvisible(res,'bbox');

pos = permute(ft.interpolateInvisible(res,'centroid'),[1,3,2]);
bbox = ft.interpolateInvisible(res,'bbox');
[screenBoundingBox,xyframe] = getCalibrationBox(pos,bbox,ft.videoHandler.frameSize);

if plotif
Expand Down Expand Up @@ -661,20 +662,22 @@ function initBackgroundAndObjects(self)

else
% init background
n = min(self.videoHandler.history,floor(self.videoHandler.timeRange(2)*self.videoHandler.frameRate));
n = min(n,500);
self.videoHandler.reset(); % resets reader to timerange(1)
self.videoHandler.resetBkg();
self.videoHandler.initialize(0);
self.videoHandler.computeSegments = false;

for i = 1:n
self.videoHandler.step();
fish.helper.verbose('%1.1f%%\r',i/n*100); % some output
if self.opts.tracks.initBackground
n = min(self.videoHandler.history,floor(self.videoHandler.timeRange(2)*self.videoHandler.frameRate));
n = min(n,500);
self.videoHandler.reset(); % resets reader to timerange(1)
self.videoHandler.resetBkg();
self.videoHandler.initialize(0);
self.videoHandler.computeSegments = false;

for i = 1:n
self.videoHandler.step();
fish.helper.verbose('%1.1f%%\r',i/n*100); % some output
end
self.videoHandler.computeSegments = true;
self.videoHandler.reset();
end
self.videoHandler.computeSegments = true;
self.videoHandler.reset();


end
end

Expand Down Expand Up @@ -815,12 +818,21 @@ function initTracking(self)
self.nFramesForSingleUpdate = floor(1.5* self.nFramesForUniqueUpdate);
self.maxFramesPerBatch = self.nFramesForSingleUpdate + 50;


if ~isinf(self.opts.classifier.timeToInit)
self.nFramesForInit = min(max(ceil(self.opts.classifier.timeToInit*self.avgTimeScale),1),200);
else
self.nFramesForInit = Inf; % disables the classifier
end


fish.helper.verbose('nFramesForInit: %d',self.nFramesForInit);
fish.helper.verbose('nFramesAfterCrossing: %d',self.nFramesAfterCrossing);
fish.helper.verbose('nFramesForUniqueUpdate: %d',self.nFramesForUniqueUpdate);
fish.helper.verbose('nFramesForSingleUpdate: %d',self.nFramesForSingleUpdate);

fish.helper.verbose('clpMovAvgTau: %d',self.clpMovAvgTau);
fish.helper.verbose('minBatchN: %d',self.minBatchN );

end


Expand Down Expand Up @@ -2535,7 +2547,7 @@ function checkVideoHandler(self)

def.opts.detector.adjustThresScale = 0.95;
doc.detector.adjustThresScale = {'0.8..1 : reduce when detections too noisy (useKNN=0)',''};


%% reader
def.opts.reader(1).resizeif = false;
Expand Down Expand Up @@ -2632,7 +2644,7 @@ function checkVideoHandler(self)
def.opts.tracks.tauVelocity = 1;
doc.tracks.tauVelocity = {'Time constant to compute the ' 'velocity [avgBLC]'};


def.opts.tracks.initBackground = 1;

%% dag
def.opts.dag.probScale = 0.5;
Expand Down
1 change: 0 additions & 1 deletion +fish/@Tracker/private/generateResults.m
Expand Up @@ -63,7 +63,6 @@ function generateResults(self)
tmp(tidx,:,:,:,:,:) = field;
self.res.(f{1}).tracks.(f2{1}) = tmp;
end
self.res.(f{1}).tracks = rmfield(self.res.(f{1}).tracks,'t');

self.res.(f{1}).t = t;
self.res.(f{1}).tabs = nan(size(t));
Expand Down
5 changes: 4 additions & 1 deletion +fish/@Tracker/private/getCalibrationBox.m
Expand Up @@ -6,7 +6,10 @@
offset = ceil(size(pos,1)/10);
pos = pos(offset+1:end-offset,:,:);
bbox = bbox(offset+1:end-offset,:,:);

dmsk = isnan(pos(:,1));
pos(dmsk,:,:) = [];
bbox(dmsk,:,:) = [];

mpos = squeeze(nanmean(pos,1));

% NOTE: For simplicity we assume that the screen is rectangular and
Expand Down
26 changes: 13 additions & 13 deletions exps/texturesinregions.m
Expand Up @@ -5,8 +5,8 @@
PLOT =0
TEST = 0;

path = '/data/videos/onlinelearning';
VIDID =
path = '/data/videos/onlinelearning/new';
VIDID = 2;

if LOAD && ~exist('ft','var')

Expand All @@ -24,9 +24,9 @@
opts.stimulus.presenter = 'fish.stimulus.PresenterTrackTextureRegions';
opts.detector.adjustThresScale = 1.05;

opts.fishwidth = 25;
opts.fishlength = 90;

opts.fishwidth = 35;
opts.fishlength = 150;
opts.detector.history = 5000;

ft = fish.Tracker({0,videoFile},opts);
end
Expand All @@ -35,9 +35,9 @@
if COMPUTE

if ~exist('sbbox','var')
%sbbox = fish.Tracker.calibrateStimulusScreen();
%sbbox = fish.Tracker.calibrateStimulusScreen(0,1);
%sbbox = [115,90,1550,1214];
sbbox = [114,69,1557,1226];
sbbox = [147,71,1555,1237];
end
opts = [];
opts.avgVelocity = 5;
Expand All @@ -51,14 +51,14 @@
ostm.usePredFishId = false;

ostm.stmCol= parula(ft.nfish);
ostm.stmOnInt= 1; % in sec
ostm.stmOnInt= 2; % in sec
ostm.stmOnIntCV= 0.1;

ostm.stmOffInt= 5; % in sec
ostm.stmOffInt= 4; % in sec
ostm.stmOffIntCV= 0.5;

ostm.stmSize = ft.fishlength;
ostm.regSizeFactorScale = [0,0.5,1.5];
ostm.regSizeFactorScale = [0,1,2];
ostm.stmSizeFactor = 1;
ostm.xRegions = [1/3,2/3];

Expand All @@ -67,7 +67,7 @@

ostm.stmShiftOriSTD = -1; % random;
ostm.stmShiftCV = 2;
ostm.stmSizeFactorCV = 0.5;
ostm.stmSizeFactorCV = 0.25;

ostm.stmVelThres = [2];
ostm.stmBorderThres = 0.05;
Expand All @@ -76,11 +76,11 @@

ostm.colBackground = [0,0,0];
ostm.colBorder = [1,1,1];
ostm.borderWidth = 0.0;
ostm.borderWidth = 0.00;


ostm.adaptationTime = 30;
ostm.tmax = 3600*5;
ostm.tmax = 3600*2;



Expand Down

0 comments on commit 0344557

Please sign in to comment.