Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

video pixelation screen size

$
0
0
Hi,
I want to make an RGB LED matrix with arduino that shows whatever the camera is getting,

My first step is to have my video "pixelated",
I found an awesome example by Daniel Shiffman [Learning Processing],

But my problem is that I need a square screen to translate this to my LED matrix array, [8x8, 16x16...]

this is the code im using from exercise 16-7 video pixelation


  1. // Learning Processing
  2. // Daniel Shiffman
  3. // http://www.learningprocessing.com

  4. // Example 16-7: Video pixelation

  5. import processing.video.*;

  6. // Size of each cell in the grid, ratio of window size to video size
  7. //int videoScale = 8;

  8. int videoScale = 16; //20 columns ; 15 rows


  9. //int videoScale = 32; //20 columns ; 15 rows


  10. //int videoScale = 64; //10 columns ; 7 rows

  11. // Number of columns and rows in our system
  12. int cols, rows;
  13. // Variable to hold onto Capture object
  14. Capture video;

  15. void setup() {
  16.   size(640,480);
  17.    // size(500,500);

  18.   
  19.   // Initialize columns and rows
  20.   cols = width/videoScale;
  21.   rows = height/videoScale;
  22.   video = new Capture(this,width,height);
  23.   video.start();
  24. }

  25. void draw() {
  26.   // Read image from the camera
  27.   if (video.available()) {
  28.     video.read();
  29.   }
  30.   video.loadPixels();
  31.   
  32.   // Begin loop for columns
  33.   for (int i = 0; i < cols; i++) {
  34.     // Begin loop for rows
  35.     for (int j = 0; j < rows; j++) {
  36.       
  37.       // Where are we, pixel-wise?
  38.       int x = i*videoScale;
  39.       int y = j*videoScale;
  40.       // Looking up the appropriate color in the pixel array
  41.       color c = video.pixels[x + y*video.width];
  42.       fill(c);
  43.       stroke(0);
  44.       rect(x,y,videoScale,videoScale);
  45.     }
  46.   }
  47. }


so I need a square screen
if I use    :: size(500,500);

I get the error:

* (Processing core video:46085): WARNING **: ColorConverter: size 512000 is not a multiple of unit size 500000
So, how to fix this to have my square size screen?

Thanks!







Viewing all articles
Browse latest Browse all 1768

Trending Articles