Use of Gpuimage

Source: Internet
Author: User

Recently in a 3D model face-changing function, users take selfies with their mobile phones, and then change the face of the model to their own.

In this process, the Android can use the United States 美图秀秀 beauty Jenku to whiten, but the iOS side there is no similar east, Baidu, will find on GitHub there is an open source project called Beautifyfacedemo, can achieve real-time beauty camera, Imagine the realization of a picture of beauty certainly no problem. Then began to study, the final use, the effect can also.

Here's a record of the calling process:

  Step 1, download the Gpuimage project from Https://github.com/BradLarson/GPUImage, from https://github.com/Guikunzhi/ Beautifyfacedemo Download Beautifyfacedemo Project

  Step 2, create a new single View application project Testbeautifyface,

Drag the Framework folder in the Gpuimage project folder to the Testbeautifyface project folder,

In the new project, create a new framework folder and drag-and-drop the Gpuimage.xcodeproj file to the Xcode framework folder.

Then add the dependency: in the build Phases-link Binary with libraries midpoint + Add the following framework:

Coremedia,corevideo,opengles,avfoundation,quartzcore, the final libgpuimage.a file also added, or the link will be error ...

Configure the header file search path in the header search paths entry in Build settings, add the framework path containing the gpuimage, and mine is on the same level as the Testbeautifyface project file, so it is: framework/** (* * indicates include directory and all subdirectories)

  Step 3, using gpuimage:

In order to save time, directly on the foreigner's Code ^_^:

1Gpuimagefilter *Selectedfilter;2      3     Switch(buttonindex) {4          Case 0:5Selectedfilter =[[Gpuimagegrayscalefilter alloc] init];6              Break;7          Case 1:8Selectedfilter =[[Gpuimagesepiafilter alloc] init];9              Break;Ten          Case 2: OneSelectedfilter =[[Gpuimagesketchfilter alloc] init]; A              Break; -          Case 3: -Selectedfilter =[[Gpuimagepixellatefilter alloc] init]; the              Break; -          Case 4: -Selectedfilter =[[Gpuimagecolorinvertfilter alloc] init]; -              Break; +          Case 5: -Selectedfilter =[[Gpuimagetoonfilter alloc] init]; +              Break; A          Case 6: atSelectedfilter =[[Gpuimagepinchdistortionfilter alloc] init]; -              Break; -          Case 7: -Selectedfilter =[[Gpuimagefilter alloc] init]; -              Break; -         default: in              Break; -     } to       +UIImage *filteredimage =[Selectedfilter imagebyfilteringimage:originalimage]; -[Self.selectedimageview Setimage:filteredimage];
View Code

  Step 4, use the beauty filter to beautify a picture:

      

1     Gpuimagebeautifyfilter *beautifyfilter = [[Gpuimagebeautifyfilter alloc] init]; 2     UIImage *filteredimage = [Beautifyfilter imagebyfilteringimage:selectedimage]; 3     [Self.selectedimageview Setimage:filteredimage];
View Code

Write it down here and continue to study gpuimage~.

Reference: http://code.tutsplus.com/tutorials/build-a-photo-app-with-gpuimage--mobile-12223

Use of Gpuimage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.