How do I down-sample video to large pixels and get the pixel array data which will then be output...

Ultimately I'm trying to do this:

Which is taking down-sampled web-cam footage. Sending the large pixel-block-color-information (black and white) array data over UDP (over the network) and have Cinema-4d listen to the UDP data packets with a python effector.

My immediate issue is getting the array pixel data for the large pixels (not every single individual pixel, which I think I'm getting now). I'm not sure what is being output when I use this code in the console though. Is this code sending every pixels color data in the window to the console? How do I get just the big down sampled pixel blocks? Or is it already only sending the rows/columns that have been down-sampled? I'm a little confused. This stuff is kind of over my head, but I'm trying to figure it out. Any help would be appreciated.

Here's more info on what I'm trying to do and what my immediate issue is: I'm trying to print the large pixel values every frame (eventually I'd like to only have black and white values but I haven't gotten that far). I'm not too sure how exactly Processing 3.3.6 is interpreting this code. Or if this is the wrong way to go about getting the pixel array data clean enough to send to another program and interpret. I'm just hacking code together right now like a maniac. I finally got pixel output in the console (I think), though I don't know what the output actually means. It looks like Java (hex info?), but I don't really know exactly.

I'm getting print data like this: [I@8e9278b[I@8e9278b[I@8e9278b[I@8e9278b[I@8e9278b[I@8e9278...


// Size of each cell in the grid, ratio of window size to video size
//Screen Pixels are 80 width and 60 height in the case of 640/480
int videoScale = 8;
// Number of columns and rows in the system
int cols, rows;
// Variable to hold onto Capture object
Capture video;

void setup() {  
  size(640, 480);  
  // 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++) {      
      // Where are you, pixel-wise?      
      int x = i*videoScale;      
      int y = j*videoScale;
      color c = video.pixels[i + j*video.width];
      rect(x, y, videoScale, videoScale);

      //Experiment code for capturing video pixel color data so far:
      //I'm not sure I need this get() - taking it out still sends data to console.


  • edited December 2017

    Please don't post duplicates

    Print () omits the newline so it'll run the data from each frame together


    This is the standard way of showing an array (the [) of integers (the I). It's basically the address of the start of the array. And utterly useless. You'd have to iterate over the array and print the individual pixels to make more sense of it.

    But, I warn you, that much data won't make much sense either, it's just a flood, hundreds of values 60 times a second.

  • Ok that's helpful. The only reason why I'm printing the pixel array color data (or trying) is just to make sure I can get that information. Then I need to figure out how to interpret it on the other end after I send it out of Processing across the network. Do you know if what is being printed are the values of the "large" pixels or do you suppose it's printing every individual pixel and I'm getting many values of the same "big" pixel. I'm trying to boil the pixel color data down to a manageable size with the down-sampling of the video into larger pixel blocks.

  • As I've said is the address of the start of the array, not the contents of the array. That's why it's always the same - the array doesn't move.

    Read the tutorial on colours, it covers this stuff.

Sign In or Register to comment.