i wrote this code to detect the face in each no.of frames in given video file but it throws this error Error using ShapeInserter/step The Pts input data type must be integer. how to solve this error pls suggest me the answer for this problem
Show older comments
faceDetector = vision.CascadeObjectDetector(); filename = 'D:\matlab\srini project\3.avi'; mov = VideoReader(filename);
% Output folder
outputFolder = fullfile(cd, 'srini'); if ~exist(outputFolder, 'dir') mkdir(outputFolder); end
%getting no of frames
numberOfFrames = mov.NumberOfFrames; numberOfFramesWritten = 0; for frame = 1 : numberOfFrames-1
thisFrame = read(mov, frame); outputBaseFileName = sprintf('%3.3d.jpg', frame); outputFullFileName = fullfile(outputFolder, outputBaseFileName); imwrite(thisFrame, outputFullFileName, 'jpg'); progressIndication = sprintf('Wrote frame %4d of %d.', frame,numberOfFrames);
bbox = step(faceDetector, thisFrame);
% Convert the first box to a polygon. % This is needed to be able to visualize the rotation of the object. x = bbox(1, 1); y = bbox(1, 2); w = bbox(1, 3); h = bbox(1, 4); bboxPolygon = [x, y, x+w, y, x+w, y+h, x, y+h];
% Draw the returned bounding box around the detected face. shapeInserter = vision.ShapeInserter('Shape', 'Polygons','BorderColor','Custom','CustomBorderColor',[255 255 0]); thisFrame = step(shapeInserter, thisFrame, bboxPolygon);
figure; imshow(thisFrame); title('Detected face'); disp(progressIndication); %disp(detected);
numberOfFramesWritten = numberOfFramesWritten + 1; end progressIndication = sprintf('Wrote %d frames to folder "%s"',numberOfFramesWritten, outputFolder); disp(progressIndication);
i wrote this code to detect the face in each no.of frames in given video file but it throws this error
Error using ShapeInserter/step The Pts input data type must be integer.
how to solve this error pls suggest me the answer to detect the face in each frames in a given video..
1 Comment
Dhananjay
on 20 Jul 2013
for every instance of bbox, except the first one where it was defined, write int32(bbox) and check. It should work.
Answers (0)
Categories
Find more on Track Objects and Estimate Motion 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!