Artificial Intelligence - هوش مصنوعی

Artificial Intelligence - هوش مصنوعی (http://artificial.ir/intelligence/)
-   شناسایی صورت (Face Recognition) (http://artificial.ir/intelligence/forum29.html)
-   -   متلب (http://artificial.ir/intelligence/thread13493.html)

monir93 ۱۲-۴-۱۳۹۳ ۱۲:۲۶ بعد از ظهر

متلب
 
میخوام بعد از تشخیص چهره ویولا جونز ،ناحیه تشخیص داده شده رو از کل تصویر جدا کنم دوستان اگه کد متلب رو دارند تقاضا میکنم کمکم کنند.

mahdiii ۱۲-۵-۱۳۹۳ ۰۱:۳۲ قبل از ظهر

خب شما مختصات و طول و عرض مستطیل رو دارین. به راحتی میتونین بگین که از کدوم سطر تا کدوم سطر و از کدوم تا کدوم ستون تصویر انتخاب و جدابشه
image(a:a+b,c:c+d
)
a,c اولین شماره سطر و ستون مورد نظره و b ,d طول و عرض اون بخش موردنظر

M2soft ۰۱-۱۲-۱۳۹۴ ۰۸:۰۴ بعد از ظهر

PHP Code:

function  [imgFace, LeftEye, RightEye, Mouth, LeftEyebrow,  RightEyebrow] = detectFacialRegions(I)
%  
This function is to find the facial regions (eyes, mouth and eyebrows)
%  
Reference:
%  
Silva, Caroline; Schnitman, Leizer ;  Oliveira, Luciano. "Detection of Facial Landmarks
%  Using Local-Based Information"
. The 19th edition of the Brazilian Conference on Automation - CBA 2012, 
%  
Campina Grande, PB, Brazil (oral presentation), September 3, 2012. 
%
%  
Copyright 2014 by Caroline Pacheco do E.Silva
%  If you have any problem, please feel free to contact Caroline Pacheco do E.Silva.
%  
lolyne.pacheco@gmail.com
%%

%
To detect Face
 FDetect 
= vision.CascadeObjectDetector;
 
Face = step(FDetect,I);
 
imgFace = (I(Face(1,2):Face(1,2)+Face(1,4),Face(1,1):Face(1,1)+Face(1,3),:));

 %
To detect Left Eye
 EyeDetect 
= vision.CascadeObjectDetector('LeftEye');
 
Eye=step(EyeDetect,imgFace);
 
LeftEye  = Eye(1,:);
 
 %
To detect Right Eye
 EyeDetect 
= vision.CascadeObjectDetector('RightEye');
 
Eye=step(EyeDetect,imgFace);
 
RightEye = Eye(2,:);
 
%
To detect Mouth
 MouthDetect 
= vision.CascadeObjectDetector('Mouth','MergeThreshold',16);
 
findMouth=step(MouthDetect,imgFace);
 
orderMouth= sortrows(findMouth,2);
 
posMouth = size(findMouth,1);
 
Mouth = orderMouth(posMouth,:);

%
To detect Left Eyebrow
 LeftEyebrow   
= LeftEye;
 
LeftEyebrow(4) = (LeftEyebrow(4)/2)-4;
 
LeftEyebrow(3) = LeftEyebrow(3);
 
LeftEyebrow(4) = uint8(LeftEyebrow(4));
 
LeftEyebrow(3) = uint8(LeftEyebrow(3));

%
To detect Right Eyebrow
 RightEyebrow  
= RightEye;
 
RightEyebrow(4) =  (RightEyebrow(4)/2);
 
RightEyebrow(3) = RightEyebrow(3);
 
RightEyebrow(4) = uint8(RightEyebrow(4));
 
RightEyebrow(3) = uint8(RightEyebrow(3));

end 

کد بالا یک تابع است که یک عکس به عنوان ورودی میپذیره و با استفاده از object ویلاجوینز ( viola jones ) میادویژگی های اونو استخراج میکنه
مثل صورت
چشم ها
ابروها
دهان

این تیکه کد زیر هم میاد بعد از تشخیص صورت اون و از تصویر جدا میکنه و خودش میشه یه عکس کوچولو از ناحیه صورت

PHP Code:

FDetect = vision.CascadeObjectDetector;
 
Face = step(FDetect,I);
 
imgFace = (I(Face(1,2):Face(1,2)+Face(1,4),Face(1,1):Face(1,1)+Face(1,3),:)); 

البته این فقط برای عکسهایی است که یک چهره در اون هست
یعنی ایندکس 1 در face(1,?) به همین جهت استفاده شده
چون وقتی کد step(FDetect,I) و اجرا میکنیم به ما یک ارایه 1 تا n سطری برمیگردونه که هر سطرش 4 تا مقدار داره که همون 4 نقطه چهره است و تعداد سطرها هم تعداد چهره های شناسایی شده
که البته یعضی وقت ها یک سری چهره ها الکی تشخیص داده میشه
یعنی همیشه ما چهره های شناسایی شده و نمیتونیم ازش مطمئن حرف بزنیم
تو تصویر هم همیشه شاید چشم راست یا همیشه چشم چپ نداشته باشیم

این کد هم از اون تابع استفاده کردم
PHP Code:

clear all;
close all;
clc

I 
= imread('1.jpg');
[
imgFace, LeftEye, RightEye, Mouth, LeftEyebrow,  RightEyebrow] = detectFacialRegions(I);

figure,imshow(imgFace);

hold on
    rectangle
('Position',LeftEye(1,:),'LineWidth',1,'LineStyle','-','EdgeColor','b');
    
rectangle('Position',RightEye(1,:),'LineWidth',1,'LineStyle','-','EdgeColor','g');
    %
rectangle('Position',Mouth(1,:),'LineWidth',1,'LineStyle','-','EdgeColor','b');
    %
rectangle('Position',LeftEyebrow(1,:),'LineWidth',1,'LineStyle','-','EdgeColor','y');
    %
rectangle('Position',RightEyebrow(1,:),'LineWidth',1,'LineStyle','-','EdgeColor','r');
    
hold off 



زمان محلي شما با تنظيم GMT +3.5 هم اکنون ۱۲:۱۶ بعد از ظهر ميباشد.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.