La capture vidéo est un outil puissant pour les artistes et les développeurs qui souhaitent créer des expériences visuelles interactives. Avec la librairie GSVideo et les librairies openGL (native) et GLGraphics, il est possible de capturer un flux vidéo et de le traiter pour créer des effets visuels intéressants. Dans cet article, nous allons examiner comment capturer un flux vidéo avec GSVideo et GLGraphics et comment le traiter pour créer des effets visuels intéressants.
Processing Capture Vidéo avec GSVideo et GLGraphics : Capture d’un flux vidéo avec la librairie GSVideo couplée aux librairies openGL (native) et GLGraphics.
Explication
- L’utilisation de la librairie GLGraphics permet de réduire l’utilisation de la CPU lors de la capture vidéo en utilisant un conteneur GLTexture pour le stockage des frames vidéos.

- Comme le montre ce graphique,
- les 4 threads de la CPU sont davantage sollicités avec GSVideo utilisée seule (moitié gauche)
- que lorsque les librairies openGL et GLGraphics sont utilisées pour la capture (moitié droite)
- Ceci est bon à savoir pour les applications nécessitant une utilisation CPU critique…
Matériel et configuration utilisés
- PC Intel Core Quad 2.33 Ghz
- Webcam(s) USB Hercules DualPix Exchange
- Ubuntu 10.04 LTS
- Processing 1-5
- Librairie GSVideo 0.9
- Librairie GLGraphics 0.99
Ressources utiles
- Librairie GSVideo
- Librairie openGL
- Librairie GLGraphics
Le programme
// All the decoding stages, until the color conversion from YUV
// to RGB are handled by gstreamer, and the video frames are
// directly transfered over to the OpenGL texture encapsulated
// by the GLTexture object.
// You need the GLGraphics library (0.99+) to use this functionality:
// http://glgraphics.sourceforge.net/
import processing.opengl.*; // librairie openGL pour Processing (librairie native)
import codeanticode.glgraphics.*; // librairie GLGraphics
import codeanticode.gsvideo.*; // librairie GS Video
GSCapture cam; // objet GSCapture = webcam
GLTexture tex; // objet GLTexture = conteneur d’image vidéo – étend PImage
void setup() {
size(320, 240, GLConstants.GLGRAPHICS); // initialisation graphique pour openGL
cam = new GSCapture(this, 640, 480); // initialise webcam
// Use texture tex as the destination for the camera pixels.
tex = new GLTexture(this); // initialise objet GLTexture
cam.setPixelDest(tex); // initialise la destination pour l’image vidéo – ici le conteneur GLTexture
cam.start(); // démarre la webcam
/*
// You can get the resolutions supported by the
// capture device using the resolutions() method.
// It must be called after creating the capture
// object.
int[][] res = cam.resolutions();
for (int i = 0; i < res.length; i++) {
println(res[i][0] + « x » + res[i][1]);
}
*/
/*
// You can also get the framerates supported by the
// capture device:
String[] fps = cam.framerates();
for (int i = 0; i < fps.length; i++) {
println(fps[i]);
}
*/
}
void captureEvent(GSCapture cam) { // est appelée lorsqu’une capture survient
cam.read(); // acquisition d’une nouvelle frame
}
void draw() {
// If there is a new frame available from the camera, the
// putPixelsIntoTexture() function will copy it to the
// video card and will return true.
if (tex.putPixelsIntoTexture()) {
//img1=tex;
image(tex, 0, 0, width, height); // le plus efficace !
//image(img1, 0, 0, width, height);
}
}
Articles Liés
- Processing Capture Vidéo : Capture d'un flux vidéo (1 webcam) avec la librairie GSVideo seule
Le traitement de la vidéo est un domaine qui a connu une croissance rapide ces…
- Processing GSVidéo : Capture simple d'un flux vidéo à 100fps avec la webcam Eye PS3
Processing GSVidéo est une application qui permet de capturer des flux vidéo à 100fps…
- GLAP-Box : Procédure : Test Matériel : Tester la capture vidéo par webcam
La GLAP-Box est un outil pratique pour tester la capture vidéo par webcam. Il permet…