segsAll = cell(length(frs),1);
This line of code is unreachable I don't know why. I have supplied the image properly and also tried to display it and it got displayed. But error is still there, something wrong with the if statement.
if true % code
%Define our movie and scale factor
cd demo_people;
addpath(genpath('.'));
frs = 1:201;
movieS = 'ims/%.8d.jpg';
imscale = .6;
%First step; run stylized pose detector on each frame
INIT_DETECT = 0;
if INIT_DETECT
%First, run our stylized person detector
segsAll = cell(length(frs),1);
%for fr = frs,
for fr = 167
fr
%Read in image, scaling it so torso is roughly 50 pixels long
imOrig = imread(sprintf(movieS,fr));
%For this sequence, hard-code in we're looking for some-one
% walking to the right with a torso 50 pixels high
im = imresize(imOrig(:,end:-1:1,:),imscale,'bilinear');
% Because the walking detector involves sampling, may have to
% do this multiple times
% and take best-scoring one
segs = findWalkingPerson(im);
%Flip and re-size to regular image
[segs.x,segs.u] = deal(size(im,2) - segs.x + 1,-segs.u);
[segs.x,segs.y,segs.len,segs.w] = ...
deal(segs.x/imscale,segs.y/imscale,segs.len/imscale,segs.w/imscale);
%Build an appearance model for each limbs and evaluate how
% good we are
modelSegs = buildLimbModelLin({imOrig},{segs});
%Sum up the fraction of missclassified pixels, downweighting
% the upper arm by .5
segs.cost = [1 .5 1 1 1 1 1 1] * modelSegs.err;
segsAll{fr} = segs;
end
%Take the best scoring one
costs = repmat(100,length(frs),1);
for i = 1:length(frs),
if ~isempty(segsAll{i}),
costs(i) = segsAll{i}.cost;
end
end
[dummy,fr] = min(costs);
%Build a quadratic logistic regression model for each limb
im = imread(sprintf(movieS,fr));
modelSegs = buildLimbModelQuad({im},segsAll(fr));
save walkingDetections segsAll modelSegs;
else
load walkingDetections;
end
%Track by detecting with learned appearance model
trackSegs = cell(length(frs),1);
for fr = frs,
fr
clf;
im = imread(sprintf(movieS,fr));
%Can search over image and different scales if desired
im = imresize(im,imscale,'bilinear');
subplot(231);
imshow(im); title(sprintf('Frame %d',fr));
%Sample body poses by computing the posterior with the
% sum-product algorithm
[pts,cost] = findGeneralPerson(im,modelSegs);
subplot(235);
showPersonPts(size(im),pts);
title('Posterior');
%Find the modes in the samples
trackSegs{fr} = findModePose(pts);
subplot(236);
showsegIm(im,trackSegs{fr});
title('Mode in posterior');
drawnow;
end
%Show the track
clf;
set(gcf,'doublebuffer','on');
for fr = frs,
im = imread(sprintf(movieS,fr));
%Can search over image and different scales if desired
im = imresize(im,imscale);
showsegIm(im,trackSegs{fr});
drawnow;
end
end

댓글 수: 1

matt dash
matt dash 2014년 11월 9일
You should edit your question to properly format the code. It is very difficult to read as it is.

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

 채택된 답변

per isakson
per isakson 2014년 11월 9일

0 개 추천

INIT_DETECT is always false, thus the first branch of the if-statement cannot be reached.

댓글 수: 1

samir
samir 2014년 11월 9일
then how should I use that statement so that the first branch is reached?

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

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 11월 9일

0 개 추천

Change the code to:
INIT_DETECT = true;
if INIT_DETECT

댓글 수: 2

samir's "Answer" moved here since it shoudl really be a "Comment" to me rather than an independent "Answer" to his original question:
I tried running the code with INIT_DETECT =true. I am getting he following error:
Warning: Escape sequence 'U' is not valid. See 'help sprintf' for valid escape sequences.
> In baseballDo at 18
Error using imread (line 366)
Can't open file "C:" for reading;
you may not have read permission.
Error in baseballDo (line 18)
imOrig = imread(sprintf(movieS,fr));
Note: I changed the path of input image file to my local machine path.
Try this:
% Create full file name of file in the ims subfolder
% of the current folder.
movieS = sprintf('%s/ims/%.8d.jpg', pwd, fr);
% Make sure it exists. Warn if it does not exist.
if ~exist(movieS, 'file')
warningMessage = sprintf('Image file not found:\n%s', movieS);
uiwait(warndlg(warningMessage));
continue;
end
im = imread(movieS);

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

질문:

2014년 11월 9일

댓글:

2014년 11월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by