Why does video.width & video.length always return same values

edited February 2017 in Raspberry PI

Hi I am writing a program which works fine on my laptop (OSX) where I am accessing the pixels from live captured video and comparing it to another pixelArray. I am now trying to get the same code to run with raspberry pi & raspberry pi camera and am using GL Video. I keep getting an arrayoutofbounds exception because the pixel array for the video is always less than the image size (always resized to screen size). What I've noticed no matter what value I choose for screen size, the video.width and video.height always return 320 & 200. Where are these values coming from?

I've a modified version of PixelArrayCapture below - the original example in the GLVideo library is linked here. https://github.com/gohai/processing-glvideo/tree/master/examples/PixelArrayCapture

import gohai.glvideo.*;
GLCapture video;

void setup() {
//  size(320, 240, P2D);
//  size(1024, 768, P3D);


  // this will use the first recognized camer
  video = new GLCapture(this);

void draw() {
  if (video.available()) {
  image(video, 0, 0, width, height);
  println(video.width, video.height, width, height);

  color center;
//  center = video.get(video.width/2, video.height/2);
//  fill(center);
//  ellipse(width/2, height/2, 125, 125);

  // alternatively, the pixel value can also be read like this:
  if (0 < video.width) {
    println("dims", video.width, video.height, width, height);
    center = video.pixels[video.height/2*video.width + video.width/2];


Sign In or Register to comment.