First, download gpuimage
(1): Https://github.com/BradLarson/GPUImage
(2) After downloading, open the Gpuimage.xcodeproj project, select the real machine to run the project (generate LIB file for the real machine)
(3) Click Libgpuimage.a under Products to select the show in Finder.
(4) Add all the header files contained in the GPUImage.h file to the include. In a similar way, folder names can be customized.
(5) Add all the header files contained in the GPUImage.h file to the include. In a similar way, folder names can be customized.
Ii. Creation of the project
(1) Import "include" and "Libgpuimage.a" into the project, the structure is as follows:
(2) Create a ". pch", named Custom, here as follows:
(3) Select the ". pch" file and you can see the contents as follows:
(4) Find Project > Build Settings > Search "Prefix Header";
(5) "Apple LLVM 7.0-language″ column you will see the Prefix Header keyword;
(6) Enter "/users/mac/desktop/gpuiimagetest/gpuiimagetest/gpuiimagetest-prefix.pch" (Select the ". pch" file you created, show in The Finder copies the file address, or simply drags the file into the code area to get the address.
(7) Precompile Prefix header is yes, pre-compiled PCH file will be cached, can improve the speed of compilation.
(8) Make the following changes in "GPUIIMAGETEST-PREFIX.PCH":
(9) Clean and build your project
Third, write the test code
@interface Viewcontroller ()
{
UIImage * inputimage;
}
@property (Weak, nonatomic) Iboutlet Uiimageview *changeimageview;
@end
@implementation Viewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Inputimage = [UIImage imagenamed:@ "Face.png"];
Using the black and white sketch filter
Gpuimagesketchfilter *disfilter = [[Gpuimagesketchfilter alloc] init];
Set line weight default value is 1.0
Disfilter.edgestrength = 1;
Set the area to render
[Disfilter forceProcessingAtSize:inputImage.size];
[Disfilter Usenextframeforimagecapture];
Get Data source
Gpuimagepicture *stillimagesource = [[Gpuimagepicture alloc]initwithimage:inputimage];
Add on Filter
[Stillimagesource Addtarget:disfilter];
Start rendering
[Stillimagesource Processimage];
Get a picture after rendering
UIImage *newimage = [Disfilter imagefromcurrentframebuffer];
Load it out
Self.changeImageView.image = NewImage;
}
Original:
After processing the diagram:
Iv. key words in Gpuimage
? Output as Source
? Intput as input source
? Filter as Filter
Use of open source framework gpuimage in iOS build libgpuimage.a file and create project (i)