SlideShare a Scribd company logo
1 of 17
Download to read offline
Aug. 5, 2014
GPUImage Introduction
Bruce Tsai
Core Image
✤ Included in
iOS from 2011!
✤ 100+ built-in
filters!
✤ Multithread
by CPU
Drawbacks
✤ Customization limited!
- Subclass CIFilter in iOS!
- Create custom filters (shader) only in OSX!
✤ Performance not tuned!
- Address tuning tips in WWDC 2012 (session 511)
3
GPUImage
✤ Open source (BSD) iOS framework!
✤ GPU-based image and video processing!
✤ From GPU-accelerated video processing project (2010)!
✤ https://github.com/BradLarson/GPUImage
4
Advantages
✤ Performance!
- High FPS in real-time preview!
✤ Customization!
- OpenGL ES shader code
5
Buffer Process Flow
VideoCamera Sepia
View
MovieWriter
BlendPicture
Source Filter Output
Code Snippet
GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera
alloc] initWithSessionPreset:AVCaptureSessionPreset640x480
cameraPosition:AVCaptureDevicePositionBack];
GPUImageFilter *customFilter = [[GPUImageFilter alloc]
initWithFragmentShaderFromFile:@“CustomShader”];
GPUImageView *filteredVideoView = [[GPUImageView alloc]
initWithFrame:CGRectMake(0.0, 0.0, viewWidth, viewHeight)];
[videoCamera addTarget:customFilter];
[customFilter addTarget:filteredVideoView];
[videoCamera startCameraCapture];
Class Diagram
Procedures
1. Add effect to input buffer !
2. Save result to output buffer!
3. Set targets’ input buffer attributes!
4. Set targets’ input buffer!
5. Invoke targets’ operation
9
Frame Buffer Object (FBO)
glBindFramebuffer(GL_FRAMEBUFFER,
framebuffer);
glBindTexture(GL_TEXTURE_2D, renderTexture);
glFramebufferTexture2D(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
renderTexture, 0);
Buffer Binding in FBO
Frame
Buffer
TexturePixel Buffer
Render destination
Actual render
target
Main memory
buffer
Conversion to and fromTexture
CVPixelBufferRef pxBufferRef =
CMSampleBufferGetImageBuffer(imageBuffer);
CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDe
fault, videoTextureCache, pxBufferRef, NULL, GL_TEXTURE_2D,
GL_RGBA, width, height, GL_BGRA, GL_UNSIGNED_BYTE, 0,
&videoTextureRef);
...
// renderTargetRef is corresponding to renderTexture of FBO
[writerAdaptor appendPixelBuffer:renderTargetRef
withPresentationTime:pts];
Threading Model
✤ Grand Central Dispatch (GCD)!
- Dispatch queue!
✤ runSynchronousOnVideoProcessingQueue!
✤ runAsynchronousOnVideoProcessingQueue!
✤ runSynchronousOnContextQueue!
✤ runAsynchronousOnContextQueue
14
Demo
Reference
✤ https://github.com/BradLarson/GPUImage!
✤ http://blog.db-in.com/all-about-opengl-es-2-x-part-2/!
✤ https://developer.apple.com/library/ios/documentation/
3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/
Introduction/Introduction.html#//apple_ref/doc/uid/
TP40008793!
✤ https://developer.apple.com/library/ios/documentation/
GraphicsImaging/Conceptual/CoreImaging/ci_intro/
ci_intro.html#//apple_ref/doc/uid/TP30001185

More Related Content

Viewers also liked

Secure Multi-Party Negotiation: An Analysis for Electronic Payments in Mobile...
Secure Multi-Party Negotiation: An Analysis for Electronic Payments in Mobile...Secure Multi-Party Negotiation: An Analysis for Electronic Payments in Mobile...
Secure Multi-Party Negotiation: An Analysis for Electronic Payments in Mobile...IDES Editor
 
What's a Core Image? An Image-Processing Framework on iOS and OS X
What's a Core Image? An Image-Processing Framework on iOS and OS XWhat's a Core Image? An Image-Processing Framework on iOS and OS X
What's a Core Image? An Image-Processing Framework on iOS and OS XFlatiron School
 
Advanced Imaging on iOS
Advanced Imaging on iOSAdvanced Imaging on iOS
Advanced Imaging on iOSrsebbe
 
Hyojin portfolio
Hyojin portfolioHyojin portfolio
Hyojin portfolioHyojin Mo
 
Digital watermarking
Digital watermarkingDigital watermarking
Digital watermarkingrupareliab14
 
Image Processing and Computer Vision in iOS
Image Processing and Computer Vision in iOSImage Processing and Computer Vision in iOS
Image Processing and Computer Vision in iOSOge Marques
 

Viewers also liked (10)

Secure Multi-Party Negotiation: An Analysis for Electronic Payments in Mobile...
Secure Multi-Party Negotiation: An Analysis for Electronic Payments in Mobile...Secure Multi-Party Negotiation: An Analysis for Electronic Payments in Mobile...
Secure Multi-Party Negotiation: An Analysis for Electronic Payments in Mobile...
 
What's a Core Image? An Image-Processing Framework on iOS and OS X
What's a Core Image? An Image-Processing Framework on iOS and OS XWhat's a Core Image? An Image-Processing Framework on iOS and OS X
What's a Core Image? An Image-Processing Framework on iOS and OS X
 
Advanced Imaging on iOS
Advanced Imaging on iOSAdvanced Imaging on iOS
Advanced Imaging on iOS
 
Hyojin portfolio
Hyojin portfolioHyojin portfolio
Hyojin portfolio
 
Image compression Algorithms
Image compression AlgorithmsImage compression Algorithms
Image compression Algorithms
 
Jpeg compression
Jpeg compressionJpeg compression
Jpeg compression
 
Digital Watermarking
Digital WatermarkingDigital Watermarking
Digital Watermarking
 
Digital watermarking
Digital watermarkingDigital watermarking
Digital watermarking
 
Image Processing and Computer Vision in iOS
Image Processing and Computer Vision in iOSImage Processing and Computer Vision in iOS
Image Processing and Computer Vision in iOS
 
JPEG Image Compression
JPEG Image CompressionJPEG Image Compression
JPEG Image Compression
 

Similar to iOS GPUImage introduction

AVFoundation @ TACOW 2013 05 14
AVFoundation @ TACOW 2013 05 14AVFoundation @ TACOW 2013 05 14
AVFoundation @ TACOW 2013 05 14Ryder Mackay
 
Core image presentation
Core image presentationCore image presentation
Core image presentationKyle Stewart
 
Yahoo! Open Hackday 2013 - Frosted Glass Effect
Yahoo! Open Hackday 2013 - Frosted Glass EffectYahoo! Open Hackday 2013 - Frosted Glass Effect
Yahoo! Open Hackday 2013 - Frosted Glass EffectSyu-jhih Wu
 
Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014Alvinsight
 
Mobile Meow at Mobilism
Mobile Meow at MobilismMobile Meow at Mobilism
Mobile Meow at MobilismGreg Schechter
 
Why is making and managing apps so hard?
Why is making and managing apps so hard?Why is making and managing apps so hard?
Why is making and managing apps so hard?Nick Bogaty
 
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...Joone Hur
 
HTML5 Video Presentation
HTML5 Video PresentationHTML5 Video Presentation
HTML5 Video Presentationsith33
 
Hero Video Performance
Hero Video PerformanceHero Video Performance
Hero Video PerformanceWalter Ebert
 
JS Days HTML5 Flash and the Battle for Faster Cat Videos
JS Days HTML5 Flash and the Battle for Faster Cat VideosJS Days HTML5 Flash and the Battle for Faster Cat Videos
JS Days HTML5 Flash and the Battle for Faster Cat VideosGreg Schechter
 
Responsive browser-based video recording and playback
Responsive browser-based video recording and playbackResponsive browser-based video recording and playback
Responsive browser-based video recording and playbackOliver Friedmann
 
VISION Technology from AMD Powered by AMD E-Series & C-Series APUs
VISION Technology from AMD Powered by AMD E-Series & C-Series APUsVISION Technology from AMD Powered by AMD E-Series & C-Series APUs
VISION Technology from AMD Powered by AMD E-Series & C-Series APUsAdditionalResources
 
Сергей Батищев: 2D игры на HTML5: мифы и реальность разработки
Сергей Батищев: 2D игры на HTML5: мифы и реальность разработкиСергей Батищев: 2D игры на HTML5: мифы и реальность разработки
Сергей Батищев: 2D игры на HTML5: мифы и реальность разработкиDevGAMM Conference
 
Building Video Applications with YouTube APIs
Building Video Applications with YouTube APIsBuilding Video Applications with YouTube APIs
Building Video Applications with YouTube APIsJarek Wilkiewicz
 
USPTA Specialty Course - Video Analysis
USPTA Specialty Course - Video AnalysisUSPTA Specialty Course - Video Analysis
USPTA Specialty Course - Video AnalysisDoug Eng
 
Multimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audioMultimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audioChristian Heilmann
 

Similar to iOS GPUImage introduction (20)

AVFoundation @ TACOW 2013 05 14
AVFoundation @ TACOW 2013 05 14AVFoundation @ TACOW 2013 05 14
AVFoundation @ TACOW 2013 05 14
 
Core image presentation
Core image presentationCore image presentation
Core image presentation
 
Yahoo! Open Hackday 2013 - Frosted Glass Effect
Yahoo! Open Hackday 2013 - Frosted Glass EffectYahoo! Open Hackday 2013 - Frosted Glass Effect
Yahoo! Open Hackday 2013 - Frosted Glass Effect
 
Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014
 
JS Days Mobile Meow
JS Days Mobile MeowJS Days Mobile Meow
JS Days Mobile Meow
 
Web DU Mobile Meow
Web DU Mobile MeowWeb DU Mobile Meow
Web DU Mobile Meow
 
Mobile Meow at Mobilism
Mobile Meow at MobilismMobile Meow at Mobilism
Mobile Meow at Mobilism
 
Why is making and managing apps so hard?
Why is making and managing apps so hard?Why is making and managing apps so hard?
Why is making and managing apps so hard?
 
Flowframes
FlowframesFlowframes
Flowframes
 
Html5video
Html5videoHtml5video
Html5video
 
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
 
HTML5 Video Presentation
HTML5 Video PresentationHTML5 Video Presentation
HTML5 Video Presentation
 
Hero Video Performance
Hero Video PerformanceHero Video Performance
Hero Video Performance
 
JS Days HTML5 Flash and the Battle for Faster Cat Videos
JS Days HTML5 Flash and the Battle for Faster Cat VideosJS Days HTML5 Flash and the Battle for Faster Cat Videos
JS Days HTML5 Flash and the Battle for Faster Cat Videos
 
Responsive browser-based video recording and playback
Responsive browser-based video recording and playbackResponsive browser-based video recording and playback
Responsive browser-based video recording and playback
 
VISION Technology from AMD Powered by AMD E-Series & C-Series APUs
VISION Technology from AMD Powered by AMD E-Series & C-Series APUsVISION Technology from AMD Powered by AMD E-Series & C-Series APUs
VISION Technology from AMD Powered by AMD E-Series & C-Series APUs
 
Сергей Батищев: 2D игры на HTML5: мифы и реальность разработки
Сергей Батищев: 2D игры на HTML5: мифы и реальность разработкиСергей Батищев: 2D игры на HTML5: мифы и реальность разработки
Сергей Батищев: 2D игры на HTML5: мифы и реальность разработки
 
Building Video Applications with YouTube APIs
Building Video Applications with YouTube APIsBuilding Video Applications with YouTube APIs
Building Video Applications with YouTube APIs
 
USPTA Specialty Course - Video Analysis
USPTA Specialty Course - Video AnalysisUSPTA Specialty Course - Video Analysis
USPTA Specialty Course - Video Analysis
 
Multimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audioMultimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audio
 

More from Yi-Lung Tsai

Threads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonThreads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonYi-Lung Tsai
 
Lightning Talk - Raspberry Pi
Lightning Talk - Raspberry PiLightning Talk - Raspberry Pi
Lightning Talk - Raspberry PiYi-Lung Tsai
 
Problem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - GraphsProblem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - GraphsYi-Lung Tsai
 
Problem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - ListsProblem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - ListsYi-Lung Tsai
 
Problem Solving with Algorithms and Data Structures
Problem Solving with Algorithms and Data StructuresProblem Solving with Algorithms and Data Structures
Problem Solving with Algorithms and Data StructuresYi-Lung Tsai
 
OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL IntroductionYi-Lung Tsai
 
Android programming introduction
Android programming introductionAndroid programming introduction
Android programming introductionYi-Lung Tsai
 

More from Yi-Lung Tsai (8)

Threads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonThreads and Callbacks for Embedded Python
Threads and Callbacks for Embedded Python
 
Lightning Talk - Raspberry Pi
Lightning Talk - Raspberry PiLightning Talk - Raspberry Pi
Lightning Talk - Raspberry Pi
 
Problem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - GraphsProblem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - Graphs
 
Normal mapping
Normal mappingNormal mapping
Normal mapping
 
Problem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - ListsProblem Solving with Algorithms and Data Structure - Lists
Problem Solving with Algorithms and Data Structure - Lists
 
Problem Solving with Algorithms and Data Structures
Problem Solving with Algorithms and Data StructuresProblem Solving with Algorithms and Data Structures
Problem Solving with Algorithms and Data Structures
 
OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL Introduction
 
Android programming introduction
Android programming introductionAndroid programming introduction
Android programming introduction
 

Recently uploaded

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 

Recently uploaded (20)

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 

iOS GPUImage introduction

  • 1. Aug. 5, 2014 GPUImage Introduction Bruce Tsai
  • 2. Core Image ✤ Included in iOS from 2011! ✤ 100+ built-in filters! ✤ Multithread by CPU
  • 3. Drawbacks ✤ Customization limited! - Subclass CIFilter in iOS! - Create custom filters (shader) only in OSX! ✤ Performance not tuned! - Address tuning tips in WWDC 2012 (session 511) 3
  • 4. GPUImage ✤ Open source (BSD) iOS framework! ✤ GPU-based image and video processing! ✤ From GPU-accelerated video processing project (2010)! ✤ https://github.com/BradLarson/GPUImage 4
  • 5. Advantages ✤ Performance! - High FPS in real-time preview! ✤ Customization! - OpenGL ES shader code 5
  • 6. Buffer Process Flow VideoCamera Sepia View MovieWriter BlendPicture Source Filter Output
  • 7. Code Snippet GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack]; GPUImageFilter *customFilter = [[GPUImageFilter alloc] initWithFragmentShaderFromFile:@“CustomShader”]; GPUImageView *filteredVideoView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, viewWidth, viewHeight)]; [videoCamera addTarget:customFilter]; [customFilter addTarget:filteredVideoView]; [videoCamera startCameraCapture];
  • 9. Procedures 1. Add effect to input buffer ! 2. Save result to output buffer! 3. Set targets’ input buffer attributes! 4. Set targets’ input buffer! 5. Invoke targets’ operation 9
  • 10.
  • 11. Frame Buffer Object (FBO) glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glBindTexture(GL_TEXTURE_2D, renderTexture); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, renderTexture, 0);
  • 12. Buffer Binding in FBO Frame Buffer TexturePixel Buffer Render destination Actual render target Main memory buffer
  • 13. Conversion to and fromTexture CVPixelBufferRef pxBufferRef = CMSampleBufferGetImageBuffer(imageBuffer); CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDe fault, videoTextureCache, pxBufferRef, NULL, GL_TEXTURE_2D, GL_RGBA, width, height, GL_BGRA, GL_UNSIGNED_BYTE, 0, &videoTextureRef); ... // renderTargetRef is corresponding to renderTexture of FBO [writerAdaptor appendPixelBuffer:renderTargetRef withPresentationTime:pts];
  • 14. Threading Model ✤ Grand Central Dispatch (GCD)! - Dispatch queue! ✤ runSynchronousOnVideoProcessingQueue! ✤ runAsynchronousOnVideoProcessingQueue! ✤ runSynchronousOnContextQueue! ✤ runAsynchronousOnContextQueue 14
  • 15.
  • 16. Demo
  • 17. Reference ✤ https://github.com/BradLarson/GPUImage! ✤ http://blog.db-in.com/all-about-opengl-es-2-x-part-2/! ✤ https://developer.apple.com/library/ios/documentation/ 3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/ Introduction/Introduction.html#//apple_ref/doc/uid/ TP40008793! ✤ https://developer.apple.com/library/ios/documentation/ GraphicsImaging/Conceptual/CoreImaging/ci_intro/ ci_intro.html#//apple_ref/doc/uid/TP30001185