From 3746f102402c13e7b36283f0a13e8b397f5451ac Mon Sep 17 00:00:00 2001 From: Sandy Noble Date: Fri, 29 Mar 2013 19:19:24 +0000 Subject: [PATCH] Added a couple of webcam bits. --- DisplayMachine.pde | 92 ++++++++++++++++++++++++++++++++- controlsSetup.pde | 10 ++++ polargraphcontroller_webcam.pde | 40 ++++++++++++++ tabSetup.pde | 13 ++++- 4 files changed, 152 insertions(+), 3 deletions(-) diff --git a/DisplayMachine.pde b/DisplayMachine.pde index 2869225..669e819 100644 --- a/DisplayMachine.pde +++ b/DisplayMachine.pde @@ -346,11 +346,99 @@ class DisplayMachine extends Machine } } + public void drawForWebcam() + { + // work out the scaling factor. + noStroke(); + // draw machine outline + +// fill(80); +// rect(getOutline().getLeft()+DROP_SHADOW_DISTANCE, getOutline().getTop()+DROP_SHADOW_DISTANCE, getOutline().getWidth(), getOutline().getHeight()); + + fill(getMachineColour()); + rect(getOutline().getLeft(), getOutline().getTop(), getOutline().getWidth(), getOutline().getHeight()); + + + +// if (displayingGuides) +// { +// // draw some guides +// stroke(getGuideColour()); +// strokeWeight(1); +// // centre line +// line(getOutline().getLeft()+(getOutline().getWidth()/2), getOutline().getTop(), +// getOutline().getLeft()+(getOutline().getWidth()/2), getOutline().getBottom()); +// +// // page top line +// line(getOutline().getLeft(), getOutline().getTop()+sc(getHomePoint().y), +// getOutline().getRight(), getOutline().getTop()+sc(getHomePoint().y)); +// } + + // draw page + fill(getPageColour()); + rect(getOutline().getLeft()+sc(getPage().getLeft()), + getOutline().getTop()+sc(getPage().getTop()), + sc(getPage().getWidth()), + sc(getPage().getHeight())); + text("page " + getDimensionsAsText(getPage()), getOutline().getLeft()+sc(getPage().getLeft()), + getOutline().getTop()+sc(getPage().getTop())-3); + noFill(); + + + + stroke(getBackgroundColour(),150); + strokeWeight(3); + noFill(); + rect(getOutline().getLeft()-2, getOutline().getTop()-2, getOutline().getWidth()+3, getOutline().getHeight()+3); + + stroke(getMachineColour(),150); + strokeWeight(3); + noFill(); + rect(getOutline().getLeft()+sc(getPage().getLeft())-2, + getOutline().getTop()+sc(getPage().getTop())-2, + sc(getPage().getWidth())+4, + sc(getPage().getHeight())+4); + + if (displayingGuides) + { + drawPictureFrame(); + } + + if (drawingLiveVideo) + { + drawLiveVideo(); + } + + if (displayingVector && getVectorShape() != null) + { + stroke(100); + displayVectorImage(color(200)); + } + + if (displayingGuides + && getOutline().surrounds(getMouseVector()) + && currentMode != MODE_MOVE_IMAGE + && mouseOverControls().isEmpty() + ) + { + cursor(CROSS); + } + else + { + cursor(ARROW); + } + } + public void displayVectorImage() + { + displayVectorImage(color(0,0,0)); + } + + public void displayVectorImage(int strokeColour) { RPoint[][] pointPaths = getVectorShape().getPointsInPaths(); RG.ignoreStyles(); - stroke(1); + strokeWeight(1); if (pointPaths != null) { for(int i = 0; i buildPanels() rovingPanel.setControlSizes(buildControlSizesForPanel(rovingPanel)); panels.put(PANEL_NAME_ROVING, rovingPanel); + Panel webcamPanel = new Panel(PANEL_NAME_WEBCAM, panelOutline); + webcamPanel.setOutlineColour(color(200,200,200)); + // get controls + webcamPanel.setResizable(true); + webcamPanel.setControls(getControlsForPanels().get(PANEL_NAME_WEBCAM)); + // get control positions + rovingPanel.setControlPositions(buildControlPositionsForPanel(webcamPanel)); + rovingPanel.setControlSizes(buildControlSizesForPanel(webcamPanel)); + panels.put(PANEL_NAME_WEBCAM, webcamPanel); + Panel detailsPanel = new Panel(PANEL_NAME_DETAILS, panelOutline); detailsPanel.setOutlineColour(color(200, 200, 200)); // get controls diff --git a/polargraphcontroller_webcam.pde b/polargraphcontroller_webcam.pde index dea32ea..5cb4a5c 100644 --- a/polargraphcontroller_webcam.pde +++ b/polargraphcontroller_webcam.pde @@ -1,3 +1,8 @@ +import JMyron.*; +import diewald_CV_kit.libraryinfo.*; +import diewald_CV_kit.utility.*; +import diewald_CV_kit.blobdetection.*; + import geomerative.*; import org.apache.batik.svggen.font.table.*; import org.apache.batik.svggen.font.*; @@ -383,6 +388,8 @@ public static final String TAB_NAME_DETAILS = "tab_details"; public static final String TAB_LABEL_DETAILS = "Setup"; public static final String TAB_NAME_QUEUE = "tab_queue"; public static final String TAB_LABEL_QUEUE = "Queue"; +public static final String TAB_NAME_WEBCAM = "tab_webcam"; +public static final String TAB_LABEL_WEBCAM = "Camera"; // Page states public String currentTab = TAB_NAME_INPUT; @@ -392,6 +399,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_DETAILS = "panel_details"; public static final String PANEL_NAME_QUEUE = "panel_queue"; +public static final String PANEL_NAME_WEBCAM = "panel_webcam"; public static final String PANEL_NAME_GENERAL = "panel_general"; @@ -565,6 +573,10 @@ void draw() { drawRovingPage(); } + else if (getCurrentTab() == TAB_NAME_WEBCAM) + { + drawWebcamPage(); + } else { drawDetailsPage(); @@ -740,6 +752,34 @@ void drawRovingPage() showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20); } +void drawWebcamPage() +{ + strokeWeight(1); + background(100); + noFill(); + stroke(255, 150, 255, 100); + strokeWeight(3); + stroke(150); + noFill(); + getDisplayMachine().drawForWebcam(); + stroke(255, 0, 0); + + for (Panel panel : getPanelsForTab(TAB_NAME_WEBCAM)) + { + panel.draw(); + } + text(propertiesFilename, getPanel(PANEL_NAME_GENERAL).getOutline().getLeft(), getPanel(PANEL_NAME_GENERAL).getOutline().getTop()-7); + +// showCurrentMachinePosition(); + showGroupBox(); + showCurrentMachinePosition(); + if (displayingInfoTextOnInputPage) + showText(250,45); + drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y); + + showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20); +} + void drawCommandQueuePage() { cursor(ARROW); diff --git a/tabSetup.pde b/tabSetup.pde index 4dd450d..82866c1 100644 --- a/tabSetup.pde +++ b/tabSetup.pde @@ -49,6 +49,10 @@ Map> buildPanelsForTabs() rovingPanels.add(getPanel(PANEL_NAME_ROVING)); rovingPanels.add(getPanel(PANEL_NAME_GENERAL)); + Set webcamPanels = new HashSet(2); + webcamPanels.add(getPanel(PANEL_NAME_WEBCAM)); + webcamPanels.add(getPanel(PANEL_NAME_WEBCAM)); + Set detailsPanels = new HashSet(2); detailsPanels.add(getPanel(PANEL_NAME_DETAILS)); detailsPanels.add(getPanel(PANEL_NAME_GENERAL)); @@ -59,6 +63,7 @@ Map> buildPanelsForTabs() map.put(TAB_NAME_INPUT, inputPanels); map.put(TAB_NAME_ROVING, rovingPanels); + map.put(TAB_NAME_WEBCAM, webcamPanels); map.put(TAB_NAME_DETAILS, detailsPanels); map.put(TAB_NAME_QUEUE, queuePanels); @@ -70,6 +75,7 @@ List buildTabNames() List list = new ArrayList(4); list.add(TAB_NAME_INPUT); list.add(TAB_NAME_ROVING); + list.add(TAB_NAME_WEBCAM); list.add(TAB_NAME_DETAILS); list.add(TAB_NAME_QUEUE); return list; @@ -89,9 +95,13 @@ void initTabs() cp5.tab(TAB_NAME_ROVING).activateEvent(true); cp5.tab(TAB_NAME_ROVING).setId(3); + cp5.tab(TAB_NAME_WEBCAM).setLabel(TAB_LABEL_WEBCAM); + cp5.tab(TAB_NAME_WEBCAM).activateEvent(true); + cp5.tab(TAB_NAME_WEBCAM).setId(4); + cp5.tab(TAB_NAME_QUEUE).setLabel(TAB_LABEL_QUEUE); cp5.tab(TAB_NAME_QUEUE).activateEvent(true); - cp5.tab(TAB_NAME_QUEUE).setId(4); + cp5.tab(TAB_NAME_QUEUE).setId(5); } public Set buildPanelNames() @@ -99,6 +109,7 @@ public Set buildPanelNames() Set set = new HashSet(5); set.add(PANEL_NAME_INPUT); set.add(PANEL_NAME_ROVING); + set.add(PANEL_NAME_WEBCAM); set.add(PANEL_NAME_DETAILS); set.add(PANEL_NAME_QUEUE); set.add(PANEL_NAME_GENERAL);