i have trained the cascade object detector to detect fists. But now I want to count the number of fists and display. Is there any way using vision toolbox ? please suggest me the steps

Want function names or an algorithm which will count the number of objects detected (i have trained cascade object detector to detect my fist)

 採用された回答

Anand
Anand 2014 年 10 月 9 日
If you have already trained a cascade object classifier, you should already have an output XML file containing the classification model as created by trainCascadeObjectDetector.
Now specify this XML file as the classification model when using the vision.CascadeObjectDetector.
As an example, if the XML file is fist.xml
% associate fist.xml classification model to Cascade Object Detector
fistDetector = vision.CascadeObjectDetector('fist.xml');
% run the classifier on image im and return bounding boxes of fists.
fistBBox = step(fistDetector, im);
% display fists on image
imFist = insertObjectAnnotation(im,'rectangle',fistBBox,'Fist');
figure, imshow(imFist)

3 件のコメント

Thank you for replying. But the problem is still unsolved. My code detects the fists an the method I used is similar to what you have mentioned. The thing is that, I want a method that will show the COUNT of number of objects (here fists) detected on the output display window.
% my code
clc
vid = videoinput('winvideo', 1, 'YUY2_640x480');
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval=2;
start(vid)
detector = vision.CascadeObjectDetector('fist1.xml');
while(1)
img = getsnapshot(vid);
bbox = step(detector, img);
detectedImg = insertObjectAnnotation(img, 'rectangle', bbox, 'stop sign');
imshow(detectedImg);
end
stop(vid);
flushdata(vid);
clear all
numFists = size(fistBBox,1);
imFistWithNum = insertText( insertObjectAnnotation(im,'rectangle',fistBBox,'Fist'), [5 5], numFists );
figure, imshow(imFistWithNum);
Swapnil
Swapnil 2014 年 10 月 10 日
Its exactly what I needed. Thanks alot :)

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

その他の回答 (0 件)

質問済み:

2014 年 10 月 9 日

コメント済み:

2014 年 10 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by