SlideShare a Scribd company logo
Uma Introdução a
Computer Vision


    Gustavo Pinto
    @gustavopinto
@gustavopinto
voltando alguns meses
         atrás
ainda
 em
2012
Python simplecv
Python simplecv
Python simplecv
Python simplecv
Computer Vision Made
       Easy



      Gustavo Pinto
    www.entropie.com.br
Computer Vision Made
       Easy



      Gustavo Pinto
    www.entropie.com.br
Reconhece essa imagem?
Reconhece essa imagem?

     Ela é *a* original?
E essa?
E essa? Como você sabe?
E essa? Como você sabe?
E essa? Como você sabe?




                  how to code?
Python simplecv
Python simplecv
Pixel
Pixel




r, g, b = monalisa[10, 0]
r = 231
g=0
b = 41
Pixel (231, 0, 14)
Pixel (231, 0, 14)




       R, G, B
Pixel (231, 0, 14)




       R, G, B



        [0..255]
Pixel (231, 0, 14)




       R, G, B



        [0..255]



           ....
logo...


              [[ 8, 0, 0],
               [10, 0, 0],
          =    [ 7, 0, 0],
               ...,
               [ 0, 3, 0],
               [ 0, 2, 0],
               [ 0, 2, 1]]]
E se...




          -   = x
E se...


[[ 2    0 0]       [[ 8 0 0]
 [2     0 0]        [10 0 0]
 [1     0 0]        [ 7 0 0]
 ...,
 [0     0 0]
               -    ...,
                    [ 0 3 0]
                             = x
 [0     0 0]        [ 0 2 0]
 [0     0 14]]      [ 0 2 1]]]
logo:


[[ 2    0 0]       [[ 8 0 0]     [[ -6 0   0]
 [2     0 0]        [10 0 0]      [ -8 0   0]
 [1     0 0]        [ 7 0 0]      [ -6 0   0]
 ...,
 [0     0 0]
               -    ...,
                    [ 0 3 0]
                             =    ...,
                                  [ 0 -3   0]
 [0     0 0]        [ 0 2 0]      [ 0 -2   0]
 [0     0 14]]      [ 0 2 1]]]    [ 0 -2   13]]]
logo:


[[ 2    0 0]       [[ 8 0 0]     [[ -6 0   0]
 [2     0 0]        [10 0 0]      [ -8 0   0]
 [1     0 0]        [ 7 0 0]      [ -6 0   0]
 ...,
 [0     0 0]
               -    ...,
                    [ 0 3 0]
                             =    ...,
                                  [ 0 -3   0]
 [0     0 0]        [ 0 2 0]      [ 0 -2   0]
 [0     0 14]]      [ 0 2 1]]]    [ 0 -2   13]]]
logo:
                           Então não existe
[[ 2    0 0]       [[ 8 0 0] cor negativa? 0]
                                    [[ -6 0
 [2     0 0]        [10 0 0]         [ -8 0 0]
 [1     0 0]        [ 7 0 0]         [ -6 0 0]
 ...,
 [0     0 0]
               -    ...,
                    [ 0 3 0]
                             =       ...,
                                     [ 0 -3 0]
 [0     0 0]        [ 0 2 0]         [ 0 -2 0]
 [0     0 14]]      [ 0 2 1]]]       [ 0 -2 13]]]
logo:


[[ 2    0 0]       [[ 8 0 0]     [[ 0 0   0]
 [2     0 0]        [10 0 0]      [0 0    0]
 [1     0 0]        [ 7 0 0]      [0 0    0]
 ...,
 [0     0 0]
               -    ...,
                    [ 0 3 0]
                             =    ...,
                                  [0 0    0]
 [0     0 0]        [ 0 2 0]      [0 0    0]
 [0     0 14]]      [ 0 2 1]]]    [0 0
                                 13]]]
x.show()
-   =
-           =
75.88       61.04       27.57
-           =
75.88       61.04       27.57
x=         -
if x >= threshold :
     print "fake"
x=         -
if x >= threshold :
     print "fake"
Como criar
esse código?
Enabling Computers to
         See
● Open source
● Escrito em Python
● Integrado com iPython
● Excelente para
  ○ manipulação de imagens
  ○ conversão de formatos
  ○ detecção de features
● Captura imagens de streams
  ○ kinect, webcams, IP Cams, ...
What is Computer Vision?
What is Computer Vision?
What is Computer Vision?
               acquire

               process

               analyze
This is computer vision
      made easy!
Primeiro Problema




2004
Primeiro Problema




2004
Primeiro Problema




2004
Primeiro Problema


         Vou criar um
          script pra
       redimensionar..



2004
Primeiro Problema
Primeiro Problema
Primeiro Problema
Primeiro Problema
           imgs = ImageSet(image_dir)

                   for img in imgs:
                    img = img.resize(w=x, h=y)
                    img.save()
Primeiro Problema
           imgs = ImageSet(image_dir)

                  for img in imgs:
                   img = img.resize(w=x, h=y)
                   img.save()
Primeiro Problema
           imgs = ImageSet(image_dir)

                   for img in imgs:
                    img = img.resize(w=x, h=y)
                    img.save()
Primeiro Problema
           imgs = ImageSet(image_dir)

                   for img in imgs:
                    img = img.resize(w=x, h=y)
                    img.save()
Primeiro Problema
           imgs = ImageSet(image_dir)

                   for img in imgs:
                    img = img.resize(w=x, h=y)
                    img.save()
     Esse cara
      sou eu..
Primeiro Problema
           imgs = ImageSet(image_dir)

                           for img in imgs:
                            img = img.resize(w=x, h=y)
                            img.save()




                  150+ methods




http://simplecv.org/docs/SimpleCV.html
Outras features




original / 5    original   original * 5
Outras features




rotate(73., point=(img.width/2,img.height/2))




                                                img.binarize()   img.binarize().invert()
            img.crop(50,40,100, 100)
Segundo Problema


Quem mexeu no meu sorvete?
Quem mexeu no meu sorvete?
Quem mexeu no meu sorvete?
+
+
+
+
    =
        Como eu vejo
+
+
    =
        Como realmente é
cam =
Camera()
cam.live()
cam =
Camera()
cam.live()
cam =
Camera()
cam.live()

cam = Camera()
while True:
  cam.getImage().
show()
cam =
Camera()
cam.live()

cam = Camera()
while True:
  cam.getImage().
show()


cam = Camera()
disp = Display()
while disp.isNotDone():
   img = cam.getImage()
   img.save(disp)
cam =
Camera()
cam.live()

cam = Camera()
while True:
  cam.getImage().
show()


cam = JpegStreamReader(device)
disp = Display()
while disp.isNotDone():
   img = cam.getImage()
   img.save(disp)
cam = JpegStreamReader(device)
disp = Display()
previous = cam.getImage()
while disp.isNotDone():
   current = cam.getImage()
   diff = current - previous

  if diff.getNumpy().mean() > threshold:
      estaoMexendoNaGeladeira(current)
cam = JpegStreamReader(device)
disp = Display()
previous = cam.getImage()
while disp.isNotDone():
   current = cam.getImage()
   diff = current - previous

  if diff.getNumpy().mean() > threshold:
      postAtFacebook(current)
Terceiro Problema


  Identificando Imagens
Template Maching
  search for instances in a image
Python simplecv
.findTemplate(   )
.findTemplate(   )




matches.draw()
.findTemplate(   )
.findTemplate(   )




matches.draw()
Key Point
Template Maching
    search for keypoints
.findkeypointMatch(   )
.findkeypointMatch(    )




.findkeypoints().draw()
.findkeypointMatch(   )




matches.draw()
Haar Like Features
  classify more generic objects
●   Face
●   Perfil
●   Olhos
●   Orelhas
●   Óculos




    img.findHaarFeatures('face')[-1].draw()
●   Face
●   Perfil
●   Olhos
●   Boca
●   Nariz
●   Face
●   Perfil
●   Olhos
●   Boca
●   Nariz
●   Face
●   Perfil
●   Olhos
●   Boca
●   Nariz
Haar-like
 Features
    !=
   Face
Recognition
Sim, e dai?
mustacheinator.py




     https://gist.github.com/4685584
Problema Bónus
Problema Bónus
Problema Bónus

        barcode = img.findBarcode()
        if barcode is not None:
              print barcode[0].data

More Related Content

PDF
The Ring programming language version 1.7 book - Part 57 of 196
PDF
Dynamic Deployment With Apache Felix
PPTX
Raspberry Pi à la GroovyFX
PDF
Exploring Canvas
PDF
Program Language - Fall 2013
PPTX
Introduction of 3D Development
PPTX
Making Games in JavaScript
PDF
Gems of GameplayKit. UA Mobile 2017.
The Ring programming language version 1.7 book - Part 57 of 196
Dynamic Deployment With Apache Felix
Raspberry Pi à la GroovyFX
Exploring Canvas
Program Language - Fall 2013
Introduction of 3D Development
Making Games in JavaScript
Gems of GameplayKit. UA Mobile 2017.

What's hot (20)

PPT
X2 T06 01 Discs & Washers
PDF
ฝึกคิดเลขเร็ว ป4(1)
PPTX
Patrick Kettner - JavaScript without javascript
PPT
Multiplicaciones2
PDF
662305 LAB13
PDF
งานและพลังงาน
PDF
Human-powered Javascript Compression for Fun and Gummy Bears
KEY
Kwp2 091217
PPTX
Kotlin Mullets
PDF
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
PPT
Mobile Game and Application with J2ME - Collision Detection
PPT
Mobile Game and Application with J2ME
PPTX
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
PPTX
Aditazz 01-ul
PDF
ฝึกคิดเลขเร็ว ป4(2)
PDF
20091106 01
PDF
1024+ Seconds of JS Wizardry - JSConf.eu 2013
DOCX
Interpolasi
PPT
Dip syntax 4
X2 T06 01 Discs & Washers
ฝึกคิดเลขเร็ว ป4(1)
Patrick Kettner - JavaScript without javascript
Multiplicaciones2
662305 LAB13
งานและพลังงาน
Human-powered Javascript Compression for Fun and Gummy Bears
Kwp2 091217
Kotlin Mullets
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
Mobile Game and Application with J2ME - Collision Detection
Mobile Game and Application with J2ME
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
Aditazz 01-ul
ฝึกคิดเลขเร็ว ป4(2)
20091106 01
1024+ Seconds of JS Wizardry - JSConf.eu 2013
Interpolasi
Dip syntax 4
Ad

Viewers also liked (12)

PPT
W2py pyconpe
PDF
Tdd not sure if testing or developing
PDF
Python, A pílula Azul da programação
PDF
Porque aprender haskell me fez um programador python melhor?
PDF
Dados abertos ciencia_livre
PDF
Palestra Institucional PUG-PE
PDF
PyFoursquare: Python Library for Foursquare
PPTX
Pug pe vii - luciano rodrigues - debugger
PDF
Uma implementação de suporte a
PDF
Processamento de Linguagem natural com PHP
PDF
Gerando bindings de bibliotecas C++ para Python
PDF
Big Data com Python
W2py pyconpe
Tdd not sure if testing or developing
Python, A pílula Azul da programação
Porque aprender haskell me fez um programador python melhor?
Dados abertos ciencia_livre
Palestra Institucional PUG-PE
PyFoursquare: Python Library for Foursquare
Pug pe vii - luciano rodrigues - debugger
Uma implementação de suporte a
Processamento de Linguagem natural com PHP
Gerando bindings de bibliotecas C++ para Python
Big Data com Python
Ad

Similar to Python simplecv (20)

PDF
CE344L-200365-Lab5.pdf
PDF
比較明合成による流星の検出
PDF
파이썬으로 해보는 이미지 처리
PDF
러닝머신 말고 머신러닝
PDF
You are task to add a yawning detection to the programme below;i.pdf
PDF
Python Puzzlers
PPTX
Unit 6 Image processing Libraries.[pptx]
PDF
Mimstris: Building an arcade puzzle game in React / Redux
PDF
Introduction to deep learning using python
KEY
Beautiful Development ブレイクスルー体験記
PPTX
Rpartii 131126003007-phpapp01
PPTX
R part II
PDF
Functional optics
PDF
04 - Geometric Modelling para el diseño ...
DOCX
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
PDF
Ejercicio 211 del libro de baldor
KEY
openFrameworks 007 - graphics
PPTX
Intro to Python (High School) Unit #3
PDF
PDF
Palestra - Utilizando tensorflow mobile e seus desafios
CE344L-200365-Lab5.pdf
比較明合成による流星の検出
파이썬으로 해보는 이미지 처리
러닝머신 말고 머신러닝
You are task to add a yawning detection to the programme below;i.pdf
Python Puzzlers
Unit 6 Image processing Libraries.[pptx]
Mimstris: Building an arcade puzzle game in React / Redux
Introduction to deep learning using python
Beautiful Development ブレイクスルー体験記
Rpartii 131126003007-phpapp01
R part II
Functional optics
04 - Geometric Modelling para el diseño ...
circ.db.dbcircleserver(1).py#!usrlocalbinpython3im.docx
Ejercicio 211 del libro de baldor
openFrameworks 007 - graphics
Intro to Python (High School) Unit #3
Palestra - Utilizando tensorflow mobile e seus desafios

More from UFPA (8)

PDF
Evidence Briefings: Towards a Medium to Transfer Knowledge from Systematic Re...
PDF
More Common Than You Think: An In-Depth Study of Casual Contributors
PDF
What Programmers Say About Refactoring Tools? An Empirical Investigation of ...
PDF
Possibilidades com python
PDF
Are Java Programmers Transitioning to Multicore?
PPTX
Beljug2010
PDF
Grails from scratch
PDF
A computacao e_voce_caminhos_para_seguir
Evidence Briefings: Towards a Medium to Transfer Knowledge from Systematic Re...
More Common Than You Think: An In-Depth Study of Casual Contributors
What Programmers Say About Refactoring Tools? An Empirical Investigation of ...
Possibilidades com python
Are Java Programmers Transitioning to Multicore?
Beljug2010
Grails from scratch
A computacao e_voce_caminhos_para_seguir

Python simplecv