Hi community,
I’m quite used to Java, however I’m starting with Processing.
My aim is to make a realtime slit-scan effect, with the Pi camera (V2) and RPi3.
The following code is working, and I’m yet impressed by the Processing ability to generate a quite constant frame-rate.
Ideally I would like to achive the high frame rate ability of the camera module V2, around 120/180 fps. So my question is in two part.
First, do we have the possibility to change other settings of the camera, such as shutter speed, iso ?
And secondly:
This code is working at about 20fps. It relies on the PImage.copy() method to store the large rotating image buffer and rebuild the time scanned output image.
Is there a better - more efficient strategy for the buffer and reconstruction ?
Thanks a lot, and if Processing team reads this: kudos for this nice job!
import gohai.glvideo.*;
GLCapture video;
PImage img[];
int imgIndex = 0;
PImage imgDest;
void setup() {
size(256, 256, P2D); // Important to note the renderer
// Get the list of cameras connected to the Pi
String[] devices = GLCapture.list();
println("Devices:");
printArray(devices);
// Get the resolutions and framerates supported by the first camera
if (0 < devices.length) {
String[] configs = GLCapture.configs(devices[0]);
println("Configs:");
printArray(configs);
}
// this will use the first recognized camera by default
//video = new GLCapture(this);
// you could be more specific also, e.g.
//video = new GLCapture(this, devices[0]);
video = new GLCapture(this, devices[0], 256, 256, 90);
//video = new GLCapture(this, devices[0], configs[0]);
img = new PImage[256];
imgDest = createImage(256, 256, RGB);
for (int j = 0; j < img.length; j++) {
img[j] = createImage(256, 256, RGB);
}
video.start();
}
void draw() {
background(0);
// If the camera is sending new data, capture that data
if (video.available()) {
video.read();
img[imgIndex%256].copy(video, 0,0,256,256,0,0,256,256);
for(int i=0; i<256; i++){
imgDest.copy(img[(imgIndex + i)%256], i, 0, 1, 256, i, 0, 1, 256);
}
imgIndex++;
}
image(imgDest, 0, 0, 256, 256);
}