i am having problem using a HistogramBasedTracker as it is showing "Error using HistogramBasedTracker Expected R to be of size 1x4 when it is actually size 2x4." how to solve it?

i am new in MATLAB and making a face detector using image Image Acquisition Toolbox but a error is showing every time i ran the code....the error is like: " Error using HistogramBasedTracker
Expected R to be of size 1x4 when it is actually size 2x4.
Error in vision.HistogramBasedTracker/initializeObject (line 281)
validateattributes(roi, {'numeric'}, ...
Error in maybefinal (line 20)
initializeObject(tracker, hueChannel, noseBBox);"
but code is given below : " viddevice= imaq.VideoDevice('winvideo', 1, 'MJPG_640x400');
vidplayerobject= vision.VideoPlayer;
vidplayerobject.Name = 'facedetected Video';
faceDetector = vision.CascadeObjectDetector();
noseDetector = vision.CascadeObjectDetector('Nose');
tracker = vision.HistogramBasedTracker;
nFrames = 0;
while (nFrames<1500)
videoFrame=step(viddevice);
bbox = step(faceDetector, videoFrame);
boxInserter = vision.ShapeInserter('BorderColor','Custom',...
'CustomBorderColor',[255 255 0]);
videoOut = step(boxInserter, videoFrame,bbox);
faceImage = imcrop(videoFrame,bbox);
noseBBox = step(noseDetector,faceImage);
noseBBox(1:2) = noseBBox(1:2) + bbox(1:2);
initializeObject(tracker, hueChannel, noseBBox);
[hueChannel,~,~] = rgb2hsv(videoFrame);
bbox = step(tracker, hueChannel);
videoOut = step(boxInserter, videoFrame, bbox);
step(vidplayerobject,videoOut);
nFrames = nFrames + 1;
end
release(viddevice);
release(vidplayerobject);
release(faceDetector);
release(noseDetector);
release(tracker); " i am not understanding the problem........... so i will be greatfull if someone help me with my codes and the way to solve the error..

 採用された回答

For debugging, after the statement
noseBBox = step(noseDetector,faceImage);
please show size(noseBBox) and size(bbox)
Question: what would the face detector and nose detector return if there were two faces in the image?

2 件のコメント

muinbun
muinbun 2013 年 1 月 24 日
thnx for your hints...... now its working
Arif
Arif 2013 年 3 月 5 日
i did not get any clue(my bad). can you explain a little bit

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by