人臉識別 iOS開發

2021-07-10 02:34:14 字數 1308 閱讀 4335

首先定義屬性:

@property(strong,nonatomic)

uiimage

*ima;

@property(strong,nonatomic)

uiimageview

*iamgeview;

self

.ima

= [uiimage

imagenamed:

@"123.png"];

self

.iamgeview

= [[

uiimageview

alloc]initwithimage:

self

.ima];

self.iamgeview.frame =cgrectmake(0,0,  self.ima.size.width, self.ima.size.height);

[self.view

addsubview:self.iamgeview];

ciimage *image = [ciimage

imagewithcgimage: self.ima.cgimage];

nsdictionary*opts = [nsdictionary

dictionarywithobject

:cidetectoraccuracyhigh

forkey

: cidetectoraccuracy];

cidetector* detector = [cidetector

detectoroftype

:cidetectortypeface

context

:nil

options

:opts];

//得到面部資料

nsarray* features = [detector featuresinimage:image];

for (cifacefeature *fin features)

if(f.hasrighteyeposition)

if(f.hasmouthposition)

if (f.hassmile)

if (f.hasfaceangle)

}其中眼睛和嘴巴的位置,是在**image上的位置而不是imageview,**的scale也會影響位置的判斷。(本文中scale為1)其中y值以**底部為基準的(平時我們定義的frame是以頂部為基準),所以為獲取正確的y位置,需要用**的高度,減去獲取的y值

iOS 人臉識別

請求url資料格式 向授權服務位址傳送請求 推薦使用post 並在url中帶上以下引數 grant type 必須引數,固定為client credentials client id 必須引數,應用的api key client secret 必須引數,應用的secret key 例如 grant ...

ios識別人臉自動拍照 ios人臉拍照識別

人臉識別,ios人臉拍照識別 人臉識別,ios人臉拍照識別產品背景 隨著深度學習方法的應用,人臉識別技術的識別率已經得到質的提公升,目前人臉識別率已經達到99 以上。人臉識別技術與其他生物特徵識別技術相比,在實際應用中具有天然獨到的優勢 通過攝像頭直接獲取,可以非接觸的方式完成識別過程,方便快捷。目...

iOS人臉識別 CoreImage

1 從初始uiimage獲取乙個ciimage物件。2 建立乙個用於分析物件的cicontext。3 通過type和options引數建立乙個cidetector例項。type引數指定了要識別的特徵型別。options引數可以設定識別特徵的精確度,低精確度速度快,高精確度更準確。4 建立乙個影象陣列...