Last active
          November 4, 2017 16:57 
        
      - 
      
- 
        Save villares/3b39c58c36d4a4c150ad2b1fba42a83b to your computer and use it in GitHub Desktop. 
    exemplo Getting Started with Capture de Processing
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** | |
| * Traduzido do exemplo Getting Started with Capture (Processing.org) | |
| * Reading and displaying an image from an attached Capture device. | |
| */ | |
| import processing.video.*; | |
| Capture cam; | |
| void setup() { | |
| size(640, 480); | |
| String[] cameras = Capture.list(); // A lista de câmeras disponíveis | |
| if (cameras == null) { | |
| println("Não rolou a lista, tentar a câmera padrão..."); | |
| cam = new Capture(this, 640, 480); | |
| } | |
| if (cameras.length == 0) { // se a lista for vazia | |
| println("Não tem nenhuma câmera disponível."); | |
| exit(); | |
| } else { | |
| println("Câmeras disponíveis:"); | |
| printArray(cameras) // mostra no console a lista | |
| // Para escolher a câmera use o índice do array (i.e. cameras[i]) ou o nome + settings | |
| // cam = new Capture(this, 640, 480, "Built-in iSight", 30); | |
| cam = new Capture(this, cameras[0]); | |
| cam.start(); // Inicia a captura | |
| } | |
| } | |
| void draw() { | |
| if (cam.available() == true) { | |
| cam.read(); | |
| } | |
| image(cam, 0, 0, width, height); // desenhando no canvas a imagem capturada | |
| // Tem uma alternativa mais rápida do que image() para mostrar cam na tela, mas não permite nenhuma manipulação: | |
| //set(0, 0, cam); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment