We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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);
fullScreen(P3D,1);
// size(1024, 768, P3D);
noStroke();
// this will use the first recognized camer
video = new GLCapture(this);
video.play();
}
void draw() {
background(0);
if (video.available()) {
video.read();
}
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) {
video.loadPixels();
println("dims", video.width, video.height, width, height);
center = video.pixels[video.height/2*video.width + video.width/2];
}
}
Answers
Check this post:
https://forum.processing.org/two/discussion/13485/how-to-use-processing-3-and-the-video-capture-library-on-raspberry-pi
Kf
@Jackieh111 The 320x240 seems to be the default resolution for the camera on OS X. Unfortunately GStreamer doesn't currently let us query the hardware capabilities on that platform, but if you know that your camera will e.g. do 1024x768, you should be able to do like this in the latest release of the GL Video library:
Thank you so much - that fixed my problem!