face and eye detection crop

4 visualizaciones (últimos 30 días)
Nur Izzati Nadiah
Nur Izzati Nadiah el 27 de Jun. de 2012
Respondida: Tohru Kikawada el 13 de En. de 2017
I detect the face using function available in computer vision system toolbox bbox = step(faceDetector, I);
I insert the box for detected face imageOut = step(boxInserter, I, uint8(bbox));
As a result, Some image has two or three boxes at the target subject. For example, I use this to detect the face, and some of the image have two box that detect the face in one image.
Crop Icrop = imcrop(I,bbox);
The problem is when I want to crop the detected face, it is error due to multiple bbox appear in the image.
How to solve this problem?
Thanks
  1 comentario
Shadman Sakib Khan
Shadman Sakib Khan el 11 de Dic. de 2016
As far I know imcrop function can only crop using the parameter (x,y ,width, height). But in your bbox there are four corner position of the polygon. That's why the error occurs. But if you already solve the problem, can you please give me the solution of cropping an image using four corner point.

Iniciar sesión para comentar.

Respuestas (1)

Tohru Kikawada
Tohru Kikawada el 13 de En. de 2017
You can use cellfun for processing multiple ROIs as follows:
%%Create a detector object.
faceDetector = vision.CascadeObjectDetector;
%%Read input image.
I = imread('visionteam.jpg');
%%Detect faces.
bboxes = step(faceDetector, I);
%%Convert bboxes to cell arrays
bboxesCell = mat2cell(bboxes,ones(size(bboxes,1),1),size(bboxes,2));
%%Crop detected faces.
facesCropped = cellfun(@(x)imcrop(I,x),bboxesCell,'UniformOutput',false)
%%Display a cropped image
imshow(facesCropped{1});

Community Treasure Hunt

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

Start Hunting!

Translated by