I have directory, there are many images in this directory, I want to detect the face from images, and create the directories of image name store only the faces on that directory. How to do this, kindly help me

조회 수: 3 (최근 30일)
myDir = 'C:\myImages\';
this is the name of directory which contains many images. i want to detect the faces from images and want to crop the face from image and save it like: For example. There is one image name 1.jpg, create the directory name 1 and inside directory there should faces stored which were present in the image 1.jpg.
  댓글 수: 6
Image Analyst
Image Analyst 2017년 11월 30일
Remants of original discussion(before they also get deleted):
myDir = 'C:\myImages\';
this is the name of directory which contains many images. i want to detect the faces from images and want to crop the face from image and save it like: For example. There is one image name 1.jpg, create the directory name 1 and inside directory there should faces stored which were present in the image 1.jpg.

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

답변 (1개)

Image Analyst
Image Analyst 2017년 11월 18일
"i have done till face detection and cropping, but i am facing difficulty to save the cropped face "
OK, good that you've already done that, because that's the hardest part.
To save the cropped image, simply call imwrite:
baseFileName = sprintf('Face#%d.png', currentFaceIndex);
fullFileName = fullfile(outputFolder, baseFileName);
imwrite(croppedImage, fullFileName);
  댓글 수: 2
saeeda saher
saeeda saher 2017년 11월 20일
Here is my Code .. it is for a single image but i want to apply this process on multiple images which are in directory.
and want to create a separate folder with same name as image, and save the cropped face in that directory, ex, pic name is 1.jpg, folder should be created of same name and cropped face should be saved in this folder, this process should be for all images which are in directory... kindly help me for this..
I=imread('E:\a.jpg');
figure(1),imshow(I);
FaceDetect = vision.CascadeObjectDetector;
BB = step(FaceDetect,I);
figure(2),imshow(I);
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',3,'LineStyle','- ','EdgeColor','r');
end
for i = 1:size(BB,1)
J= imcrop(I,BB(i,:));
% figure(3),subplot(5,5,i);imshow(J);
fname = sprintf('b_cropped_%d.jpg', i);
fpath = fullfile('E:\face', fname);
imwrite(J, fpath)
% imwrite(J,'E:\g_cropped.jpg')
end

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

카테고리

Help CenterFile Exchange에서 Computer Vision Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by