Changed "webcam" to "trace", made trace load the contents of the bitmap instead of looking for a webcam.

This commit is contained in:
Sandy Noble 2013-05-09 23:31:44 +01:00
parent 256f2b8a05
commit 6c8555eda9
7 changed files with 151 additions and 144 deletions

View File

@ -346,30 +346,23 @@ class DisplayMachine extends Machine
} }
} }
public void drawForWebcam() public void drawForTrace()
{ {
// work out the scaling factor. // work out the scaling factor.
noStroke(); noStroke();
// draw machine outline // draw machine outline
// liveImage = webcam_buildLiveImage(); // liveImage = trace_buildLiveImage();
// draw actual image // draw actual image
if (displayingImage && imageIsReady() && webcamShape != null)
{
processedLiveImage = webcam_processImageForTrace(getImage());
colourSeparations = webcam_buildSeps(processedLiveImage, sepKeyColour);
webcamShape = webcam_traceImage(colourSeparations);
}
// if (drawingLiveVideo) // if (drawingLiveVideo)
// { // {
// displayLiveVideo(); // displayLiveVideo();
// } // }
if (drawingWebcamShape && webcamShape != null) if (drawingTraceShape && traceShape != null)
{ {
displayWebcamShape(); displaytraceShape();
} }
else else
{ {
@ -377,74 +370,74 @@ class DisplayMachine extends Machine
} }
} }
public void displayLiveVideo() // public void displayLiveVideo()
{ // {
// draw actual image, maximum size // // draw actual image, maximum size
if (processedLiveImage != null) // if (processedLiveImage != null)
{ // {
// origin - top left of the corner // // origin - top left of the corner
float ox = getPanel(PANEL_NAME_WEBCAM).getOutline().getRight()+7; // float ox = getPanel(PANEL_NAME_WEBCAM).getOutline().getRight()+7;
float oy = getPanel(PANEL_NAME_GENERAL).getOutline().getTop(); // float oy = getPanel(PANEL_NAME_GENERAL).getOutline().getTop();
//
// calculate size to display at. // // calculate size to display at.
float aspectRatio = (rotateWebcamImage) ? 480.0/640.0 : 640.0/480.0; // rotated, remember // float aspectRatio = (rotateWebcamImage) ? 480.0/640.0 : 640.0/480.0; // rotated, remember
float h = height - getPanel(PANEL_NAME_GENERAL).getOutline().getTop() -10; // float h = height - getPanel(PANEL_NAME_GENERAL).getOutline().getTop() -10;
float w = h * (480.0/640.0); // float w = h * (480.0/640.0);
// println("height: " + h + ", width: " + w); //// println("height: " + h + ", width: " + w);
// println("origin x: " + ox + ", y: " + oy); //// println("origin x: " + ox + ", y: " + oy);
//
if (rotateWebcamImage) // if (rotateWebcamImage)
{ // {
float t = h; // float t = h;
h = w; // h = w;
w = t; // w = t;
} // }
//
//stroke(255); // //stroke(255);
rect(ox,oy,w,h); // rect(ox,oy,w,h);
//
tint(255, getImageTransparency()); // tint(255, getImageTransparency());
if (rotateWebcamImage) // if (rotateWebcamImage)
{ // {
translate(ox, oy); // translate(ox, oy);
rotate(radians(270)); // rotate(radians(270));
image(processedLiveImage, -w, 0, w, h); // image(processedLiveImage, -w, 0, w, h);
image(liveImage, -w, (w-(w/4))+10, w/4, h/4); // image(liveImage, -w, (w-(w/4))+10, w/4, h/4);
// stroke(0,255,0); //// stroke(0,255,0);
// ellipse(0,0,80,40); //// ellipse(0,0,80,40);
// stroke(0,0,255); //// stroke(0,0,255);
// ellipse(-w,0,80,40); //// ellipse(-w,0,80,40);
rotate(radians(-270)); // rotate(radians(-270));
translate(-ox, -oy); // translate(-ox, -oy);
} // }
else // else
{ // {
translate(ox, oy); // translate(ox, oy);
image(processedLiveImage, 0, 0, h, w); // image(processedLiveImage, 0, 0, h, w);
image(liveImage, h-(h/4), w+10, h/4, w/4); // image(liveImage, h-(h/4), w+10, h/4, w/4);
translate(-ox, -oy); // translate(-ox, -oy);
} // }
noTint(); // noTint();
noFill(); // noFill();
} // }
} // }
public void displayWebcamShape() public void displaytraceShape()
{ {
strokeWeight(1); strokeWeight(1);
if (captureShape != null) if (captureShape != null)
{ {
//displayWebcamShapeAtFullSize(webcamShape, false, color(150,150,150)); //displaytraceShapeAtFullSize(traceShape, false, color(150,150,150));
displayWebcamShapeAtFullSize(captureShape, true, color(0,0,0)); displaytraceShapeAtFullSize(captureShape, true, color(0,0,0));
} }
else else
{ {
displayWebcamShapeAtFullSize(webcamShape, false, color(255,255,255)); displaytraceShapeAtFullSize(traceShape, false, color(255,255,255));
} }
} }
public void displayWebcamShapeAtFullSize(RShape vec, boolean illustrateSequence, Integer colour) public void displaytraceShapeAtFullSize(RShape vec, boolean illustrateSequence, Integer colour)
{ {
RG.ignoreStyles(); RG.ignoreStyles();
// work out scaling to make it full size on the screen // work out scaling to make it full size on the screen
@ -454,7 +447,7 @@ class DisplayMachine extends Machine
float scaler = h / vec.getWidth(); float scaler = h / vec.getWidth();
if (rotateWebcamImage) if (rotateWebcamImage)
scaler = h / vec.getHeight(); scaler = h / vec.getHeight();
PVector position = new PVector(getPanel(PANEL_NAME_WEBCAM).getOutline().getRight()+7, getPanel(PANEL_NAME_GENERAL).getOutline().getTop()); PVector position = new PVector(getPanel(PANEL_NAME_TRACE).getOutline().getRight()+7, getPanel(PANEL_NAME_GENERAL).getOutline().getTop());
noFill(); noFill();
RPoint[][] pointPaths = vec.getPointsInPaths(); RPoint[][] pointPaths = vec.getPointsInPaths();

View File

@ -525,6 +525,7 @@ class Machine
{ {
this.imageBitmap = loadImage(filename); this.imageBitmap = loadImage(filename);
this.imageFilename = filename; this.imageFilename = filename;
trace_initTrace(this.imageBitmap);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -114,19 +114,31 @@ void button_mode_sendPenliftRangePersist()
void numberbox_mode_liveBlurValue(int value) void numberbox_mode_liveBlurValue(int value)
{ {
blurValue = value; if (value != blurValue)
{
blurValue = value;
retraceShape = true;
}
} }
void numberbox_mode_liveSimplificationValue(int value) void numberbox_mode_liveSimplificationValue(int value)
{ {
liveSimplification = value; if (value != liveSimplification)
{
liveSimplification = value;
retraceShape = true;
}
} }
void numberbox_mode_livePosteriseValue(int value) void numberbox_mode_livePosteriseValue(int value)
{ {
posterizeValue = value; if (value != posterizeValue)
{
posterizeValue = value;
retraceShape = true;
}
} }
void button_mode_liveCaptureFromLive() void button_mode_liveCaptureFromLive()
{ {
webcam_captureCurrentImage(); trace_captureCurrentImage();
} }
void button_mode_liveClearCapture() void button_mode_liveClearCapture()
{ {
@ -148,20 +160,20 @@ void button_mode_liveConfirmDraw()
confirmedDraw = true; confirmedDraw = true;
// work out scaling and position // work out scaling and position
float scaling = getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getWidth()) / captureShape.getWidth(); float scaling = getDisplayMachine().inMM(getDisplayMachine().getImageFrame().getWidth()) / captureShape.getWidth();
PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().x), PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getImageFrame().getPosition().x),
getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().y)); getDisplayMachine().inMM(getDisplayMachine().getImageFrame().getPosition().y));
sendVectorShapes(captureShape, scaling, position, PATH_SORT_CENTRE_FIRST); sendVectorShapes(captureShape, scaling, position, PATH_SORT_CENTRE_FIRST);
button_mode_penUp(); button_mode_penUp();
// save shape as SVG // save shape as SVG
webcam_saveShape(captureShape); trace_saveShape(captureShape);
} }
} }
void toggle_mode_showWebcamRawVideo(boolean flag) void toggle_mode_showWebcamRawVideo(boolean flag)
{ {
drawingLiveVideo = flag; // drawingLiveVideo = flag;
} }
void toggle_mode_flipWebcam(boolean flag) void toggle_mode_flipWebcam(boolean flag)
{ {

View File

@ -130,15 +130,15 @@ Map<String, Panel> buildPanels()
rovingPanel.setControlSizes(buildControlSizesForPanel(rovingPanel)); rovingPanel.setControlSizes(buildControlSizesForPanel(rovingPanel));
panels.put(PANEL_NAME_ROVING, rovingPanel); panels.put(PANEL_NAME_ROVING, rovingPanel);
Panel webcamPanel = new Panel(PANEL_NAME_WEBCAM, panelOutline); Panel tracePanel = new Panel(PANEL_NAME_TRACE, panelOutline);
webcamPanel.setOutlineColour(color(200,200,200)); tracePanel.setOutlineColour(color(200,200,200));
// get controls // get controls
webcamPanel.setResizable(true); tracePanel.setResizable(true);
webcamPanel.setControls(getControlsForPanels().get(PANEL_NAME_WEBCAM)); tracePanel.setControls(getControlsForPanels().get(PANEL_NAME_TRACE));
// get control positions // get control positions
webcamPanel.setControlPositions(buildControlPositionsForPanel(webcamPanel)); tracePanel.setControlPositions(buildControlPositionsForPanel(tracePanel));
webcamPanel.setControlSizes(buildControlSizesForPanel(webcamPanel)); tracePanel.setControlSizes(buildControlSizesForPanel(tracePanel));
panels.put(PANEL_NAME_WEBCAM, webcamPanel); panels.put(PANEL_NAME_TRACE, tracePanel);
Panel detailsPanel = new Panel(PANEL_NAME_DETAILS, panelOutline); Panel detailsPanel = new Panel(PANEL_NAME_DETAILS, panelOutline);
detailsPanel.setOutlineColour(color(200, 200, 200)); detailsPanel.setOutlineColour(color(200, 200, 200));
@ -538,7 +538,7 @@ Map<String, Controller> initialiseToggleValues(Map<String, Controller> map)
else if (MODE_SHOW_WEBCAM_RAW_VIDEO.equals(key)) else if (MODE_SHOW_WEBCAM_RAW_VIDEO.equals(key))
{ {
Toggle t = (Toggle) map.get(key); Toggle t = (Toggle) map.get(key);
t.setValue((drawingLiveVideo) ? 1 : 0); // t.setValue((drawingLiveVideo) ? 1 : 0);
} }
else if (MODE_FLIP_WEBCAM_INPUT.equals(key)) else if (MODE_FLIP_WEBCAM_INPUT.equals(key))
{ {
@ -635,7 +635,7 @@ Map<String, List<Controller>> buildControlsForPanels()
map.put(PANEL_NAME_DETAILS, getControllersForControllerNames(getControlNamesForDetailPanel())); map.put(PANEL_NAME_DETAILS, getControllersForControllerNames(getControlNamesForDetailPanel()));
map.put(PANEL_NAME_QUEUE, getControllersForControllerNames(getControlNamesForQueuePanel())); map.put(PANEL_NAME_QUEUE, getControllersForControllerNames(getControlNamesForQueuePanel()));
map.put(PANEL_NAME_GENERAL, getControllersForControllerNames(getControlNamesForGeneralPanel())); map.put(PANEL_NAME_GENERAL, getControllersForControllerNames(getControlNamesForGeneralPanel()));
map.put(PANEL_NAME_WEBCAM, getControllersForControllerNames(getControlNamesForWebcamPanel())); map.put(PANEL_NAME_TRACE, getControllersForControllerNames(getControlNamesForTracePanel()));
return map; return map;
} }
@ -724,7 +724,7 @@ List<String> getControlNamesForRovingPanel()
return controlNames; return controlNames;
} }
List<String> getControlNamesForWebcamPanel() List<String> getControlNamesForTracePanel()
{ {
List<String> controlNames = new ArrayList<String>(); List<String> controlNames = new ArrayList<String>();
controlNames.add(MODE_LIVE_BLUR_VALUE); controlNames.add(MODE_LIVE_BLUR_VALUE);
@ -736,9 +736,9 @@ List<String> getControlNamesForWebcamPanel()
controlNames.add(MODE_LIVE_CONFIRM_DRAW); controlNames.add(MODE_LIVE_CONFIRM_DRAW);
// controlNames.add(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF); // controlNames.add(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF);
controlNames.add(MODE_SHOW_WEBCAM_RAW_VIDEO); // controlNames.add(MODE_SHOW_WEBCAM_RAW_VIDEO);
controlNames.add(MODE_FLIP_WEBCAM_INPUT); // controlNames.add(MODE_FLIP_WEBCAM_INPUT);
controlNames.add(MODE_ROTATE_WEBCAM_INPUT); // controlNames.add(MODE_ROTATE_WEBCAM_INPUT);
return controlNames; return controlNames;
} }

View File

@ -406,8 +406,8 @@ public static final String TAB_NAME_DETAILS = "tab_details";
public static final String TAB_LABEL_DETAILS = "Setup"; public static final String TAB_LABEL_DETAILS = "Setup";
public static final String TAB_NAME_QUEUE = "tab_queue"; public static final String TAB_NAME_QUEUE = "tab_queue";
public static final String TAB_LABEL_QUEUE = "Queue"; public static final String TAB_LABEL_QUEUE = "Queue";
public static final String TAB_NAME_WEBCAM = "tab_webcam"; public static final String TAB_NAME_TRACE = "tab_trace";
public static final String TAB_LABEL_WEBCAM = "Camera"; public static final String TAB_LABEL_TRACE = "Trace";
// Page states // Page states
public String currentTab = TAB_NAME_INPUT; public String currentTab = TAB_NAME_INPUT;
@ -417,7 +417,7 @@ public static final String PANEL_NAME_INPUT = "panel_input";
public static final String PANEL_NAME_ROVING = "panel_roving"; public static final String PANEL_NAME_ROVING = "panel_roving";
public static final String PANEL_NAME_DETAILS = "panel_details"; public static final String PANEL_NAME_DETAILS = "panel_details";
public static final String PANEL_NAME_QUEUE = "panel_queue"; public static final String PANEL_NAME_QUEUE = "panel_queue";
public static final String PANEL_NAME_WEBCAM = "panel_webcam"; public static final String PANEL_NAME_TRACE = "panel_trace";
public static final String PANEL_NAME_GENERAL = "panel_general"; public static final String PANEL_NAME_GENERAL = "panel_general";
@ -460,9 +460,8 @@ boolean overwriteExistingStoreFile = true;
public static Console console; public static Console console;
public boolean useWindowedConsole = false; public boolean useWindowedConsole = false;
static boolean webcamEnabled = false; static boolean drawingTraceShape = true;
static boolean drawingLiveVideo = false; static boolean retraceShape = true;
static boolean drawingWebcamShape = true;
static boolean flipWebcamImage = false; static boolean flipWebcamImage = false;
static boolean rotateWebcamImage = false; static boolean rotateWebcamImage = false;
static boolean confirmedDraw = false; static boolean confirmedDraw = false;
@ -488,7 +487,7 @@ int posterizeValue = 5;
int sepKeyColour = color(0, 0, 255); int sepKeyColour = color(0, 0, 255);
Map<Integer, PImage> colourSeparations = null; Map<Integer, PImage> colourSeparations = null;
RShape webcamShape = null; RShape traceShape = null;
RShape captureShape = null; RShape captureShape = null;
String shapeSavePath = "../../savedcaptures/"; String shapeSavePath = "../../savedcaptures/";
@ -576,7 +575,6 @@ void setup()
addEventListeners(); addEventListeners();
//gamepad_init(); //gamepad_init();
webcam_initCamera();
} }
void addEventListeners() void addEventListeners()
{ {
@ -638,9 +636,9 @@ void draw()
{ {
drawRovingPage(); drawRovingPage();
} }
else if (getCurrentTab() == TAB_NAME_WEBCAM) else if (getCurrentTab() == TAB_NAME_TRACE)
{ {
drawWebcamPage(); drawTracePage();
} }
else else
{ {
@ -817,7 +815,7 @@ void drawRovingPage()
showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20); showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20);
} }
void drawWebcamPage() void drawTracePage()
{ {
strokeWeight(1); strokeWeight(1);
background(100); background(100);
@ -826,26 +824,30 @@ void drawWebcamPage()
strokeWeight(3); strokeWeight(3);
stroke(150); stroke(150);
noFill(); noFill();
if (webcamEnabled) getDisplayMachine().drawForTrace();
if (displayingImage && getDisplayMachine().imageIsReady() && retraceShape)
{ {
getDisplayMachine().drawForWebcam(); processedLiveImage = trace_processImageForTrace(getDisplayMachine().getImage());
stroke(255, 0, 0); colourSeparations = trace_buildSeps(processedLiveImage, sepKeyColour);
traceShape = trace_traceImage(colourSeparations);
for (Panel panel : getPanelsForTab(TAB_NAME_WEBCAM)) drawingTraceShape = true;
{
panel.draw();
}
} }
else
stroke(255, 0, 0);
for (Panel panel : getPanelsForTab(TAB_NAME_TRACE))
{ {
text("No camera attached.", 250, 100); panel.draw();
} }
text(propertiesFilename, getPanel(PANEL_NAME_GENERAL).getOutline().getLeft(), getPanel(PANEL_NAME_GENERAL).getOutline().getTop()-7);
if (displayingInfoTextOnInputPage) if (displayingInfoTextOnInputPage)
showText(250,45); showText(250,45);
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y); drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
showCommandQueue((int) width-200, 20); showCommandQueue((int) width-200, 20);
// processGamepadInput(); // processGamepadInput();
// //
// if (displayGamepadOverlay) // if (displayGamepadOverlay)

View File

@ -49,9 +49,9 @@ Map<String, Set<Panel>> buildPanelsForTabs()
rovingPanels.add(getPanel(PANEL_NAME_ROVING)); rovingPanels.add(getPanel(PANEL_NAME_ROVING));
rovingPanels.add(getPanel(PANEL_NAME_GENERAL)); rovingPanels.add(getPanel(PANEL_NAME_GENERAL));
Set<Panel> webcamPanels = new HashSet<Panel>(2); Set<Panel> tracePanels = new HashSet<Panel>(2);
webcamPanels.add(getPanel(PANEL_NAME_WEBCAM)); tracePanels.add(getPanel(PANEL_NAME_TRACE));
webcamPanels.add(getPanel(PANEL_NAME_WEBCAM)); tracePanels.add(getPanel(PANEL_NAME_GENERAL));
Set<Panel> detailsPanels = new HashSet<Panel>(2); Set<Panel> detailsPanels = new HashSet<Panel>(2);
detailsPanels.add(getPanel(PANEL_NAME_DETAILS)); detailsPanels.add(getPanel(PANEL_NAME_DETAILS));
@ -63,7 +63,7 @@ Map<String, Set<Panel>> buildPanelsForTabs()
map.put(TAB_NAME_INPUT, inputPanels); map.put(TAB_NAME_INPUT, inputPanels);
map.put(TAB_NAME_ROVING, rovingPanels); map.put(TAB_NAME_ROVING, rovingPanels);
map.put(TAB_NAME_WEBCAM, webcamPanels); map.put(TAB_NAME_TRACE, tracePanels);
map.put(TAB_NAME_DETAILS, detailsPanels); map.put(TAB_NAME_DETAILS, detailsPanels);
map.put(TAB_NAME_QUEUE, queuePanels); map.put(TAB_NAME_QUEUE, queuePanels);
@ -75,7 +75,7 @@ List<String> buildTabNames()
List<String> list = new ArrayList<String>(5); List<String> list = new ArrayList<String>(5);
list.add(TAB_NAME_INPUT); list.add(TAB_NAME_INPUT);
list.add(TAB_NAME_ROVING); list.add(TAB_NAME_ROVING);
list.add(TAB_NAME_WEBCAM); list.add(TAB_NAME_TRACE);
list.add(TAB_NAME_DETAILS); list.add(TAB_NAME_DETAILS);
list.add(TAB_NAME_QUEUE); list.add(TAB_NAME_QUEUE);
return list; return list;
@ -95,9 +95,9 @@ void initTabs()
cp5.tab(TAB_NAME_ROVING).activateEvent(true); cp5.tab(TAB_NAME_ROVING).activateEvent(true);
cp5.tab(TAB_NAME_ROVING).setId(3); cp5.tab(TAB_NAME_ROVING).setId(3);
cp5.tab(TAB_NAME_WEBCAM).setLabel(TAB_LABEL_WEBCAM); cp5.tab(TAB_NAME_TRACE).setLabel(TAB_LABEL_TRACE);
cp5.tab(TAB_NAME_WEBCAM).activateEvent(true); cp5.tab(TAB_NAME_TRACE).activateEvent(true);
cp5.tab(TAB_NAME_WEBCAM).setId(4); cp5.tab(TAB_NAME_TRACE).setId(4);
cp5.tab(TAB_NAME_QUEUE).setLabel(TAB_LABEL_QUEUE); cp5.tab(TAB_NAME_QUEUE).setLabel(TAB_LABEL_QUEUE);
cp5.tab(TAB_NAME_QUEUE).activateEvent(true); cp5.tab(TAB_NAME_QUEUE).activateEvent(true);
@ -109,7 +109,7 @@ public Set<String> buildPanelNames()
Set<String> set = new HashSet<String>(6); Set<String> set = new HashSet<String>(6);
set.add(PANEL_NAME_INPUT); set.add(PANEL_NAME_INPUT);
set.add(PANEL_NAME_ROVING); set.add(PANEL_NAME_ROVING);
set.add(PANEL_NAME_WEBCAM); set.add(PANEL_NAME_TRACE);
set.add(PANEL_NAME_DETAILS); set.add(PANEL_NAME_DETAILS);
set.add(PANEL_NAME_QUEUE); set.add(PANEL_NAME_QUEUE);
set.add(PANEL_NAME_GENERAL); set.add(PANEL_NAME_GENERAL);

View File

@ -1,17 +1,18 @@
public void webcam_initCamera() public void trace_initTrace(PImage img)
{ {
// dummy initCamera(), does nothing // dummy initCamera(), does nothing
webcamEnabled = true; // tracetraceEnabled = true;
blob_detector = new BlobDetector( 640, 480); img.loadPixels();
blob_detector = new BlobDetector(img.width, img.height);
blob_detector.setResolution(1); blob_detector.setResolution(1);
blob_detector.computeContours(true); blob_detector.computeContours(true);
blob_detector.computeBlobPixels(true); blob_detector.computeBlobPixels(true);
blob_detector.setMinMaxPixels(10*10, 640*480); blob_detector.setMinMaxPixels(10*10, img.width * img.height);
blob_detector.setBLOBable(new BLOBable_blueBlobs(liveImage)); blob_detector.setBLOBable(new BLOBable_blueBlobs(liveImage));
} }
public void webcam_initCameraProcCam() public void trace_initCameraProcCam()
{ {
// try // try
// { // {
@ -19,17 +20,17 @@ public void webcam_initCameraProcCam()
// if (cameras.length > 0) { // if (cameras.length > 0) {
// liveCamera = new Capture(this, 640, 480, cameras[0]); // liveCamera = new Capture(this, 640, 480, cameras[0]);
// //liveCamera.start(); // //liveCamera.start();
// webcamEnabled = true; // traceEnabled = true;
// } // }
// } // }
// catch (Exception e) // catch (Exception e)
// { // {
// println("Exception occurred trying to look for attached webcams. Webcam will not be used. " + e.getMessage()); // println("Exception occurred trying to look for attached webcams. Webcam will not be used. " + e.getMessage());
// webcamEnabled = false; // traceEnabled = false;
// } // }
} }
//public PImage webcam_buildLiveImage() //public PImage trace_buildLiveImage()
//{ //{
// //liveCamera.start(); // //liveCamera.start();
// PImage pimg = createImage(640, 480, RGB); // PImage pimg = createImage(640, 480, RGB);
@ -69,7 +70,7 @@ public void webcam_initCameraProcCam()
// return pimg; // return pimg;
//} //}
public PImage webcam_processImageForTrace(PImage in) public PImage trace_processImageForTrace(PImage in)
{ {
PImage out = createImage(in.width, in.height, RGB); PImage out = createImage(in.width, in.height, RGB);
out.loadPixels(); out.loadPixels();
@ -83,7 +84,7 @@ public PImage webcam_processImageForTrace(PImage in)
return out; return out;
} }
public RShape webcam_traceImage(Map<Integer, PImage> seps) public RShape trace_traceImage(Map<Integer, PImage> seps)
{ {
RShape allShapes = null; RShape allShapes = null;
if (seps != null) if (seps != null)
@ -119,7 +120,7 @@ public RShape webcam_traceImage(Map<Integer, PImage> seps)
for (int simple_cnt = 0; simple_cnt < liveSimplification; simple_cnt++) { for (int simple_cnt = 0; simple_cnt < liveSimplification; simple_cnt++) {
contour_simple= Polyline.SIMPLIFY(contour_simple, 2, simple_cnt); contour_simple= Polyline.SIMPLIFY(contour_simple, 2, simple_cnt);
} }
RShape shp = webcam_convertDiewaldToRShape(contour_simple); RShape shp = trace_convertDiewaldToRShape(contour_simple);
if (shp != null) if (shp != null)
{ {
shapeNo++; shapeNo++;
@ -129,7 +130,7 @@ public RShape webcam_traceImage(Map<Integer, PImage> seps)
} }
else else
{ {
RShape shp = webcam_convertDiewaldToRShape(contour.getPixels()); RShape shp = trace_convertDiewaldToRShape(contour.getPixels());
if (shp != null) if (shp != null)
allShapes.addChild(shp); allShapes.addChild(shp);
} }
@ -148,7 +149,7 @@ public RShape webcam_traceImage(Map<Integer, PImage> seps)
return allShapes; return allShapes;
} }
Map<Integer, PImage> webcam_buildSeps(PImage img, Integer keyColour) Map<Integer, PImage> trace_buildSeps(PImage img, Integer keyColour)
{ {
// create separations // create separations
// pull out number of colours // pull out number of colours
@ -176,7 +177,7 @@ Map<Integer, PImage> webcam_buildSeps(PImage img, Integer keyColour)
return seps; return seps;
} }
RShape webcam_convertDiewaldToRShape(List<Pixel> points) RShape trace_convertDiewaldToRShape(List<Pixel> points)
{ {
RShape shp = null; RShape shp = null;
if (points.size() > 2) { if (points.size() > 2) {
@ -193,25 +194,23 @@ RShape webcam_convertDiewaldToRShape(List<Pixel> points)
} }
public void webcam_captureCurrentImage(PImage inImage) public void trace_captureCurrentImage(PImage inImage)
{ {
processedCapturedImage = webcam_processImageForTrace(inImage); captureShape = traceShape;
colourSeparations = webcam_buildSeps(processedCapturedImage, sepKeyColour);
captureShape = webcam_traceImage(colourSeparations);
} }
public void webcam_captureCurrentImage() public void trace_captureCurrentImage()
{ {
// capturedImage = webcam_buildLiveImage(); // capturedImage = trace_buildLiveImage();
// webcam_captureCurrentImage(capturedImage); trace_captureCurrentImage(getDisplayMachine().getImage());
} }
public void webcam_processLoadedImage() public void trace_processLoadedImage()
{ {
webcam_captureCurrentImage(getDisplayMachine().getImage()); trace_captureCurrentImage(getDisplayMachine().getImage());
} }
public void webcam_saveShape(RShape sh) public void trace_saveShape(RShape sh)
{ {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
String dateCode = sdf.format(new java.util.Date()); String dateCode = sdf.format(new java.util.Date());