Fullframe Video Capture

edited November 2017 in Library Questions

Does anyone know how to get this video capture code working at fullScreen( )? When I change it to full screen it does not work at all and I know it is based on the fact this code was written for a specific size and a lot is based on that size.

This is a modification of Daniel Shiffman's Video - Software Mirrors code. https://processing.org/tutorials/video/


import processing.video.*;

// Size of each cell in the grid, ratio of window size to video size
int videoScale = 20;

// Number of columns and rows in the system
int cols, rows;

// Variable to hold onto Capture object
Capture video;

// used for the noise randomness
float xoff = 0.0;
float yoff = 0.0;
float coff = 0.0;

void setup() {  
  size(1280, 720); 
  //fullScreen( );

  // Initialize columns and rows  
  cols = width/videoScale;  
  rows = height/videoScale;  
  video = new Capture(this, cols, rows);

// Read image from the camera
void captureEvent(Capture video) {  

void draw() {

  // Begin loop for columns  
  for (int i = 0; i < cols; i++) {    
    // Begin loop for rows    
    for (int j = 0; j < rows; j++) {            
      int x = i*videoScale;      
      int y = j*videoScale;
      color c = video.pixels[i + j*video.width];


      //rotate the rect
      xoff = xoff + .01;
      float n = noise(xoff) * width;
      pushMatrix( );
      translate(x + videoScale/2, y + videoScale/2);
      rotate(radians(45 + n));
      translate(-(x + videoScale/2), -(y + videoScale/2));

      // draw the rect with the video color
      rect(x, y, videoScale/1.9, videoScale/1.9); 
      popMatrix( );


  • When I change it to full screen it does not work at all

    Can you add more details? Do you get an error by any chance? Are you familiar with Capture.list()?


  • It works great at size(1280, 720) but if you comment that out and use fullSCreen( ) then it is just black. width and height both are divided by videoScale which I realize would result in a float being returned at the new fullSCreen resolution and it is expecting an int. But the error is not that. I get the error: (Processing core video:3479): GStreamer-CRITICAL **: Trying to dispose element Video Capture, but it is in PAUSED instead of the NULL state. You need to explicitly set elements to the NULL state before dropping the final reference, to allow them to clean up. This problem may also be caused by a refcounting bug in the application or some element.

  • I did use Capture.list() initially but got rid of it later once I verified that my camera was available and it worked fine without seeking this information from the system.

  • Do you get that same error line when working with the working version of the sketch? (aka no when running at fulScreen?) Then, it is probly not an error but a warning. I said to use Capture.list because you define your Capture object based on your screen resolution. You need to make sure the screen resolution defined in the constructor is available in your device. If you have verified that, then it is hard to figure what else the problem could be... at least from this side.

    A possible solution is to get the Capture working with 1280 x 720 resolution and then display the video using the image() function with 5 parameters. Please check the reference.


  • It works fine at 1280 x 720. That screen resolution is available in my camera device. I need it to be full screen and my computer does not have 1280 x 720 as an option on its display in the System Preferences. Its a strange resolution but the best one to to fill the space (I am projecting this) is 1366 x 768. But that is irrelevant. Basically I know that I must capture the image at the resolution of the capture device. It works fine when I do. When I put it in fullscreen mode, it does not work at all because the screen resolution has changed and the new Capture gets sent the width and height of the fullscreen and it does not like that. So basically I need to know how to resize the whole window to fullscreen (scale it up) without affecting the width and height variable. Is there a way to do this?

  • Answer ✓

    Thanks kfrajer for your suggestions, they got me thinking. I solved it. I just replaced:

     cols = width/videoScale;  
     rows = height/videoScale;  


     cols = 1280/videoScale;  
     rows = 720/videoScale;  

    and then added:


    to my draw( )

    The basic problem was that the Capture device was getting a width and height it could not deal with when I went into fullScreen( ). So by using the literal sizes I wanted instead of getting the width and height from the screen size, it stopped complaining and works great.

Sign In or Register to comment.