iOS 原生CoreImage人臉識別

2021-07-10 02:26:54 字數 1313 閱讀 7647

首先定義屬性:

@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 *f in features)

if(f.hasrighteyeposition)

if(f.hasmouthposition)

if (f.hassmile)

if (f.hasfaceangle)

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

iOS人臉識別 CoreImage

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

IOS 中的CoreImage框架

coreimage framework 組成 主要分為三部分 1 定義部分 coreimage 何coreimagedefines。見名思義,代表了coreimage 這個框架和它的定義。2 操作部分 濾鏡 cifliter cifilter 產生乙個ciimage。典型的,接受一到多的作為輸入,經...

iOS中的CoreImage框架

core image是ios中的影象處理框架,使用上比較簡單方便,常用於 的濾鏡處理,還有就是面部檢測 沒有識別 等用途。coreimage框架裡主要包括以下幾個我們常用的模組 ciimage 這是代表影象的類。cifilter 代表濾鏡的乙個類,能夠通過key value來設定輸入值,用於為cii...