How to removed the ??? Reference to non-existent field error

조회 수: 1 (최근 30일)
Sanjay Saini
Sanjay Saini 2014년 5월 8일
댓글: Sanjay Saini 2014년 5월 9일
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);

채택된 답변

Image Analyst
Image Analyst 2014년 5월 9일
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
Image Analyst
Image Analyst 2014년 5월 9일
Try
thisBG = load(sprintf...............
BG_STATS{V} = thisBG;
fieldnames(thisBG);
bg_means = thisBG.bg_means;
Sanjay Saini
Sanjay Saini 2014년 5월 9일
Thank you sir problem has been solved

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Roberto
Roberto 2014년 5월 8일
this only means that variable 'bg_means' doesn't exist in your file:
sprintf(bgModelPath,PRM.CAMS{V}.name)
  댓글 수: 1
Sanjay Saini
Sanjay Saini 2014년 5월 9일
Respected Roberto, bg_means is available in my path directory which i have given as: bgModelPath = [ABC2_DATASET_BASE_PATH '/' SN ... '/Background/Background_(%s).mat']; Both variable 'bg_means' and 'bg_vars' is available inside Background_(%s).mat file and this file path i have given as: bgModelPath = [ABC2_DATASET_BASE_PATH '/' SN ... '/Background/Background_(%s).mat']; But in path directory have 4 camera Background (Background_(C1).mat, Background_(C2).mat, Background_(C3).mat, Background_(C4).mat) and each one contain 'bg_means' and 'bg_vars' so should i give each camera background path??

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by