Webcam in Array
in
Contributed Library Questions
•
9 months ago
I am trying to integrate a webcam display into my application.
My application runs videos, and through OSCulator and GSVideo commands of a wii remote it controls a video switch through arrays. This works! However I am now wanting another (new) button to open up the webcam in the display, I got this example from the GettingStartedCapture which simply displays a webcam, but I'm wanting to place this into my project.
I know I have mentioned those contributed libraries above, but please don't be put off by them, as this is a processing issue I am having trouble with regarding the 'voids' and 'arrays' etc.
Pleeeeease help!
Here's the two sections of code, the first is the capture example that I am trying to put in my project, the second lot of code is my own code with the video switch arrays.
Thanks guys
WEBCAM CAPTURE
- import processing.video.*;
- Capture cam;
- void setup() {
size(1280, 720, P2D); - String[] cameras = Capture.list();
cam = new Capture(this, cameras[0]);
cam.start();
}
void draw() {
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0, 1280, 900);
}
MY PROJECT CODE
- import codeanticode.gsvideo.*; // import GSvideo Library
import oscP5.*; // import oscP5 Library
import netP5.*; // import netP5 Library (part of oscP5 Library) - OscP5 osculator;
GSMovie player; - //global variables
int direction;
int currentScreen; - //Arrays for pages of videos
final static byte Up = 1;
final static byte Down = 2;
final static byte number2 = 3; - byte videoButton;
public void setup() {
size(1280, 720, P2D);
background(0);- osculator = new OscP5(this, 9000);
osculator.plug(this, "buttonUp", "/wii/1/button/Up");
osculator.plug(this, "buttonDown", "/wii/1/button/Down");
osculator.plug(this, "button2", "/wii/1/button/2"); - //GSVideo Set-up
player = new GSMovie(this, "HelpScreenVideo.mov");
player.loop();
} - void draw() {
image(player, 0, 0, width, height);
} - //Voids for the switch of videos
void buttonUp (float press) {
if (press != 0 && videoButton != Up) {
player = new GSMovie(this, "ValveSoundsystem.mov");
videoButton = Up;
}
}- void buttonDown (float press) {
if (press != 0 && videoButton != Down) {
player = new GSMovie(this, "MarcusWedgewood.mov");
videoButton = Down;
}
} - void button2 (float press) {
if (press != 0 && videoButton != number2) {
//player = new GSMovie(this, "HelpScreenVideo.mov");
//NEW//
cam = new Capture(this, cameras[0]);// ????
cam.start();// ????
//
videoButton = number2;
}
}
1