tld 第二个函数tldInitFirstFrame

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function source = tldInitFirstFrame(tld,source,min_win)

% load the first frame into memory

把第一帧读入内存
source.im0 = img_get(source,source.idx(1));

这里用到了新的第一个函数 函数img_get 作用是跳转到下一函数

% set the initial bounding box:
% - from file
if source.camera == 0 && exist([source.input '/init.txt'],'file')
bb = dlmread([source.input '/init.txt']);

dlmread是matlab的函数 作用还是读取数据文件的
source.bb = bb(:);

% check
if isempty(source.bb) || min(bb_size(source.bb)) < min_win
exit('Error: bounding box is incorrectly defined or too small');
end
% - by mouse
else
source.bb = bb_click(tld,source.im0.input);

% check
if isempty(source.bb) || min(bb_size(source.bb)) < min_win
source = [];
end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

img_get函数

function img = img_get(source,I)

if source.camera
img = img_alloc(getsnapshot(source.vid));
else
img = img_alloc(source.files(source.idx(I)).name);
end

这个函数又用到了新的函数 img_alloc函数跳转

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

img_alloc 函数

function img = img_alloc(in,imsize)
% Allocates image structure.

 

分配图像结构

if ischar(in)
in = imread(in);
end

ischar 若为字符向量返回1 读取这个字符的图片咯

if ndims(in) == 3

返回矩阵的维度
%img.input = in(:,:,2);
img.input = rgb2gray(in);

变为灰度图咯
%img.input = imadjust(img.input);
else
img.input = in;
end

% img.input = fliplr(img.input);

if exist('imsize','var')
img.input = imresize(img.input,imsize);
end

没懂

img.blur = img_blur(img.input,2);

用到了新的函数 img_blur

该函数采用高斯内核来模糊灰度图像
%img.blur = img_blur(img.input,5);

posted on 2017-04-13 15:28  风筝缠绕  阅读(116)  评论(0编辑  收藏  举报

导航