# GPUImage #
<div style="float: right"><img src="http://sunsetlakesoftware.com/sites/default/files/GPUImageLogo.png" /></div>
<a href="https://zenodo.org/record/10416#.U5YGaF773Md"><img src="https://zenodo.org/badge/doi/10.5281/zenodo.10416.png" /></a>
Brad Larson
http://www.sunsetlakesoftware.com
[@bradlarson](http://twitter.com/bradlarson)
contact@sunsetlakesoftware.com
## Overview ##
The GPUImage framework is a BSD-licensed iOS library that lets you apply GPU-accelerated filters and other effects to images, live camera video, and movies. In comparison to Core Image (part of iOS 5.0), GPUImage allows you to write your own custom filters, supports deployment to iOS 4.0, and has a simpler interface. However, it currently lacks some of the more advanced features of Core Image, such as facial detection.
For massively parallel operations like processing images or live video frames, GPUs have some significant performance advantages over CPUs. On an iPhone 4, a simple image filter can be over 100 times faster to perform on the GPU than an equivalent CPU-based filter.
However, running custom filters on the GPU requires a lot of code to set up and maintain an OpenGL ES 2.0 rendering target for these filters. I created a sample project to do this:
http://www.sunsetlakesoftware.com/2010/10/22/gpu-accelerated-video-processing-mac-and-ios
and found that there was a lot of boilerplate code I had to write in its creation. Therefore, I put together this framework that encapsulates a lot of the common tasks you'll encounter when processing images and video and made it so that you don't need to care about the OpenGL ES 2.0 underpinnings.
This framework compares favorably to Core Image when handling video, taking only 2.5 ms on an iPhone 4 to upload a frame from the camera, apply a gamma filter, and display, versus 106 ms for the same operation using Core Image. CPU-based processing takes 460 ms, making GPUImage 40X faster than Core Image for this operation on this hardware, and 184X faster than CPU-bound processing. On an iPhone 4S, GPUImage is only 4X faster than Core Image for this case, and 102X faster than CPU-bound processing. However, for more complex operations like Gaussian blurs at larger radii, Core Image currently outpaces GPUImage.
## License ##
BSD-style, with the full license available with the framework in License.txt.
## Technical requirements ##
- OpenGL ES 2.0: Applications using this will not run on the original iPhone, iPhone 3G, and 1st and 2nd generation iPod touches
- iOS 4.1 as a deployment target (4.0 didn't have some extensions needed for movie reading). iOS 4.3 is needed as a deployment target if you wish to show live video previews when taking a still photo.
- iOS 5.0 SDK to build
- Devices must have a camera to use camera-related functionality (obviously)
- The framework uses automatic reference counting (ARC), but should support projects using both ARC and manual reference counting if added as a subproject as explained below. For manual reference counting applications targeting iOS 4.x, you'll need add -fobjc-arc to the Other Linker Flags for your application project.
## General architecture ##
GPUImage uses OpenGL ES 2.0 shaders to perform image and video manipulation much faster than could be done in CPU-bound routines. However, it hides the complexity of interacting with the OpenGL ES API in a simplified Objective-C interface. This interface lets you define input sources for images and video, attach filters in a chain, and send the resulting processed image or video to the screen, to a UIImage, or to a movie on disk.
Images or frames of video are uploaded from source objects, which are subclasses of GPUImageOutput. These include GPUImageVideoCamera (for live video from an iOS camera), GPUImageStillCamera (for taking photos with the camera), GPUImagePicture (for still images), and GPUImageMovie (for movies). Source objects upload still image frames to OpenGL ES as textures, then hand those textures off to the next objects in the processing chain.
Filters and other subsequent elements in the chain conform to the GPUImageInput protocol, which lets them take in the supplied or processed texture from the previous link in the chain and do something with it. Objects one step further down the chain are considered targets, and processing can be branched by adding multiple targets to a single output or filter.
For example, an application that takes in live video from the camera, converts that video to a sepia tone, then displays the video onscreen would set up a chain looking something like the following:
GPUImageVideoCamera -> GPUImageSepiaFilter -> GPUImageView
## Adding the static library to your iOS project ##
Note: if you want to use this in a Swift project, you need to use the steps in the "Adding this as a framework" section instead of the following. Swift needs modules for third-party code.
Once you have the latest source code for the framework, it's fairly straightforward to add it to your application. Start by dragging the GPUImage.xcodeproj file into your application's Xcode project to embed the framework in your project. Next, go to your application's target and add GPUImage as a Target Dependency. Finally, you'll want to drag the libGPUImage.a library from the GPUImage framework's Products folder to the Link Binary With Libraries build phase in your application's target.
GPUImage needs a few other frameworks to be linked into your application, so you'll need to add the following as linked libraries in your application target:
- CoreMedia
- CoreVideo
- OpenGLES
- AVFoundation
- QuartzCore
You'll also need to find the framework headers, so within your project's build settings set the Header Search Paths to the relative path from your application to the framework/ subdirectory within the GPUImage source directory. Make this header search path recursive.
To use the GPUImage classes within your application, simply include the core framework header using the following:
#import "GPUImage.h"
As a note: if you run into the error "Unknown class GPUImageView in Interface Builder" or the like when trying to build an interface with Interface Builder, you may need to add -ObjC to your Other Linker Flags in your project's build settings.
Also, if you need to deploy this to iOS 4.x, it appears that the current version of Xcode (4.3) requires that you weak-link the Core Video framework in your final application or you see crashes with the message "Symbol not found: _CVOpenGLESTextureCacheCreate" when you create an archive for upload to the App Store or for ad hoc distribution. To do this, go to your project's Build Phases tab, expand the Link Binary With Libraries group, and find CoreVideo.framework in the list. Change the setting for it in the far right of the list from Required to Optional.
Additionally, this is an ARC-enabled framework, so if you want to use this within a manual reference counted application targeting iOS 4.x, you'll need to add -fobjc-arc to your Other Linker Flags as well.
### Building a static library at the command line ###
If you don't want to include the project as a dependency in your application's Xcode project, you can build a universal static library for the iOS Simulator or device. To do this, run `build.sh` at the command line. The resulting library and header files will be located at `build/Release-iphone`. You may also change the version of the iOS SDK by changing the `IOSSDK_VER` variable in `build.sh` (all available versions can be found using `xcodebuild -showsdks`).
## Adding this as a framework (module) to your Mac or iOS project ##
Xcode 6 and iOS 8 support the use of full frameworks, as does the Mac, which simplifies the process of adding this to your application. To add this to your application, I recommend dragging the .xcodeproj project file into your application's project (as you would in the static library target).
For your application, go to its target b
没有合适的资源?快使用搜索试试~ 我知道了~
GPUImage美颜项目
共358个文件
h:169个
m:168个
png:5个
需积分: 34 116 下载量 148 浏览量
2016-09-28
21:28:31
上传
评论
收藏 905KB ZIP 举报
温馨提示
博客专用,下前请看博客
资源推荐
资源详情
资源评论
收起资源包目录
GPUImage美颜项目 (358个子文件)
.DS_Store 6KB
GPUImageFramework.h 8KB
GPUImage.h 6KB
GPUImageFilter.h 5KB
GPUImageVideoCamera.h 5KB
GPUImageOutput.h 5KB
GPUImageHoughTransformLineDetector.h 3KB
GPUImageCannyEdgeDetectionFilter.h 3KB
GPUImageMovieWriter.h 3KB
GPUImageContext.h 2KB
GPUImageHarrisCornerDetectionFilter.h 2KB
GPUImageMovie.h 2KB
GPUImageStillCamera.h 2KB
GPUImageGaussianBlurFilter.h 2KB
GPUImageLevelsFilter.h 2KB
GPUImageView.h 2KB
GPUImageRawDataInput.h 1KB
GLProgram.h 1KB
GPUImageLookupFilter.h 1KB
GPUImageFramebuffer.h 1KB
GPUImageFASTCornerDetectionFilter.h 1KB
GPUImageFilterPipeline.h 1KB
GPUImageToneCurveFilter.h 1KB
GPUImageGaussianSelectiveBlurFilter.h 1KB
GPUImageSmoothToonFilter.h 1KB
GPUImagePicture.h 1KB
GPUImageRawDataOutput.h 1KB
GPUImageChromaKeyBlendFilter.h 1KB
GPUImageiOSBlurFilter.h 1KB
GPUImageChromaKeyFilter.h 987B
GPUImageTwoPassFilter.h 974B
GPUImageMosaicFilter.h 973B
GPUImageTiltShiftFilter.h 927B
GPUImageHSBFilter.h 886B
GPUImageDilationFilter.h 845B
GPUImageParallelCoordinateLineTransformFilter.h 822B
GPUImageDirectionalNonMaximumSuppressionFilter.h 817B
GPUImageHistogramFilter.h 810B
GPUImageTransformFilter.h 801B
GPUImageVignetteFilter.h 799B
GPUImageMotionDetector.h 768B
GPUImageCrosshairGenerator.h 734B
GPUImageFramebufferCache.h 718B
GPUImageHistogramEqualizationFilter.h 707B
GPUImageSolidColorGenerator.h 703B
GPUImageSobelEdgeDetectionFilter.h 680B
GPUImageLineGenerator.h 674B
GPUImageTwoPassTextureSamplingFilter.h 671B
GPUImageKuwaharaFilter.h 664B
GPUImage3x3ConvolutionFilter.h 653B
GPUImagePixellatePositionFilter.h 650B
GPUImageToonFilter.h 644B
GPUImageLuminosity.h 641B
GPUImageFalseColorFilter.h 632B
GPUImageHazeFilter.h 630B
GPUImageTwoInputFilter.h 628B
GPUImageFilterGroup.h 625B
GPUImagePoissonBlendFilter.h 621B
GPUImageAverageColor.h 615B
GPUImagePinchDistortionFilter.h 615B
GPUImageGaussianBlurPositionFilter.h 607B
GPUImageBulgeDistortionFilter.h 600B
GPUImage3x3TextureSamplingFilter.h 593B
GPUImageSwirlFilter.h 576B
GPUImageSphereRefractionFilter.h 565B
GPUImageErosionFilter.h 560B
GPUImageThreeInputFilter.h 559B
GPUImageRGBDilationFilter.h 553B
GPUImageTextureOutput.h 549B
GPUImageRGBErosionFilter.h 548B
GPUImageOpeningFilter.h 548B
GPUImageClosingFilter.h 546B
GPUImageTwoInputCrossTextureSamplingFilter.h 544B
GPUImageMovieComposition.h 527B
GPUImageSoftEleganceFilter.h 527B
GPUImageWhiteBalanceFilter.h 525B
GPUImagePicture+TextureSubimage.h 524B
GPUImageHighPassFilter.h 507B
GPUImageShiTomasiFeatureDetectionFilter.h 501B
GPUImageColorMatrixFilter.h 491B
GPUImageUnsharpMaskFilter.h 479B
GPUImageRGBOpeningFilter.h 479B
GPUImageRGBClosingFilter.h 478B
GPUImageLowPassFilter.h 465B
GPUImageBeautifyFilter.h 454B
GPUImageMissEtikateFilter.h 447B
GPUImageThresholdedNonMaximumSuppressionFilter.h 430B
GPUImageAmatorkaFilter.h 429B
GPUImageCropFilter.h 429B
GPUImagePosterizeFilter.h 428B
GPUImageCrosshatchFilter.h 424B
GPUImagePolarPixellateFilter.h 420B
GPUImageRGBFilter.h 412B
GPUImageLuminanceThresholdFilter.h 408B
GPUImagePixellateFilter.h 374B
GPUImageBilateralFilter.h 372B
GPUImageHighlightShadowFilter.h 368B
GPUImageNobleCornerDetectionFilter.h 356B
GPUImageMotionBlurFilter.h 354B
GPUImageThresholdEdgeDetectionFilter.h 347B
共 358 条
- 1
- 2
- 3
- 4
资源评论
Quinn士魁
- 粉丝: 153
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- date0425111111111111111111111
- 包含贪心算法的定义及python代码部分实现
- 自动驾驶-状态估计和定位之扩展卡尔曼滤波.pdf
- csdn之x-ca-key,x-ca-nonce,x-ca-signature与x-ca-signature-headers探索
- 基于TM1620数码显示芯片STM32单片机驱动程序软件源代码.zip
- 【tomcat6使用redis配置session共享】
- 包含杨辉三角的说明及java代码实现
- FDN371N-NL-VB一款SOT23封装N-Channel场效应MOS管
- AutomotiveSPICE-V4.0 中文版
- Java实现杨辉三角的生成和打印代码示例.md
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功