GPUCV

Document Sample
GPUCV Powered By Docstoc
					                          GpuCV: A GPU-accelerated
                          framework for image
                          processing and Computer
                          Vision


                          Y. Allusse, P. Horain,
                          A. Agarwal, C. Saipriyadarshan




          Why GpuCV?


         Image processing computing bottlenecks:

          • High image resolution (15 Mpixels cameras...)
               Data weight increasing faster than CPU computing power


          • Interactive applications of computer vision
               Real-time required




page 7     GpuCV                    Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                            1
          How to accelerate image processing?


          Available technologies for acceleration:
          • Extended instruction sets (ex.: Intel OpenCV / IPP)
          • Multiple CPU cores (ex.: IBM Cell)
          • Co-processor:
            - FPGA (field-programmable gate array)

            - GPU (graphical processing unit)


         ☺ GPUs available “for free” in consumer PCs




page 9     GpuCV                Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                     GPU: what?



                     Graphics Processing Units




page 10    GpuCV                Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                        2
          GPU: what?


      Originally in consumer PCs for gaming:

          Designed for advanced rendering
          • Multi-texturing effects.
          • Realistic lights and shadows effects.
          • Post processing visual effects.

          Image rendering device
          ☺ Highly parallel processor
          ☺ High bandwidth memory


page 11   GpuCV               Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




          GPU: Computation power history
                                                                                      Source: GPU4Vision, http://gpu4vision.icg.tugraz.at/




page 14   GpuCV               Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                                                                             3
           GPU vs CPU

                     Processing power ratio on price and power consumption
                                                  gFlops per €

                                                          4


 Different purpose
                                                          2
Different architecture

 Different efficiency                                     0




                   gFlops per Watts                                              gFlops



    NVIDIA GeForce 8800 GT      ATI Radeon HD 2900 XT      Intel Core 2 Duo E6700       AMD 64 x2 6000+



 page 16   GpuCV                           Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




           GPU programming challenges


           Algorithms
           • Highly parallel
           • Coding limitations
           Dedicated APIs
           • OpenGL, shading languages, CUDA
           Development tools
           • Rapidly evolving API
           • Heterogeneous and scattered documentation

           GPU complexity to be hidden for wide acceptance


 page 20   GpuCV                           Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                                          4
                        GpuCV




                        Framework description




page 21   GpuCV                 Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




             Integration with OpenCV applications

          Compatible on multiple OS such as MS Windows
          XP and LINUX.
          Designed to be fully compliant with existing
          OpenCV applications:
          • OpenCV function:
          void cvAdd(CvArr*src1, CvArr*src2, CvArr*dst)
          • GpuCV function:
          void cvgAdd(CvArr*src1, CvArr*src2, CvArr*dst)
          Change header and lib files to GpuCV and call init
          function:
          • cvgInit()


page 23   GpuCV                 Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                        5
          GpuCV: layered framework


      GpuCV = GPGPU framework +
               GPU-accelerated Computer Vision library

             OpenCV GPU-accelerated application
                               GpuCV-CUDA                                      Computer
                                                                               vision
                                GpuCV-GLSL                                     library
            OpenCV library                  GpuCVCore
                                         GpuCVTexture                         GPGPU
                                                                              Framework
                                       GpuCVHardware


page 24   GpuCV               Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




          GpuCV: Programming interfaces


          Native OpenCV
          OpenGL-GLSL
          • Highly compatible with most hardware.
          • Widely used language.
          NVIDIA CUDA
          • Currently compatible only with recent NVIDIA cards.
          • More flexible programming facilities (recursivity, full
            memory access)

          Up to three implementations for a routine


page 25   GpuCV               Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                          6
                  GpuCV




                  Data management




page 28   GpuCV          Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




          GpuCV: Memory locations



                                                      OpenGL context



  Central memory                                       Video memory
      (RAM)                                              (VRAM)



                                                       CUDA context



page 29   GpuCV          Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                 7
          GpuCV: Data container


Data descriptors that describes the data format and
 store the data, such as:




   GpuCV supports transparent data synchronization
page 31   GpuCV           Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                  GpuCV




                  Implementation switching




page 34   GpuCV           Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                  8
                              GpuCV: Performance issues


                              Operator performance depends on:
                              • Implementation used (CPU, GLSL, CUDA).
                              • Current data location(s) and eventual transfer.
                              • Operator parameters (image size, format, options)
                              • Host computer hardware.

                              Too many parameters to optimize manually an
                              application for many target platforms




                  page 35     GpuCV                            Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                              GpuCV: fast compute operators

                                                      Addition between 2 images


             40

             35
                                                                                                          Loading Time

             30

             25
                                                                                                          Read back time
Time in ms




             20

             15                                                                                           Processing time on
                                                                                                          GPU
             10

             5                                                                                            Processing time on
                                                                                                          CPU
             0
                       128²           256²           512²              1024²            2048²
                                             Image size in pixels




                      GPU much faster without transfer!!

                  page 36     GpuCV                            Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                                                               9
                              GpuCV: compute intensive operators

                                              Image Morphological closing (Erode + Dilate)

             180

             160
                                                                                                                Loading Time

             140

             120                                                                                                Read back time
Time in ms




             100

              80
                                                                                                                Morpho closing
              60                                                                                                on GPU
              40

              20
                                                                                                                Morpho closing
                                                                                                                on CPU
               0
                        64²           128²       256²                512²          1024²          2048²
                                                 Image size in pixels




                       GPU can be faster even with transfer!

                   page 37    GpuCV                             Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                              GpuCV: activation issue

                                                    Addition between 2 small images

             1,2

                                                                                                          Loading Time
              1


             0,8
                                                                                                          Read back time
Time in ms




             0,6


             0,4                                                                                          Processing time on GPU

             0,2
                                                                                                          Processing time on CPU
              0
                         0              32²             64²                 128²           256²
                                              Image size in pixels



                   GPU requires a base activation time
                             not efficient on small images!
                   page 38    GpuCV                             Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                                                                   10
           GpuCV: Auto-switching operators


          Internal switching mechanism
          • All GpuCV operators can switch between
            different implementations (CPU, GLSL, CUDA).
          • Switching can be manual or dynamic based on
            previous on-the-fly benchmarks.
          • Switching to the most efficient solution
            considering transfer time and processing time of
            each implementations.
          Has an additional cost of about 300 µs
             To be used with image larger than 256×256.


page 39    GpuCV                      Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




          Benchmarks


      Ex. processing 2048 x 2048 images
       with NVIDIA GeForce GTX 280 et Intel Core2 Duo 2.2
          GHz (online benchmark)

      (time in ms)           OpenCV GpuCV-CUDA                              Acceleration
      Deriche                 1997     19,35                                   103,2
      Erode 3 x 3              85,1     1,2                                    70,92
      Mul.                     73,6    0,99                                    74,34
      Mat. Mul.               11172     200                                    55,86
      DFT                     435,4     9,9                                    43,98
          https://picoforge.int-evry.fr/projects/svn/gpucv/bBenchs
                                         /0.4/0.4.1.rev.175/NV8800_Core2Duo-2.2
page 44    GpuCV                      Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                              11
          Example application


      3D model-based computer vision
          Real-time motion capture by computer vision




                                                                      MPEG 4 /BAP
                                    3D/2D registration


            http://MyBlog3D.com

page 45   GpuCV            Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




          Potential applications: large images




          Remote sensing



          Microscopy wide fields



          HD color printing…



page 46   GpuCV            Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                    12
                  Conclusion




page 47   GpuCV          Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




          The GpuCV framework

      GpuCV is:
       a framework for GPU acceleration
          image processing and Computer Vision operators
       compatible with the popular OpenCV library
          replacement to OpenCV routines
       hiding GPU programming complexity
          data synchronization
          codelets management (GLSL,CUDA)
       adaptive to hardware platform
          integrated benchmarking and implementation
         switching
       multi-platform library
          MS Windows & Linux
       open source
          CeCill-B license
page 48   GpuCV          Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                 13
          GpuCV available as open source


          http://picoforge.int-evry.fr/projects/gpucv




page 51   GpuCV             Y. Allusse, P. Horain, A. Agarwal, C. Saipriyadarshan




                                                                                    14

				
DOCUMENT INFO
Flavio Bernardotti Flavio Bernardotti Ing. www.bernardotti.it/portal
About Computer consultant since 1984. I wrote the software ITALINK (1985) to create the italian FIDONET (with some other sysop). I wrote 14 books all free distributed with fidonet, usenet and internet (http://www.bernardotti.it). For other info see my site.