More gamepad based things, and a couple of ways to filter the vector results.

This commit is contained in:
Sandy Noble 2013-03-31 18:25:21 +01:00
parent f81386f61c
commit fe828d01d8
7 changed files with 320 additions and 170 deletions

View File

@ -430,17 +430,20 @@ class DisplayMachine extends Machine
{
for(int i = 0; i<pointPaths.length; i++)
{
if (pointPaths[i] != null)
if (pointPaths[i].length >= pathLengthHighPassCutoff)
{
beginShape();
for (int j = 0; j<pointPaths[i].length; j++)
if (pointPaths[i] != null)
{
PVector p = new PVector(pointPaths[i][j].x, pointPaths[i][j].y);
p = PVector.mult(p, scaler);
p = PVector.add(p, position);
vertex(p.x, p.y);
beginShape();
for (int j = 0; j<pointPaths[i].length; j++)
{
PVector p = new PVector(pointPaths[i][j].x, pointPaths[i][j].y);
p = PVector.mult(p, scaler);
p = PVector.add(p, position);
vertex(p.x, p.y);
}
endShape();
}
endShape();
}
}
}

View File

@ -132,14 +132,26 @@ void button_mode_liveAddCaption()
{
}
void numberbox_mode_vectorPathLengthHighPassCutoff(int value)
{
pathLengthHighPassCutoff = value;
}
void button_mode_liveConfirmDraw()
{
// work out scaling and position
float scaling = getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getWidth()) / captureShape.getWidth();
PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().x), getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().y) + (captureShape.getHeight() * scaling));
sendVectorShapes(captureShape, scaling, position);
if (captureShape != null)
{
// save shape as SVG
// work out scaling and position
float scaling = getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getWidth()) / captureShape.getWidth();
PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().x), getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().y) + (captureShape.getHeight() * scaling));
sendVectorShapes(captureShape, scaling, position);
button_mode_penUp();
}
}

View File

@ -474,15 +474,15 @@ Map<String, Controller> initialiseNumberboxValues(Map<String, Controller> map)
n.setDecimalPrecision(1);
n.setValue(blurValue);
n.setMin(1);
n.setMax(100);
n.setMax(10);
n.setMultiplier(0.1);
}
else if (MODE_LIVE_SIMPLIFICATION_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(liveSimplification);
n.setMin(0);
n.setMax(360);
n.setMin(LIVE_SIMPLIFICATION_MIN);
n.setMax(LIVE_SIMPLIFICATION_MAX);
n.setMultiplier(0.1);
}
else if (MODE_LIVE_POSTERISE_VALUE.equals(key))
@ -493,6 +493,14 @@ Map<String, Controller> initialiseNumberboxValues(Map<String, Controller> map)
n.setMax(32);
n.setMultiplier(0.1);
}
else if (MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(pathLengthHighPassCutoff);
n.setMin(0);
n.setMax(10000);
n.setMultiplier(0.5);
}
}
}
return map;
@ -663,6 +671,7 @@ List<String> getControlNamesForInputPanel()
controlNames.add(MODE_RESIZE_VECTOR);
controlNames.add(MODE_MOVE_VECTOR);
controlNames.add(MODE_CHANGE_MIN_VECTOR_LINE_LENGTH);
controlNames.add(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF);
controlNames.add(MODE_RENDER_VECTORS);
controlNames.add(MODE_SHOW_IMAGE);
@ -706,6 +715,7 @@ List<String> getControlNamesForWebcamPanel()
controlNames.add(MODE_LIVE_CANCEL_CAPTURE);
controlNames.add(MODE_LIVE_ADD_CAPTION);
controlNames.add(MODE_LIVE_CONFIRM_DRAW);
controlNames.add(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF);
return controlNames;
}
@ -911,6 +921,8 @@ Map<String, String> buildControlLabels()
result.put(MODE_LIVE_CANCEL_CAPTURE, "Cancel capture");
result.put(MODE_LIVE_ADD_CAPTION, "Add caption");
result.put(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF, "Path length cutoff");
return result;
}
@ -1043,6 +1055,7 @@ Set<String> buildControlNames()
result.add(MODE_LIVE_CONFIRM_DRAW);
result.add(MODE_LIVE_CANCEL_CAPTURE);
result.add(MODE_LIVE_ADD_CAPTION);
result.add(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF);
return result;
}

View File

@ -649,7 +649,7 @@ void sendVectorShapes(RShape vec, float scaling, PVector position)
RPoint[][] pointPaths = vec.getPointsInPaths();
// sort the paths to optimise the draw sequence
pointPaths = sortPathLongestFirst(pointPaths);
pointPaths = sortPathLongestFirst(pointPaths, pathLengthHighPassCutoff);
String command = "";
PVector lastPoint = new PVector();
@ -662,43 +662,47 @@ void sendVectorShapes(RShape vec, float scaling, PVector position)
{
boolean firstPointFound = false;
List<PVector> filteredPoints = filterPoints(pointPaths[i], VECTOR_FILTER_LOW_PASS, minimumVectorLineLength, scaling, position);
//println(filteredPoints);
if (!filteredPoints.isEmpty())
if (pointPaths[i].length > pathLengthHighPassCutoff)
{
// draw the first one with a pen up and down to get to it
PVector p = filteredPoints.get(0);
if ( p.x == lastPoint.x && p.y == lastPoint.y )
liftToGetToNewPoint = false;
else
liftToGetToNewPoint = true;
// pen UP! (IF THE NEW POINT IS DIFFERENT FROM THE LAST ONE!)
if (liftToGetToNewPoint)
addToCommandQueue(CMD_PENUP+"END");
// move to this point and put the pen down
command = CMD_CHANGELENGTHDIRECT+(int)p.x+","+(int)p.y+","+getMaxSegmentLength()+",END";
addToCommandQueue(command);
if (liftToGetToNewPoint)
addToCommandQueue(CMD_PENDOWN+"END");
// then just iterate through the rest
for (int j=1; j<filteredPoints.size(); j++)
List<PVector> filteredPoints = filterPoints(pointPaths[i], VECTOR_FILTER_LOW_PASS, minimumVectorLineLength, scaling, position);
//println(filteredPoints);
if (!filteredPoints.isEmpty())
{
p = filteredPoints.get(j);
// draw the first one with a pen up and down to get to it
PVector p = filteredPoints.get(0);
if ( p.x == lastPoint.x && p.y == lastPoint.y )
liftToGetToNewPoint = false;
else
liftToGetToNewPoint = true;
// pen UP! (IF THE NEW POINT IS DIFFERENT FROM THE LAST ONE!)
if (liftToGetToNewPoint)
addToCommandQueue(CMD_PENUP+"END");
// move to this point and put the pen down
command = CMD_CHANGELENGTHDIRECT+(int)p.x+","+(int)p.y+","+getMaxSegmentLength()+",END";
addToCommandQueue(command);
addToCommandQueue(command);
if (liftToGetToNewPoint)
addToCommandQueue(CMD_PENDOWN+"END");
// then just iterate through the rest
for (int j=1; j<filteredPoints.size(); j++)
{
p = filteredPoints.get(j);
command = CMD_CHANGELENGTHDIRECT+(int)p.x+","+(int)p.y+","+getMaxSegmentLength()+",END";
addToCommandQueue(command);
}
lastPoint = new PVector(p.x,p.y);
}
lastPoint = new PVector(p.x,p.y);
}
}
}
println("finished.");
}
public RPoint[][] sortPathLongestFirst(RPoint[][] pointPaths)
public RPoint[][] sortPathLongestFirst(RPoint[][] pointPaths, int highPassCutoff)
{
// put the paths into a list
List<RPoint[]> pathsList = new ArrayList<RPoint[]>(pointPaths.length);
@ -710,7 +714,6 @@ public RPoint[][] sortPathLongestFirst(RPoint[][] pointPaths)
}
}
println("PathsList: ");
for (RPoint[] path : pathsList)
println(path.length + ", ");
@ -726,18 +729,35 @@ public RPoint[][] sortPathLongestFirst(RPoint[][] pointPaths)
}
}
});
// filter out some short paths
pathsList = removeShortPaths(pathsList, highPassCutoff);
println("Sorted PathsList: ");
for (RPoint[] path : pathsList)
println(path.length + ", ");
// and put them into a new array
for (int i=0; i<pathsList.size(); i++)
{
pointPaths[i] = pathsList.get(i);
}
return pointPaths;
}
List<RPoint[]> removeShortPaths(List<RPoint[]> list, int cutoff)
{
if (cutoff > 0)
{
int numberOfPaths = list.size();
for (int i=0; i<numberOfPaths; i++)
{
if (cutoff >= list.get(i).length)
{
list.remove(i);
}
}
}
return list;
}
List<PVector> filterPoints(RPoint[] points, int filterToUse, long filterParam, float scaling, PVector position)
{
return filterPointsLowPass(points, filterParam, scaling, position);

View File

@ -1,31 +1,113 @@
ControllIO controllIO;
ControllDevice joypad;
ControllCoolieHat cooliehat;
ControllStick leftStick;
ControllStick rightStick;
ControllButton buttonA;
ControllButton buttonB;
ControllButton buttonX;
ControllButton buttonY;
ControllCoolieHat dpad;
String inputDeviceName = "Controller (Xbox 360 Wireless Receiver for Windows)";
String signalFromGamepad = null;
static final String BUTTON_A_RELEASED = "ButtonAReleased";
static final String BUTTON_B_RELEASED = "ButtonBReleased";
void gamepad_init()
{
controllIO = ControllIO.getInstance(this);
joypad = controllIO.getDevice("Controller (Xbox 360 Wireless Receiver for Windows)");
joypad.printButtons();
buttonA = joypad.getButton("Button 0");
buttonB = joypad.getButton("Button 1");
buttonX = joypad.getButton("Button 2");
buttonY = joypad.getButton("Button 3");
try
{
joypad = controllIO.getDevice(inputDeviceName);
joypad.printButtons();
buttonA.plug(this, "buttonARelease", ControllIO.ON_RELEASE);
buttonA = joypad.getButton("Button 0");
buttonB = joypad.getButton("Button 1");
buttonX = joypad.getButton("Button 2");
buttonY = joypad.getButton("Button 3");
buttonA.plug(this, "buttonARelease", ControllIO.ON_RELEASE);
buttonB.plug(this, "buttonBRelease", ControllIO.ON_RELEASE);
buttonX.plug(this, "buttonXPress", ControllIO.ON_PRESS);
buttonX.plug(this, "buttonXRelease", ControllIO.ON_RELEASE);
buttonY.plug(this, "buttonYRelease", ControllIO.ON_RELEASE);
dpad = joypad.getCoolieHat(10);
dpad.setMultiplier(4);
dpad.plug(this, "dpadPress", ControllIO.ON_PRESS);
}
catch (RuntimeException e)
{
println("Requested device (" + inputDeviceName + ") not found.");
}
}
void buttonARelease()
public void buttonARelease()
{
button_mode_liveCaptureFromLive();
signalFromGamepad = BUTTON_A_RELEASED;
}
public void buttonBRelease()
{
signalFromGamepad = BUTTON_B_RELEASED;
}
void buttonXPress()
{
drawingLiveVideo = true;
}
void buttonXRelease()
{
drawingLiveVideo = false;
}
void buttonYRelease()
{
flipWebcamImage = !flipWebcamImage;
}
void dpadPress(float x, float y)
{
println("VAl:" + dpad.getValue());
float val = dpad.getValue();
if (val == 2.0)
{
liveSimplification--;
if (liveSimplification < LIVE_SIMPLIFICATION_MIN)
liveSimplification = LIVE_SIMPLIFICATION_MIN;
}
else if (val == 6.0)
{
liveSimplification++;
if (liveSimplification > LIVE_SIMPLIFICATION_MAX)
liveSimplification = LIVE_SIMPLIFICATION_MAX;
}
Numberbox n = (Numberbox) getAllControls().get(MODE_LIVE_SIMPLIFICATION_VALUE);
n.setValue(liveSimplification);
n.update();
}
void processGamepadInput()
{
if (signalFromGamepad != null)
{
if (signalFromGamepad == BUTTON_A_RELEASED)
if (captureShape == null)
button_mode_liveCaptureFromLive();
else
button_mode_liveClearCapture();
else if (signalFromGamepad == BUTTON_B_RELEASED)
button_mode_liveConfirmDraw();
// clear the signal
signalFromGamepad = null;
}
}

View File

@ -111,6 +111,8 @@ Serial myPort; // The serial port
int[] serialInArray = new int[1]; // Where we'll put what we receive
int serialCount = 0; // A count of how many bytes we receive
boolean[] keys = new boolean[526];
final JFileChooser chooser = new JFileChooser();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy hh:mm:ss");
@ -317,6 +319,8 @@ static final String MODE_LIVE_CANCEL_CAPTURE = "button_mode_liveClearCapture";
static final String MODE_LIVE_ADD_CAPTION = "button_mode_liveAddCaption";
static final String MODE_LIVE_CONFIRM_DRAW = "button_mode_liveConfirmDraw";
static final String MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF = "numberbox_mode_vectorPathLengthHighPassCutoff";
PVector statusTextPosition = new PVector(300.0, 12.0);
@ -463,6 +467,11 @@ static PImage processedLiveImage = null;
static PImage capturedImage = null;
static PImage processedCapturedImage = null;
static final Integer LIVE_SIMPLIFICATION_MIN = 1;
static final Integer LIVE_SIMPLIFICATION_MAX = 32;
static int pathLengthHighPassCutoff = 100;
JMyron liveCamera;
BlobDetector blob_detector;
int liveSimplification = 4;
@ -818,8 +827,11 @@ void drawWebcamPage()
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
showCommandQueue((int) width-200, 20);
processGamepadInput();
}
void drawCommandQueuePage()
{
cursor(ARROW);
@ -1318,41 +1330,44 @@ void changeMachineScaling(int delta)
}
}
boolean checkKey(int k)
{
if (keys.length >= k) {
return keys[k];
}
return false;
}
void keyReleased()
{
keys[keyCode] = false;
}
void keyPressed()
{
if (key == CODED)
{
// set key to zero (or something besides the ESC).
if (keyCode == java.awt.event.KeyEvent.VK_PAGE_UP)
{
changeMachineScaling(1);
}
else if (keyCode == java.awt.event.KeyEvent.VK_PAGE_DOWN)
{
changeMachineScaling(-1);
}
else if (keyCode == DOWN)
{
getDisplayMachine().getOffset().y = getDisplayMachine().getOffset().y + 10;
}
else if (keyCode == UP)
{
getDisplayMachine().getOffset().y = getDisplayMachine().getOffset().y - 10;
}
else if (keyCode == RIGHT)
{
getDisplayMachine().getOffset().x = getDisplayMachine().getOffset().x + 10;
}
else if (keyCode == LEFT)
{
getDisplayMachine().getOffset().x = getDisplayMachine().getOffset().x - 10;
}
}
else if (key == java.awt.event.KeyEvent.VK_ESCAPE)
{
keys[keyCode] = true;
println(KeyEvent.getKeyText(keyCode));
if (checkKey(CONTROL) && checkKey(KeyEvent.VK_PAGE_UP))
changeMachineScaling(1);
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_PAGE_DOWN))
changeMachineScaling(-1);
else if (checkKey(CONTROL) && checkKey(DOWN))
getDisplayMachine().getOffset().y = getDisplayMachine().getOffset().y + 10;
else if (checkKey(CONTROL) && checkKey(UP))
getDisplayMachine().getOffset().y = getDisplayMachine().getOffset().y - 10;
else if (checkKey(CONTROL) && checkKey(RIGHT))
getDisplayMachine().getOffset().x = getDisplayMachine().getOffset().x + 10;
else if (checkKey(CONTROL) && checkKey(LEFT))
getDisplayMachine().getOffset().x = getDisplayMachine().getOffset().x - 10;
else if (checkKey(KeyEvent.VK_ESCAPE))
key = 0;
}
else if (key == 'g' || key == 'G')
// if (checkKey(CONTROL) && checkKey(KeyEvent.VK_G))
// println("CTRL+G");
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_G))
{
Toggle t = (Toggle) getAllControls().get(MODE_SHOW_GUIDES);
if (displayingGuides)
@ -1367,7 +1382,7 @@ void keyPressed()
}
t.update();
}
else if (key == 'c' || key == 'C')
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_C))
{
if (isUseWindowedConsole())
setUseWindowedConsole(false);
@ -1376,70 +1391,69 @@ void keyPressed()
initLogging();
}
else if (key == 's' || key == 'S')
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_S))
{
if (getDisplayMachine().pixelsCanBeExtracted() && isBoxSpecified())
displayingSelectedCentres = (displayingSelectedCentres) ? false : true;
}
else if (key == 'i' || key == 'I')
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_I))
{
println("I pressed!.");
displayingInfoTextOnInputPage = (displayingInfoTextOnInputPage) ? false : true;
}
else if (key == '+')
{
currentMachineMaxSpeed = currentMachineMaxSpeed+MACHINE_MAXSPEED_INCREMENT;
currentMachineMaxSpeed = Math.round(currentMachineMaxSpeed*100.0)/100.0;
NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern("###.##");
addToRealtimeCommandQueue(CMD_SETMOTORSPEED+df.format(currentMachineMaxSpeed)+",END");
}
else if (key == '-')
{
currentMachineMaxSpeed = currentMachineMaxSpeed+(0.0 - MACHINE_MAXSPEED_INCREMENT);
currentMachineMaxSpeed = Math.round(currentMachineMaxSpeed*100.0)/100.0;
NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern("###.##");
addToRealtimeCommandQueue(CMD_SETMOTORSPEED+df.format(currentMachineMaxSpeed)+",END");
}
else if (key == '*')
{
currentMachineAccel = currentMachineAccel+MACHINE_ACCEL_INCREMENT;
currentMachineAccel = Math.round(currentMachineAccel*100.0)/100.0;
NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern("###.##");
addToRealtimeCommandQueue(CMD_SETMOTORACCEL+df.format(currentMachineAccel)+",END");
}
else if (key == '/')
{
currentMachineAccel = currentMachineAccel+(0.0 - MACHINE_ACCEL_INCREMENT);
currentMachineAccel = Math.round(currentMachineAccel*100.0)/100.0;
NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern("###.##");
addToRealtimeCommandQueue(CMD_SETMOTORACCEL+df.format(currentMachineAccel)+",END");
}
else if (key == ']')
{
currentPenWidth = currentPenWidth+penIncrement;
currentPenWidth = Math.round(currentPenWidth*100.0)/100.0;
NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern("###.##");
addToRealtimeCommandQueue(CMD_CHANGEPENWIDTH+df.format(currentPenWidth)+",END");
}
else if (key == '[')
{
currentPenWidth = currentPenWidth-penIncrement;
currentPenWidth = Math.round(currentPenWidth*100.0)/100.0;
NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern("###.##");
addToRealtimeCommandQueue(CMD_CHANGEPENWIDTH+df.format(currentPenWidth)+",END");
}
// else if (key == '+')
// {
// currentMachineMaxSpeed = currentMachineMaxSpeed+MACHINE_MAXSPEED_INCREMENT;
// currentMachineMaxSpeed = Math.round(currentMachineMaxSpeed*100.0)/100.0;
// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
// DecimalFormat df = (DecimalFormat)nf;
// df.applyPattern("###.##");
// addToRealtimeCommandQueue(CMD_SETMOTORSPEED+df.format(currentMachineMaxSpeed)+",END");
// }
// else if (key == '-')
// {
// currentMachineMaxSpeed = currentMachineMaxSpeed+(0.0 - MACHINE_MAXSPEED_INCREMENT);
// currentMachineMaxSpeed = Math.round(currentMachineMaxSpeed*100.0)/100.0;
// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
// DecimalFormat df = (DecimalFormat)nf;
// df.applyPattern("###.##");
// addToRealtimeCommandQueue(CMD_SETMOTORSPEED+df.format(currentMachineMaxSpeed)+",END");
// }
// else if (key == '*')
// {
// currentMachineAccel = currentMachineAccel+MACHINE_ACCEL_INCREMENT;
// currentMachineAccel = Math.round(currentMachineAccel*100.0)/100.0;
// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
// DecimalFormat df = (DecimalFormat)nf;
// df.applyPattern("###.##");
// addToRealtimeCommandQueue(CMD_SETMOTORACCEL+df.format(currentMachineAccel)+",END");
// }
// else if (key == '/')
// {
// currentMachineAccel = currentMachineAccel+(0.0 - MACHINE_ACCEL_INCREMENT);
// currentMachineAccel = Math.round(currentMachineAccel*100.0)/100.0;
// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
// DecimalFormat df = (DecimalFormat)nf;
// df.applyPattern("###.##");
// addToRealtimeCommandQueue(CMD_SETMOTORACCEL+df.format(currentMachineAccel)+",END");
// }
// else if (key == ']')
// {
// currentPenWidth = currentPenWidth+penIncrement;
// currentPenWidth = Math.round(currentPenWidth*100.0)/100.0;
// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
// DecimalFormat df = (DecimalFormat)nf;
// df.applyPattern("###.##");
// addToRealtimeCommandQueue(CMD_CHANGEPENWIDTH+df.format(currentPenWidth)+",END");
// }
// else if (key == '[')
// {
// currentPenWidth = currentPenWidth-penIncrement;
// currentPenWidth = Math.round(currentPenWidth*100.0)/100.0;
// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
// DecimalFormat df = (DecimalFormat)nf;
// df.applyPattern("###.##");
// addToRealtimeCommandQueue(CMD_CHANGEPENWIDTH+df.format(currentPenWidth)+",END");
// }
else if (key == '#' )
{
addToRealtimeCommandQueue(CMD_PENUP+"END");
@ -1457,15 +1471,15 @@ void keyPressed()
{
this.maxSegmentLength++;
}
else if (key == ',')
{
if (this.minimumVectorLineLength > 0)
this.minimumVectorLineLength--;
}
else if (key == '.')
{
this.minimumVectorLineLength++;
}
// else if (key == ',')
// {
// if (this.minimumVectorLineLength > 0)
// this.minimumVectorLineLength--;
// }
// else if (key == '.')
// {
// this.minimumVectorLineLength++;
// }
}
void mouseDragged()
{

View File

@ -1,15 +1,15 @@
public PImage webcam_buildLiveImage()
{
liveCamera.update();
PImage pimg = createImage(640,480, RGB);
PImage pimg = createImage(640, 480, RGB);
pimg.loadPixels();
pimg.pixels = liveCamera.image();
// flip the image left to right
if (flipWebcamImage)
{
List<int[]> list = new ArrayList<int[]>(480);
for (int r=0; r<pimg.pixels.length; r+=640)
{
int[] temp = new int[640];
@ -19,10 +19,10 @@ public PImage webcam_buildLiveImage()
}
list.add(temp);
}
// reverse the list
Collections.reverse(list);
for (int r=0; r<list.size(); r++)
{
for (int c=0; c<640; c++)
@ -132,7 +132,7 @@ Map<Integer, PImage> webcam_buildSeps(PImage img, Integer keyColour)
Integer pixel = img.pixels[i];
seps.get(pixel).pixels[i] = keyColour;
}
return seps;
}
@ -153,15 +153,21 @@ RShape webcam_convertDiewaldToRShape(List<Pixel> points)
}
public void webcam_captureCurrentImage(PImage inImage)
{
processedCapturedImage = webcam_processImageForTrace(inImage);
colourSeparations = webcam_buildSeps(processedCapturedImage, sepKeyColour);
captureShape = webcam_traceImage(colourSeparations);
}
public void webcam_captureCurrentImage()
{
capturedImage = webcam_buildLiveImage();
processedCapturedImage = webcam_processImageForTrace(liveImage);
colourSeparations = webcam_buildSeps(processedCapturedImage, sepKeyColour);
captureShape = webcam_traceImage(colourSeparations);
webcam_captureCurrentImage(capturedImage);
}
public void stop() {
liveCamera.stop();
super.stop();
}