From 33f5642fa9c9d5ee7d190b0d528cc66fdfaab9d6 Mon Sep 17 00:00:00 2001 From: Sandy Noble Date: Sat, 30 Mar 2013 23:27:19 +0000 Subject: [PATCH] Crazy rocking cool. Now working. No funky gamepad interface, but workflow works. --- DisplayMachine.pde | 27 +++++++++----- controlsActions.pde | 13 ++++++- drawing.pde | 63 +++++++++++++++++++++++++++------ polargraphcontroller_webcam.pde | 5 +-- 4 files changed, 87 insertions(+), 21 deletions(-) diff --git a/DisplayMachine.pde b/DisplayMachine.pde index bd9ec52..5072c6d 100644 --- a/DisplayMachine.pde +++ b/DisplayMachine.pde @@ -448,11 +448,26 @@ class DisplayMachine extends Machine public void displayVectorImage() { - displayVectorImage(getVectorShape(), color(0,0,0), true); + displayVectorImage(getVectorShape(), vectorScaling/100, getVectorPosition(), color(0,0,0), true); + + if (captureShape != null) + { + float scaling = inMM(getPictureFrame().getWidth()) / captureShape.getWidth(); + PVector position = new PVector(inMM(getPictureFrame().getPosition().x), inMM(getPictureFrame().getPosition().y) + (captureShape.getHeight() * scaling)); + displayVectorImage(captureShape, + scaling, + position, + color(0,200,0), true); + } } - public void displayVectorImage(RShape vec, int strokeColour, boolean drawCentroid) + public void displayVectorImage(RShape vec, float scaling, PVector position, int strokeColour, boolean drawCentroid) { + PVector centroid = new PVector(vec.width/2, vec.height/2); + centroid = PVector.mult(centroid, (vectorScaling/100)); + centroid = PVector.add(centroid, getVectorPosition()); + centroid = scaleToScreen(centroid); + RPoint[][] pointPaths = vec.getPointsInPaths(); RG.ignoreStyles(); strokeWeight(1); @@ -466,8 +481,8 @@ class DisplayMachine extends Machine for (int j = 0; j filteredPoints = filterPoints(pointPaths[i], VECTOR_FILTER_LOW_PASS, minimumVectorLineLength); + List filteredPoints = filterPoints(pointPaths[i], VECTOR_FILTER_LOW_PASS, minimumVectorLineLength, scaling, position); //println(filteredPoints); if (!filteredPoints.isEmpty()) { @@ -695,12 +698,52 @@ void sendVectorShapes(RShape vec) println("finished."); } -List filterPoints(RPoint[] points, int filterToUse, long filterParam) +public RPoint[][] sortPathLongestFirst(RPoint[][] pointPaths) { - return filterPointsLowPass(points, filterParam); + // put the paths into a list + List pathsList = new ArrayList(pointPaths.length); + for (int i = 0; i() { + public int compare(RPoint[] o1, RPoint[] o2) { + if (o1.length > o2.length) { + return -1; + } else if (o1.length < o2.length) { + return 1; + } else { + return 0; + } + } + }); + + println("Sorted PathsList: "); + for (RPoint[] path : pathsList) + println(path.length + ", "); + + for (int i=0; i filterPointsLowPass(RPoint[] points, long filterParam) +List filterPoints(RPoint[] points, int filterToUse, long filterParam, float scaling, PVector position) +{ + return filterPointsLowPass(points, filterParam, scaling, position); +} + +List filterPointsLowPass(RPoint[] points, long filterParam, float scaling, PVector position) { List result = new ArrayList(); @@ -710,8 +753,8 @@ List filterPointsLowPass(RPoint[] points, long filterParam) { RPoint firstPoint = points[j]; PVector p = new PVector(firstPoint.x, firstPoint.y); - p = PVector.mult(p, (vectorScaling/100)); - p = PVector.add(p, getVectorPosition()); + p = PVector.mult(p, scaling); + p = PVector.add(p, position); p = getDisplayMachine().inSteps(p); if (getDisplayMachine().getPage().surrounds(p)) { @@ -734,7 +777,7 @@ List filterPointsLowPass(RPoint[] points, long filterParam) if (abs(diffx) > filterParam || abs(diffy) > filterParam) { - println("Adding point " + p + ", last: " + result.get(result.size()-1)); + //println("Adding point " + p + ", last: " + result.get(result.size()-1)); result.add(p); } } @@ -743,7 +786,7 @@ List filterPointsLowPass(RPoint[] points, long filterParam) if (result.size() < 2) result.clear(); - println("finished filter."); + //println("finished filter."); return result; } diff --git a/polargraphcontroller_webcam.pde b/polargraphcontroller_webcam.pde index 295ad82..2453710 100644 --- a/polargraphcontroller_webcam.pde +++ b/polargraphcontroller_webcam.pde @@ -459,9 +459,9 @@ static PImage processedCapturedImage = null; JMyron liveCamera; BlobDetector blob_detector; -int liveSimplification = 2; +int liveSimplification = 4; int blurValue = 1; -int posterizeValue = 8; +int posterizeValue = 12; int sepKeyColour = color(0, 0, 255); Map colourSeparations = null; @@ -809,6 +809,7 @@ void drawWebcamPage() if (displayingInfoTextOnInputPage) showText(250,45); drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y); + showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20); }