OpenCV On A GPU

2y ago
154 Views
4 Downloads
1.72 MB
47 Pages
Last View : 15d ago
Last Download : 3m ago
Upload by : Sutton Moon
Transcription

OpenCV on a GPUShalini Gupta, Shervin Emami, Frank BrillNVIDIA

GPU access To access NVIDIA cluster send email to jlevites@nvidia.com Subject line: “OpenCV GPU Test Drive” Add your name and phone numberWebinar FeedbackSubmit your feedback for a chance to win Tesla K20 GPUhttps://www.surveymonkey.com/s/OpenCV WebinarMore questions on OpenCV and GPUs Stay tuned with NVIDIA webinars:http://www.nvidia.com/object/cuda signup alerts.html Refer to OpenCV Yahoo! Groups

OutlineOpenCVWhy GPUs?An example - CPU vs. CUDAOpenCV CUDA functionsDiscussionFutureSummary

OpenCVIntroductionOpen source library for computer vision, image processing and machine learningPermissible BSD licenseFreely available (www.opencv.org)PortabilityReal-time computer vision (x86 MMX/SSE, ARM NEON, CUDA)C (11 years), now C (3 years since v2.0), Python and JavaWindows, OS X, Linux, Android and iOS

UsageUsage: 6 million downloads, 47,000 user groupGoogle, Yahoo, Microsoft, Intel, IBM, Sony, Honda, ToyotaApplications:Street view image stitchingAutomated inspection and surveillanceRobot and driver-less car navigation and controlMedical image analysisVideo/image search and retrievalMovies - 3D structure from motionInteractive art installations

FunctionalityDesktopx86 single-core (Intel started, now Itseez.com) - v2.4.5 2500 functions (multiplealgorithm options, data types)CUDA GPU (Nvidia) - 250 functions (5x – 100x u.htmlOpenCL GPU (3rd parties) - 100 functions (launch times 7x slower than CUDA*)Mobile (Nvidia):Android (not optimized)Tegra – 50 functions NEON, GLSL, multi-core (1.6 – 32x speed-up)*Shengen Yan, AMD Fusion Developer Summit 2012.

FunctionalityImage/video I/O, processing, display (core, imgproc, highgui)Object/feature detection (objdetect, features2d, nonfree)Geometry-based monocular or stereo computer vision (calib3d, stitching,videostab)Computational photography (photo, video, superres)Machine learning & clustering (ml, flann)CUDA and OpenCL GPU acceleration (gpu, ocl)

OutlineOpenCVWhy GPUs?An example - CPU vs. CUDAOpenCV CUDA functionsDicussionFutureSummary

Why GPU?CPUReached speed and thermal power limit!Incremental improvements (memory caches and complex architectures)Multi-core (4/8), but software rarely multi-coreGPUHighly parallel with 100s of simple coresEasier to extend by adding more coresContinue to grow exponentially!

GPU CPU (compute and /introduction-to-cuda-5-0/

GPU for OpenCVGraphicsRender ImagesFrom ScenesInverseProblemsMassivelyParallelComputer VisionUnderstand ScenesFrom Images

OutlineOpenCVWhy GPUs?An example - CPU vs. CUDAOpenCV CUDA functionsDicussionFutureSummary

OpenCV CPU example#include opencv2/opencv.hpp using namespace cv; OpenCV header files OpenCV C namespaceint main() {Mat src imread(“car1080.jpg”, 0); Load an image file as grayscaleif (!src.data) exit(1);Mat dst; bilateralFilter(src, dst, -1, 50, 7); Canny(dst, dst, 35, 200, 3); imwrite(“out.png”, dst); return 0;}Allocate a temp output imageBlur the image but keep edges sharpFind the edges, drawn as white pixelsStore to an image file

OpenCV CPU example#include opencv2/opencv.hpp using namespace cv;int main() {Mat src imread(“car1080.jpg”, 0);if (!src.data) exit(1);Mat dst;bilateralFilter(src, dst, -1, 50, 7);Canny(dst, dst, 35, 200, 3);imwrite(“out.png”, dst);return 0;}

OpenCV CUDA example#include opencv2/opencv.hpp #include opencv2/gpu/gpu.hpp using namespace cv; OpenCV GPU header fileint main() {Mat src imread(“car1080.jpg”, 0);if (!src.data) exit(1);gpu::GpuMat d src(src); gpu::GpuMat d dst; gpu::bilateralFilter(d src, d dst, -1, 50, 7); gpu::Canny(d dst, d dst, 35, 200, 3); Mat dst(d dst); imwrite(“out.png”, dst);return 0;}Upload image from CPU to GPU memoryAllocate a temp output image on the GPUProcess images on the GPUProcess images on the GPUDownload image from GPU to CPU mem

OpenCV CUDA example#include opencv2/opencv.hpp #include opencv2/gpu/gpu.hpp using namespace cv;int main() {Mat src imread(“car1080.jpg”, 0);if (!src.data) exit(1);gpu::GpuMat d src(src);gpu::GpuMat d dst;gpu::bilateralFilter(d src, d dst, -1, 50, 7);gpu::Canny(d dst, d dst, 35, 200, 3);Mat dst(d dst);imwrite(“out.png”, dst);return 0;}

CPUvs.CUDA#include opencv2/opencv.hpp #include opencv2/gpu/gpu.hpp #include opencv2/opencv.hpp using namespace cv;using namespace cv;int main() {int main() {Mat src imread(“car1080.jpg”, 0);Mat src imread(“car1080.jpg”,if (!src.data) exit(1);0);0.5ms gpu::GpuMat d src(src);if (!src.data) exit(1);0ms gpu::GpuMat d dst;Mat dst;bilateralFilter(src, dst,-1, 50, 2521ms187ms gpu::bilateralFilter(d src, d dst, -1,50, 7);7); 19ms12ms gpu::Canny(d dst, d dst, 35, 200, 3);Canny(dst, dst, 35, 200,3);Mat dst(d dst);imwrite(“out.png”, dst);0.5ms imwrite(“out.png”, dst);return 0;return 0;}}TOTALS:CPU 2540ms CUDA 200ms**results obtained over many frames

OutlineOpenCVWhy GPUs?An example - CPU vs. GPUOpenCV CUDA functionsDiscussionFutureSummary

CUDA Matrix OperationsPoint-wise matrix mathgpu::add(), ::sum(), ::div(), ::sqrt(), ::sqrSum(), ::meanStdDev, ::min(), ::max(),::minMaxLoc(), ::magnitude(), ::norm(), ::countNonZero(), ::cartToPolar(), etc.Matrix multiplicationgpu::gemm()Channel manipulation*gpu::merge(), ::split()*www.shervinemami.info/blobs.html

CUDA Geometric OperationsImage resize with sub-pixel interpolationgpu::resize()Image rotate with sub-pixel interpolationgpu::rotate()Image warp (e.g., panoramic stitching)gpu::warpPerspective(), ::warpAffine()**www.skyscrapercity.com

CUDA other Math and Geometric OperationsIntegral images (e.g., object detection and recognition, feature tracking)gpu::integral(), ::sqrIntegral()Custom geometric transformation (e.g., lens distortion correction)gpu::remap(), ::buildWarpCylindricalMaps(), /web/calibration.php

CUDA Image ProcessingSmoothinggpu::blur(), ::boxFilter(), ::GaussianBlur()Morphologicalgpu::dilate(), ::erode(), ::morphologyEx()Edge Detectiongpu::Sobel(), ::Scharr(), ::Laplacian(), gpu::Canny()Custom 2D filtersgpu::filter2D(), ::createFilter2D GPU(), ::createSeparableFilter GPU()Color space conversiongpu::cvtColor()

CUDA Image ProcessingImage blendinggpu::blendLinear()Template matching (automated inspection)gpu::matchTemplate()Gaussian pyramid (scale invariant feature/object detection)*gpu::pyrUp(), ::pyrDown()Image histogramgpu::calcHist(), gpu::histEven, gpu::histRange()Contract enhancement*gpu::equalizeHist()*OpenCV Histogram Equalization Tutorial

CUDA De-noisingGaussian noise removalgpu::FastNonLocalMeansDenoising()Edge preserving hk/ qiyang/publications.html

CUDA Fourier and MeanShiftFourier analysisgpu::dft(), ::convolve(), ::mulAndScaleSpectrums(), etc.MeanShiftgpu::meanShiftFiltering(), n/education/Workshop/t.schoenen.html

CUDA Shape DetectionLine detection (e.g., lane detection, building detection, perspective correction)gpu::HoughLines(), ::HoughLinesDownload()Circle detection (e.g., cells, coins, balls)gpu::HoughCircles(), .html www.cs.bgu.ac.il/ icbv071/StudentProjects.php

CUDA Object DetectionHAAR and LBP cascaded adaptive boosting (e.g., face, nose, eyes, mouth)gpu::CascadeClassifier GPU::detectMultiScale()HOG detector (e.g., person, car, fruit, hand)gpu::HOGDescriptor::detectMultiScale() **glowingpython.blogspot.com/2011/11/ src:www.cvc.uab.es/ dvazquez/wordpress/?page id 234

CUDA Object RecognitionInterest point detectorsgpu::cornerHarris(), ::cornerMinEigenVal(), ::SURF GPU, ::FAST GPU, ::ORB GPU(),::GoodFeaturesToTrackDetector GPU()Feature matchinggpu::BruteForceMatcher GPU(), ::BFMatcher GPU()**Kathleen Tuite, CSE576 Project, U of W, 2008.

CUDA Stereo and 3DRANSAC (e.g., object 3D pose, structure from motion, stereo vision)gpu::solvePnPRansac()Stereo correspondence (disparity map)gpu::StereoBM GPU(), ::StereoBeliefPropagation(), er()Represent stereo disparity as 3D or 2Dgpu::reprojectImageTo3D(), ::drawColorDisp()**www.cyverse.co.jp/eng/

CUDA Optical FlowDense/sparse optical flow (with simple block matching, pyramidal LucasKanade, Brox, Farnebac, TV-L1)gpu::FastOpticalFlowBM(), ::PyrLKOpticalFlow, ::BroxOpticalFlow(),::FarnebackOpticalFlow(), ::OpticalFlowDual TVL1 GPU(), ::interpolateFrames()Applications: motion estimation, object tracking, image misation-optical-flow/

CUDA Background SegmentationForegrdound/background segmentation (e.g., object detection/removal,motion tracking, background removal)gpu::FGDStatModel, ::GMG GPU, ::MOG GPU, ::MOG2 o-4-appidemic/

Custom CUDA codeCPU OpenCV provides access to image pixels to write custom functions GPU-accelerated pixel access to write custom CUDA kernels – requiresknowledge of l

OutlineOpenCVWhy GPUs?An example - CPU vs. CUDAOpenCV CUDA functionsDicussionFutureSummary

CUDA AdvantagesSimilar to CPU code – same APIGreat for long parallel operations and low data transfers – slowest CPUfunctionsSignificant boosts on GPU (e.g., bilateralFilter() – 12.7x speedup)Makes CPU compute bound CV tasks feasible in real-time (e.g., stereo vision,pedestrian detection, dense optical flow)Runtime check and use of CUDA acceleration

CUDA DisadvantagesOnly 250 functionsLimited data typesGPU: 8-bit & 32-bit grayscaleCPU: 16-bit (HDR) & 32-bit color, ROIExplicitly program for CUDAHandle data transfers between CPU and GPUOnly on NVIDIA GPUSome serial operations not sped up, e.g., Canny()CUDA has startup delay

CUDA Start Up DelayFirst CUDA call initializes CUDA moduleTypical first call – CPU to GPU transfer ( 2000ms and 1ms after that)Affects single frame applications, videos OK

Serial functions on CUDASerial functions don’t port wellEquivalent efficient CUDA parallel algorithms exist (e.g., image sums, intergalimages, histogram) – see www.moderngpu.com or Udacity’s CS344Serial GPU code saves transfer timeCUDA CV algorithms actively being researchedNew CUDA generations (hw sw) allow more algorithms

GPU Memory AccessDedicated GPUIntegrated GPUOwn high speed memoryShares CPU’s slow memoryHigh data transfer timeFree data transfersHigher memory BW ( 10x)Lower memory BWDesktops/workstationsLaptopsFunctions with lots ofprocessingFunctions with little processing

OutlineOpenCVWhy GPUs?An example - CPU vs. CUDAOpenCV CUDA functionsDiscussionFutureSummary

Future - CUDA on MobileTegra with CUDA GPU (Logan) – mobile CUDA openCV possible!Low power and area (automotive, mobile)Kayla1 and Jetson2 (Tegra 3 dGPU)Currently on mobile (Tegra) – NEON, GLES, and multithreading(OpenCV4Tegra)Custom NEON/GLES programming hard, CUDA platform.html

Future - Khronos OpenVX“OpenVX” - new standard for hw accelerated CVKhronos (e.g., OpenGL, OpenCL, OpenVG)NVIDIA, Texas Instruments, Samsung, Qualcomm, ARM, IntelFor mobile acceleration hw (CPU, GPU, DSP, fixed-function)Graph model vs. synchronous programming modelCV nodes linked in graph at initialization, efficient hw specific processingpipeline automatically generatedOpenCV to use OpenVX internally to better use hw acceleration

OutlineOpenCVWhy GPUs?An example - CPU vs. CUDAOpenCV CUDA functionsDiscussionFutureSummary

SummaryOpenCV a well established comprehensive libraryGPU CPU and growingMany CV algorithms great for GPUCUDA OpenCV - 250 functions, custom GPU htmlOpenVX extends beyond GPU (DSP, fixed function hw)

GPU Everywhere!Tegra Tablets, Smartphones, ShieldTabletsTegra 3 CPU & GPU, running Android, WinRT or Linux.Kayla Development BoardKaylaTegra 3 CPU laptop GPU, running Linux.Jetson Automotive PlatformJetsonTegra 3 CPU laptop GPU, running Linux.DesktopIntel or AMD CPU with GeForce, Quadro or Tesla GPUs.DesktopsCloud & Supercomputer centersAmazon Cloud with Fermi GPUs, Nvidia GRIDCloud &Supercomputers

GPU access To access NVIDIA cluster send email to jlevites@nvidia.com Subject line: “OpenCV GPU Test Drive” Add your name and phone numberWebinar FeedbackSubmit your feedback for a chance to win Tesla K20 GPUhttps://www.surveymonkey.com/s/OpenCV WebinarMore questions on OpenCV and GPUs Stay tuned with NVIDIA webinars:http://www.nvidia.com/object/cuda signup alerts.html Refer to OpenCV Yahoo! Groups

Questions

Upcoming GTC Express WebinarsJune 12 - Easily Accelerating Existing Monte Carlo Code: CVA and CCR ExamplesJune 20 - GPU Accelerated XenDesktop for Designers and EngineersJune 26 - Understanding Dynamic Parallelism at Any Scale with Allinea's UnifiedToolsJuly 9 – NVIDIA GRID VCA: A Turnkey Appliance for Design and EngineeringApplicationsJuly 10 - Introduction to the CUDA Toolkit as an Application Build ToolRegister at www.gputechconf.com/gtcexpress

OpenCV GPU header file Upload image from CPU to GPU memory Allocate a temp output image on the GPU Process images on the GPU Process images on the GPU Download image from GPU to CPU mem OpenCV CUDA example #include opencv2/opencv.hpp #include <

Related Documents:

Outline: OPENCV 3.0 Intro –Learning OpenCV Version 2.0 coming by Aug –Announcing 50K Vision Challenge OpenCV Background OpenCV 3.0 High Level OpenCV 3.0 Modules Brand New

7. Sumber Referensi Belajar OpenCV 8. Tip-Tip Belajar OpenCV 9. Penutup 1. Apa Itu OpenCV? OpenCV (Open Computer Vision) Pustaka computer vision yang open source dan dipakai secara luas di macam-macam sistem operasi dan arsitektur komputer untuk keperluan pe

2.Basic Numpy Tutorials 3.Numpy Examples List 4.OpenCV Documentation 5.OpenCV Forum 1.1.2Install OpenCV-Python in Windows Goals In this tutorial We will learn to setup OpenCV-Python in your Windows system. Below steps are tested in a Windows 7-64 bit machine with Visual Studio 2010 and Visual Studio 2012. The screenshots shows VS2012.

OpenCV GPU Module Performance Tesla C2050 (Fermi) vs. Core i5-760 2.8GHz (4 cores, TBB, SSE) —Average speedup with GPU: 33.98 What can you get from your computer? —opencv

openCV Library The open source computer vision li-brary, OpenCV, began as a research project at Intel in 1998.5 It has been available since 2000 under the BSD open source license. OpenCV is aimed at providing the tools needed to solve computer-vision problems. It contains a mix of low-level image-processing functions and high-level algorithmsFile Size: 2MB

3 opencv The main OpenCV repository, essential, stable modules opencv_contrib Experimental or obsolete OpenCV functionality cvat (Computer Vision Annotation Tool) Tool for annotation of datasets; reworked version of VATIC dldt (Deep Learning Deployment To

OpenCV OpenCV is an open source Computer Computer Vision library. It allows to develop complex Computer Vision and Machine Learning applications fast, offering a wide set of functions. Originally developed in C/C , now OpenCV has handlers also for Java and

Boris Fausto Frontmatter Moreinformation. xiv Preface the tendency to consider Brazilian history as an evolutionary trend characterized by constant progress. This is a simplistic point of view that events in recent years have belied. On the other hand, I have also rejected the point of view that emphasizes inertia – that suggests, for example, that problems caused by political patronage, by .