How to removed the ??? Reference to non-existent field error
    2 views (last 30 days)
  
       Show older comments
    
    Sanjay Saini
 on 8 May 2014
  
    
    
    
    
    Commented: Sanjay Saini
 on 9 May 2014
            function bgs = ComputeSilhouettes_ABC2(frame,img)
global PRM; persistent BG_STATS LAST_SEQ;
if isempty(LAST_SEQ), LAST_SEQ = -1; end
if PRM.SEQ ~= LAST_SEQ fprintf('Loading background statistics '); tic;
    SN  = get(PRM.datasetObj,'SubjectName'); SN = SN{1};
    global ABC2_DATASET_BASE_PATH;
    bgModelPath = [ABC2_DATASET_BASE_PATH '/' SN ...
        '/Background/Background_(%s).mat'];
    for V = 1 : numel(PRM.CAMS)
        % load bg_means and bg_vars
        BG_STATS{V} = load(sprintf(bgModelPath,...
            PRM.CAMS{V}.name),'bg_means','bg_vars');
        for M = 1 : numel(BG_STATS{V}.bg_means)
            ind = find(BG_STATS{V}.bg_vars{M} == 0.1);
            BG_STATS{V}.bg_vars{M}(ind) = 1.0000e-003;
        end
    end
??? Reference to non-existent field 'bg_means'.
Error in ==> ComputeSilhouettes_ABC2 at 28 for M = 1 : numel(BG_STATS{V}.bg_means)
Error in ==> LoadFrame at 61 bgs = ComputeSilhouettes_ABC2(frame,img);
0 Comments
Accepted Answer
  Image Analyst
      
      
 on 9 May 2014
        Why are you making it a cell array? Will you need all of them after the loop has finished? If not, then get rid of the braces and have it be just a normal structure. Then use fieldnames() to see what fields it has.
3 Comments
  Image Analyst
      
      
 on 9 May 2014
				Try
thisBG = load(sprintf...............
BG_STATS{V} = thisBG;
fieldnames(thisBG);
bg_means = thisBG.bg_means;
More Answers (1)
  Roberto
      
 on 8 May 2014
        this only means that variable 'bg_means' doesn't exist in your file:
sprintf(bgModelPath,PRM.CAMS{V}.name)
See Also
Categories
				Find more on Manage Products in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

