How do i pick the webcam i want to use in the code below. I have two webcams, one inbuilt in my laptop, and a USB webcam. I want to use the USB webcam, but I don't know how. I have heard of settings for JMyron, but I haven't been successful in implementing it. This has a serial communication with an Arduino. This is the software for an Airsoft Turret.
import JMyron.*;
import blobDetection.*;
import processing.serial.*;
Serial arduinoPort;
JMyron theMov;
PFont font;
BlobDetection target;
Blob blob;
Blob biggestBlob;
int[] screenPixels;
int[] currFrame;
int[] Background;
int tolerance = 60;
boolean revealing;
boolean manualControl = true;
float difference;
int blobWidth;
int blobHeight;
int biggestBlobArea;
int minBlobArea = 100;
boolean targetShape = true;
boolean frameDifferencing = true;
int frameDiffSpeed = 3;
int targetX;
int targetY;
int Targetx = 75;
int Targety = 80;
int fire = 0;
float xMin = 0.0; // 0.0 used for calibration. For a permanent calibration (lasts after stopping
float xMax = 180.0; // 180.0 the program) change these 4 floats to your calibrations.
float yMin = 180.0; // 180.0
float yMax = 80.0; // 93.0
String strTargetx; // used for serial sending
String strTargety; //
String strFire; //
float windowWidth = 320.0;
float windowHeight = 240.0;
float xRatio;
float yRatio;
void setup() {
size(320, 340);
theMov = new JMyron();
theMov.start(320, 240);
theMov.findGlobs(0);
theMov.update();
Background = theMov.image();
target = new BlobDetection(320, 240);
target.setThreshold(0.5);
target.setPosDiscrimination(true);
drawButtons();
arduinoPort = new Serial(this, Serial.list()[0], 9600); // start arduino communications
xRatio = (windowWidth / (xMax - xMin)); // used to allign sights with crosshairs on PC
yRatio = (windowHeight/ (yMax - yMin));
initializeManualControl();
}
void draw() {
if(manualControl) {
manualControl();
}
else{
processTargets();
}
strTargetx = "000" + str(Targetx); // make into 3-digit numbers