123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- function model = learn_dataset( pos, neg, bg, settings )
-
- if ( isempty(neg) )
- allImages = {pos.im};
- else
- allImages = [ {pos.im}; {neg.im} ];
- end
-
-
-
-
-
- if ( ~isfield( pos, 'x1') || ...
- ~isfield( pos, 'x1') || ...
- ~isfield( pos, 'x1') || ...
- ~isfield( pos, 'x1') ...
- )
- s_imgfns = {pos.im};
- for i_idx = 1:length(s_imgfns)
- s_fn = s_imgfns{i_idx};
- img = imread ( s_fn );
- pos(i_idx).x1 = 1;
- pos(i_idx).y1 = 1;
- pos(i_idx).x2 = size(img,2);
- pos(i_idx).y2 = size(img,1);
- end
- end
-
-
- if ( isempty(bg) )
- bg = trainBGwithArbitraryFeatures( allImages, settings );
- end
-
-
-
-
- i_numImgChannels = size ( readImage( allImages{1}),3);
- i_numDim = size( settings.fh_featureExtractor.mfunction ( zeros([3 3 i_numImgChannels]) ),3 );
-
- clear ( 'allImages' );
-
-
- settings.lda.bg = bg;
-
- settings.lda.d_detectionThreshold = 0;
-
-
- i_numCells = computeOptimalCellNumber ( pos, settings.i_binSize );
- settings.lda.bg.i_numCells = i_numCells;
-
-
-
-
-
-
- settings.lda.lambda = bg.lambda;
-
- settings.lda.b_noiseDropOut = false;
- settings.lda.d_dropOutProb = 0.0;
-
- settings.lda.bg.interval = settings.interval;
-
- model = initmodel_static(settings, i_numDim);
-
-
- if( max(model.i_numCells)<4*min(model.i_numCells) )
-
-
- warpedTrainBlocks = warpBlocksToStandardSize( model, pos, settings.fh_featureExtractor );
-
-
- feats = computeFeaturesForBlocks( warpedTrainBlocks, settings);
-
- [ldaStuff.R,ldaStuff.neg] = whitenWithDropout(model.bg, model.lda, model.i_numCells(2),model.i_numCells(1));
-
-
-
- i_truncDim = 32;
-
- model = learnWithGivenWhitening(model, ...
- ldaStuff.R, ldaStuff.neg, ...
- feats, i_truncDim );
- else
- model.maxsize
- error('HOG window is too skewed!');
- end
-
- model.w=model.w./(norm(model.w(:))+eps);
- model.thresh = 0.5;
- model.bg=[];
- end
|