当前位置:网站首页>Face recognition using cidetector
Face recognition using cidetector
2022-06-24 02:30:00 【Master coder】
utilize CIDetector To face recognition
Add images :
UIImage* image = [UIImage imageNamed:@"face.jpg"];
UIImageView *testImage = [[UIImageView alloc] initWithImage: image];
[testImage setTransform:CGAffineTransformMakeScale(1, -1)];
[[[UIApplication sharedApplication] delegate].window setTransform:
CGAffineTransformMakeScale(1, -1)];
[testImage setFrame:CGRectMake(, , testImage.image.size.width,
testImage.image.size.height)];
[self.view addSubview:testImage];
Identify pictures :
CIImage* ciimage = [CIImage imageWithCGImage:image.CGImage];
NSDictionary* opts = [NSDictionary dictionaryWithObject:
CIDetectorAccuracyHigh forKey:CIDetectorAccuracy];
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil options:opts];
NSArray* features = [detector featuresInImage:ciimage];
Mark face , Eyes and mouth :
for (CIFaceFeature *faceFeature in features){
}
// Mark face
CGFloat faceWidth = faceFeature.bounds.size.width;
UIView* faceView = [[UIView alloc] initWithFrame:faceFeature.bounds];
faceView.layer.borderWidth = 1;
faceView.layer.borderColor = [[UIColor redColor] CGColor];
[self.view addSubview:faceView];
// Mark the left eye
if(faceFeature.hasLeftEyePosition) {
UIView* leftEyeView = [[UIView alloc] initWithFrame:
CGRectMake(faceFeature.leftEyePosition.x-faceWidth*0.15, faceFeature.leftEyePosition.y-faceWidth*0.15, faceWidth*0.3, faceWidth*0.3)];
[leftEyeView setBackgroundColor:[[UIColor blueColor] colorWithAlphaComponent:0.3]];
[leftEyeView setCenter:faceFeature.leftEyePosition];
leftEyeView.layer.cornerRadius = faceWidth*0.15;
[self.view addSubview:leftEyeView];
}
// Mark the right eye
if(faceFeature.hasRightEyePosition) {
UIView* leftEye = [[UIView alloc] initWithFrame:
CGRectMake(faceFeature.rightEyePosition.x-faceWidth*0.15,
faceFeature.rightEyePosition.y-faceWidth*0.15, faceWidth*0.3, faceWidth*0.3)];
[leftEye setBackgroundColor:[[UIColor blueColor] colorWithAlphaComponent:0.3]];
[leftEye setCenter:faceFeature.rightEyePosition];
leftEye.layer.cornerRadius = faceWidth*0.15;
[self.view addSubview:leftEye];
}
// Mark the mouth
if(faceFeature.hasMouthPosition) {
UIView* mouth = [[UIView alloc] initWithFrame:
CGRectMake(faceFeature.mouthPosition.x-faceWidth*0.2, faceFeature.mouthPosition.y-faceWidth*0.2, faceWidth*0.4, faceWidth*0.4)];
[mouth setBackgroundColor:[[UIColor greenColor] colorWithAlphaComponent:0.3]];
[mouth setCenter:faceFeature.mouthPosition];
mouth.layer.cornerRadius = faceWidth*0.2;
[self.view addSubview:mouth];
}
边栏推荐
- Facebook was officially renamed meta, and the digital twin meta universe was applied!
- How to build a video website? How much does it cost to build a video website?
- Echo framework: add API logging Middleware
- Learning and life -- Talking about my learning methods
- Contour-v1.19.1 release
- Initial experience of creating partitioned tables under MySQL cases tdsql for MySQL (I)
- Use cloudflare to defend against DDoS for free
- Tencent cloud won the first place in the cloud natural language understanding classification task
- If you accidentally make the disk dynamic, how to convert it back (do not guarantee it, but take a snapshot before operation)
- Flowable get the input stream of the current task process picture
猜你喜欢

Leetcode969: pancake sorting (medium, dynamic programming)

If there are enumerations in the entity object, the conversion of enumerations can be carried out with @jsonvalue and @enumvalue annotations

Advanced BOM tool intelligent packaging function

2020 language and intelligent technology competition was launched, and Baidu provided the largest Chinese data set

163 mailbox login portal display, enterprise mailbox computer version login portal

How to fill in and register e-mail, and open mass mailing software for free

application. Yaml configuring multiple running environments
Cloudpods golang practice

Introduction to development model + test model

BIM model example
随机推荐
[expense center] demand & problem feedback week is coming! Feedback wins a good gift!
How to batch output ean 13 code to pictures
[Tencent cloud double 12.12] from 56 yuan! New users of Tencent cloud buy for the first time, which is more cost-effective!
2021 game security industry summit: Security Co Construction and healthy development of escort industry
DB2 database generates HTML patrol Report
What is the domain name trademark? What are the registration conditions for domain names and trademarks?
No serializer found for class ** and no propert no properties discovered to create BeanSerializer
Opengl: how to use shader to convert RGBA to nv21 image format? (open source for the first time in the whole network)
Leetcode problem solving notes for slow ploughing of stupid cattle (dynamic update...)
Operation and maintenance platform tcapulusdb transaction management
The cloud University of "digital and real integration, CO building authentic Internet" is surging forward
S2b2c platform of fresh food industry reshapes the ecosystem of agricultural products and builds a mobile fresh food comprehensive mall
163 mailbox login portal display, enterprise mailbox computer version login portal
Grpc: adjust data transfer size limit
How to build a cloud game server what needs to be considered to build a cloud game server
Uipickerview show and hide animation
How do I fix the iPhone green screen problem? Try these solutions
What are the conditions for trademark registration? How long does it take to register a trademark?
Fulleventlogview does not display some event ID contents
Benchmarking Shopify? Similarities and differences between "two giants" of Chinese e-commerce SAAS and Weimeng