⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aux_error_check.m

📁 Standard model object recognition matlab code
💻 M
字号:
function stat = aux_error_check (level)% FUNCTION stat = aux_error_check (level)%% Do some rudimentary error checking before initializing the% filters or performing the main computations.global learn_file;global all_oper;% The output is not used for now.stat = 0;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Check #1:% Check if level is defined correctly: see init_filt_oper.mallowed_lvl = {[1], [1 1], [1 1 1], [1 1 1 1], ...      [1 1 0 0 1], [1 1 0 0 1 1], [1 1 0 0 1 1 1], ...      [1 1 0 0 1 1 1 1], [1 1 1 1 1 1], [1 1 1 1 1 1 1], ...      [1 1 1 1 1 1 1 1], ...      [0 0 1], [0 0 0 0 1], ...      [0 0 1 1], [0 0 0 0 1 1], [0 0 0 0 1 1 1 1], ...      [0 0 0 0 0 0 1 1], ...      [0 0 1 1 1 1], [0 0 1 1 1 1 1 1] ...      };is_lvl = 0;for i = 1:length(allowed_lvl)  is_lvl = is_lvl+ strcmp(num2str(level), num2str(allowed_lvl{i}));endif is_lvl==0  error('Level is not well defined.');end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Check #2:% Check if the learn_file is defined.for i = 1:length(level)  if level(i)>0    if sum([3 5 7]==i) > 0 % if S2b, S2, or S3.      if length(learn_file)==0 | length(learn_file{i})==0	err_str = 'learn_file is not defined.';	error(err_str);      end    end        endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Check #3:% Check if init_filter_def.m is reasonable.% (1) number of features in C1.[a,b,c,d] = init_filter_def(2);is_cond = sum(b(4,:)==4) > 0;if ~is_cond  error('Number of orientations in C1 error.');end% (2) number of features in S2, S3, S2bfor i = 1:length(level)  if level(i) > 0 & sum([3 5 7]==i)>0    [a,b,c,d] = init_filter_def(i);    % Load the learn_file and check the # features.    load(learn_file{i});    scales = aux_get_filt_info(fieldnames(f));    for j = scales      siz_info = getfield(f,['size_s' num2str(j)]);      feat_in_learn_file(scales) = siz_info(4);    end    if max(b(4,:)) > max(feat_in_learn_file)      disp('There are not enough features in learn_file.');      disp([learn_file{i}]);      disp('Some ways of correcting the error: ');      disp('   (1) Learn more features.');      disp('   (2) Adjust init_filter_def.m (default_num)');      disp('   (3) Augment learn_file with dummy features.');      error(['Not enough features in ' learn_file{i}]);    end  endend% (3) number of features within layersfor i = 1:length(level)  if level(i) > 0 & sum([4 6 8]==i)>0    [a,b,c,d] = init_filter_def(i);    if sum(b(3,:)~=b(4,:))>0 % b(3,:) should equal b(4,:).      error(['Number of features not match within Layer ' num2str(i)]);    end  endend% (4) number of featuers between layers.for i = 2:length(level)  if level(i) > 0    clear b_*;    if i == 5 % S2      [a,b_pre,c,d] = init_filter_def(2);    else      [a,b_pre,c,d] = init_filter_def(i-1);    end        if length(intersect([3 5 7],i)) > 0      % scale mixing, according to C unit.      [a,b,c,d] = init_filter_def(i-1);      for m_idx = 1:max(d)	which_scale = find(d==m_idx);	b_pre_new(4,m_idx) = max(b_pre(4,which_scale));      end    else      b_pre_new = b_pre;    end        [a,b_nex,c,d] = init_filter_def(i);          is_cond = (b_pre_new(4,:)~=b_nex(3,:));    if sum(is_cond)>0      error(['Number of features not match: Layer ' num2str(i)]);    end  endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -