# How to use SPOUT input with 11.10: Computer Vision: Adding Lifespan to Blobs - Processing Tutorial

**URL:** <https://discourse.processing.org/t/how-to-use-spout-input-with-11-10-computer-vision-adding-lifespan-to-blobs-processing-tutorial/40735>\
**Category:** Libraries\
**Created:** [January 29, 2023, 9:59am UTC](https://discourse.processing.org/t/how-to-use-spout-input-with-11-10-computer-vision-adding-lifespan-to-blobs-processing-tutorial/40735 "2023-01-29T09:59:18Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 29, 2023, 9:21pm UTC](https://discourse.processing.org/t/how-to-use-spout-input-with-11-10-computer-vision-adding-lifespan-to-blobs-processing-tutorial/40735/7 "2023-01-29T21:21:54Z")

</div>

> [@marijn](#):
>
> But I don’t know how to convert the Spout texture input, to a video format like Capture()  
> So that it can be used with functions like GetPixels() and other functions that are used in the blobtracking example.

Hello @marijn,

I thought I would take this out for a spin!

Steps:

- Installed latest _TouchDesigner_ and used the default example and changed output to _TDSSyphonSpoutOut_
- Modified the _SpoutDataReceiver_ example that comes with Spout library added to Processing. Partial code below… I only included setup() and draw().

```auto
// GLV Edit of SpoutDataReceiver in Examples
// 2023-01-29

//
// SpoutDataReceiver
//
// Receive texture and data from a Spout sender
//
// Spout 2.007
// https://spout.zeal.co
//

// IMPORT THE SPOUT LIBRARY
import spout.*;

PImage pgr, pgr1; // Canvas to receive a texture

// DECLARE A SPOUT OBJECT
Spout spout;

void setup()
  {
  // Initial window size
  size(640, 360, P3D);
  
  pgr1 = createImage(width, height, RGB);
  
  // Screen text size
  textSize(16);
  
  // CREATE A NEW SPOUT OBJECT
  spout = new Spout(this);

  frameRate(30.0);
  } 

int count = 0;

void draw() 
  { 
  background(0);  
  //
  // RECEIVE FROM A SENDER
  //
  
  if(spout.receiveTexture()) 
    {        
    pgr = spout.receiveTexture(pgr);
    
    if(pgr != null)
      {
      //image(pgr, 0, 0);  
      imageProcess1();     
      
      showInfo();
      count++;
      }   
    }
  println(frameCount, count); //Check to see if synched 
  }
  
void imageProcess1()
  {
  // Works!  
  //image(pgr, 0, 0);
  //pgr1 = get(); // copy sketch window to pgr1
  
  // Works
  image(pgr, 0, 0);
  loadPixels(); //Required!
  arrayCopy(pixels, pgr1.pixels); // Makes a copy to work with
  
  // Fast and efficient for accessing x, y locations in pixel array
  for(int y=0; y<pgr1.height; y++)
    {
    int tmp = y*pgr1.width;  
    for(int x=0; x<pgr1.width; x++)  
      {
      int loc = x + tmp;
      if (y>height/2)
        {
        if (brightness(pgr1.pixels[loc]) < 128)
          pgr1.pixels[loc] = 0xFFFFFFFF;
        }  
      }
    }
    
  // Efficient for pixel array access
  //for(int i=0; i<pgr1.pixels.length; i++)
  // {
  // if (brightness(pgr1.pixels[i]) < 128)
  // pgr1.pixels[i] = 0xFFFFFFFF;
  // }  
  
  pgr1.updatePixels(); // Required! 
  image(pgr1, width/2, 0);
  }

```

And voila!

Left is spout data received.  
Right is image processed… see code for details.

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/a/9/a9823f0ca48395b0ed7ca08577956594ee7ee190.jpeg)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/4/7443f42dcec05942fef40922ff390cf06ff706d8.png)

Thanks for this topic! I had fun with this.

References:  
[https://processing.org/tutorials/pixels](https://processing.org/tutorials/pixels)

`:)`

---

_[View the full topic](https://discourse.processing.org/t/how-to-use-spout-input-with-11-10-computer-vision-adding-lifespan-to-blobs-processing-tutorial/40735)._
