mirror of
https://github.com/euphy/polargraphcontroller
synced 2024-11-14 02:07:57 +01:00
Changed "webcam" to "trace", made trace load the contents of the bitmap instead of looking for a webcam.
This commit is contained in:
parent
256f2b8a05
commit
6c8555eda9
@ -346,30 +346,23 @@ class DisplayMachine extends Machine
|
||||
}
|
||||
}
|
||||
|
||||
public void drawForWebcam()
|
||||
public void drawForTrace()
|
||||
{
|
||||
// work out the scaling factor.
|
||||
noStroke();
|
||||
// draw machine outline
|
||||
|
||||
// liveImage = webcam_buildLiveImage();
|
||||
// liveImage = trace_buildLiveImage();
|
||||
// draw actual image
|
||||
if (displayingImage && imageIsReady() && webcamShape != null)
|
||||
{
|
||||
processedLiveImage = webcam_processImageForTrace(getImage());
|
||||
|
||||
colourSeparations = webcam_buildSeps(processedLiveImage, sepKeyColour);
|
||||
webcamShape = webcam_traceImage(colourSeparations);
|
||||
}
|
||||
|
||||
// if (drawingLiveVideo)
|
||||
// {
|
||||
// displayLiveVideo();
|
||||
// }
|
||||
|
||||
if (drawingWebcamShape && webcamShape != null)
|
||||
if (drawingTraceShape && traceShape != null)
|
||||
{
|
||||
displayWebcamShape();
|
||||
displaytraceShape();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -377,74 +370,74 @@ class DisplayMachine extends Machine
|
||||
}
|
||||
}
|
||||
|
||||
public void displayLiveVideo()
|
||||
{
|
||||
// draw actual image, maximum size
|
||||
if (processedLiveImage != null)
|
||||
{
|
||||
// origin - top left of the corner
|
||||
float ox = getPanel(PANEL_NAME_WEBCAM).getOutline().getRight()+7;
|
||||
float oy = getPanel(PANEL_NAME_GENERAL).getOutline().getTop();
|
||||
|
||||
// calculate size to display at.
|
||||
float aspectRatio = (rotateWebcamImage) ? 480.0/640.0 : 640.0/480.0; // rotated, remember
|
||||
float h = height - getPanel(PANEL_NAME_GENERAL).getOutline().getTop() -10;
|
||||
float w = h * (480.0/640.0);
|
||||
// println("height: " + h + ", width: " + w);
|
||||
// println("origin x: " + ox + ", y: " + oy);
|
||||
|
||||
if (rotateWebcamImage)
|
||||
{
|
||||
float t = h;
|
||||
h = w;
|
||||
w = t;
|
||||
}
|
||||
|
||||
//stroke(255);
|
||||
rect(ox,oy,w,h);
|
||||
|
||||
tint(255, getImageTransparency());
|
||||
if (rotateWebcamImage)
|
||||
{
|
||||
translate(ox, oy);
|
||||
rotate(radians(270));
|
||||
image(processedLiveImage, -w, 0, w, h);
|
||||
image(liveImage, -w, (w-(w/4))+10, w/4, h/4);
|
||||
// stroke(0,255,0);
|
||||
// ellipse(0,0,80,40);
|
||||
// stroke(0,0,255);
|
||||
// ellipse(-w,0,80,40);
|
||||
rotate(radians(-270));
|
||||
translate(-ox, -oy);
|
||||
}
|
||||
else
|
||||
{
|
||||
translate(ox, oy);
|
||||
image(processedLiveImage, 0, 0, h, w);
|
||||
image(liveImage, h-(h/4), w+10, h/4, w/4);
|
||||
translate(-ox, -oy);
|
||||
}
|
||||
noTint();
|
||||
noFill();
|
||||
}
|
||||
}
|
||||
// public void displayLiveVideo()
|
||||
// {
|
||||
// // draw actual image, maximum size
|
||||
// if (processedLiveImage != null)
|
||||
// {
|
||||
// // origin - top left of the corner
|
||||
// float ox = getPanel(PANEL_NAME_WEBCAM).getOutline().getRight()+7;
|
||||
// float oy = getPanel(PANEL_NAME_GENERAL).getOutline().getTop();
|
||||
//
|
||||
// // calculate size to display at.
|
||||
// float aspectRatio = (rotateWebcamImage) ? 480.0/640.0 : 640.0/480.0; // rotated, remember
|
||||
// float h = height - getPanel(PANEL_NAME_GENERAL).getOutline().getTop() -10;
|
||||
// float w = h * (480.0/640.0);
|
||||
//// println("height: " + h + ", width: " + w);
|
||||
//// println("origin x: " + ox + ", y: " + oy);
|
||||
//
|
||||
// if (rotateWebcamImage)
|
||||
// {
|
||||
// float t = h;
|
||||
// h = w;
|
||||
// w = t;
|
||||
// }
|
||||
//
|
||||
// //stroke(255);
|
||||
// rect(ox,oy,w,h);
|
||||
//
|
||||
// tint(255, getImageTransparency());
|
||||
// if (rotateWebcamImage)
|
||||
// {
|
||||
// translate(ox, oy);
|
||||
// rotate(radians(270));
|
||||
// image(processedLiveImage, -w, 0, w, h);
|
||||
// image(liveImage, -w, (w-(w/4))+10, w/4, h/4);
|
||||
//// stroke(0,255,0);
|
||||
//// ellipse(0,0,80,40);
|
||||
//// stroke(0,0,255);
|
||||
//// ellipse(-w,0,80,40);
|
||||
// rotate(radians(-270));
|
||||
// translate(-ox, -oy);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// translate(ox, oy);
|
||||
// image(processedLiveImage, 0, 0, h, w);
|
||||
// image(liveImage, h-(h/4), w+10, h/4, w/4);
|
||||
// translate(-ox, -oy);
|
||||
// }
|
||||
// noTint();
|
||||
// noFill();
|
||||
// }
|
||||
// }
|
||||
|
||||
public void displayWebcamShape()
|
||||
public void displaytraceShape()
|
||||
{
|
||||
strokeWeight(1);
|
||||
|
||||
if (captureShape != null)
|
||||
{
|
||||
//displayWebcamShapeAtFullSize(webcamShape, false, color(150,150,150));
|
||||
displayWebcamShapeAtFullSize(captureShape, true, color(0,0,0));
|
||||
//displaytraceShapeAtFullSize(traceShape, false, color(150,150,150));
|
||||
displaytraceShapeAtFullSize(captureShape, true, color(0,0,0));
|
||||
}
|
||||
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();
|
||||
// work out scaling to make it full size on the screen
|
||||
@ -454,7 +447,7 @@ class DisplayMachine extends Machine
|
||||
float scaler = h / vec.getWidth();
|
||||
if (rotateWebcamImage)
|
||||
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();
|
||||
RPoint[][] pointPaths = vec.getPointsInPaths();
|
||||
|
@ -525,6 +525,7 @@ class Machine
|
||||
{
|
||||
this.imageBitmap = loadImage(filename);
|
||||
this.imageFilename = filename;
|
||||
trace_initTrace(this.imageBitmap);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -114,19 +114,31 @@ void button_mode_sendPenliftRangePersist()
|
||||
|
||||
void numberbox_mode_liveBlurValue(int value)
|
||||
{
|
||||
blurValue = value;
|
||||
if (value != blurValue)
|
||||
{
|
||||
blurValue = value;
|
||||
retraceShape = true;
|
||||
}
|
||||
}
|
||||
void numberbox_mode_liveSimplificationValue(int value)
|
||||
{
|
||||
liveSimplification = value;
|
||||
if (value != liveSimplification)
|
||||
{
|
||||
liveSimplification = value;
|
||||
retraceShape = true;
|
||||
}
|
||||
}
|
||||
void numberbox_mode_livePosteriseValue(int value)
|
||||
{
|
||||
posterizeValue = value;
|
||||
if (value != posterizeValue)
|
||||
{
|
||||
posterizeValue = value;
|
||||
retraceShape = true;
|
||||
}
|
||||
}
|
||||
void button_mode_liveCaptureFromLive()
|
||||
{
|
||||
webcam_captureCurrentImage();
|
||||
trace_captureCurrentImage();
|
||||
}
|
||||
void button_mode_liveClearCapture()
|
||||
{
|
||||
@ -148,20 +160,20 @@ void button_mode_liveConfirmDraw()
|
||||
confirmedDraw = true;
|
||||
|
||||
// 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));
|
||||
float scaling = getDisplayMachine().inMM(getDisplayMachine().getImageFrame().getWidth()) / captureShape.getWidth();
|
||||
PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getImageFrame().getPosition().x),
|
||||
getDisplayMachine().inMM(getDisplayMachine().getImageFrame().getPosition().y));
|
||||
|
||||
sendVectorShapes(captureShape, scaling, position, PATH_SORT_CENTRE_FIRST);
|
||||
button_mode_penUp();
|
||||
|
||||
// save shape as SVG
|
||||
webcam_saveShape(captureShape);
|
||||
trace_saveShape(captureShape);
|
||||
}
|
||||
}
|
||||
void toggle_mode_showWebcamRawVideo(boolean flag)
|
||||
{
|
||||
drawingLiveVideo = flag;
|
||||
// drawingLiveVideo = flag;
|
||||
}
|
||||
void toggle_mode_flipWebcam(boolean flag)
|
||||
{
|
||||
|
@ -130,15 +130,15 @@ Map<String, Panel> 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));
|
||||
Panel tracePanel = new Panel(PANEL_NAME_TRACE, panelOutline);
|
||||
tracePanel.setOutlineColour(color(200,200,200));
|
||||
// get controls
|
||||
webcamPanel.setResizable(true);
|
||||
webcamPanel.setControls(getControlsForPanels().get(PANEL_NAME_WEBCAM));
|
||||
tracePanel.setResizable(true);
|
||||
tracePanel.setControls(getControlsForPanels().get(PANEL_NAME_TRACE));
|
||||
// get control positions
|
||||
webcamPanel.setControlPositions(buildControlPositionsForPanel(webcamPanel));
|
||||
webcamPanel.setControlSizes(buildControlSizesForPanel(webcamPanel));
|
||||
panels.put(PANEL_NAME_WEBCAM, webcamPanel);
|
||||
tracePanel.setControlPositions(buildControlPositionsForPanel(tracePanel));
|
||||
tracePanel.setControlSizes(buildControlSizesForPanel(tracePanel));
|
||||
panels.put(PANEL_NAME_TRACE, tracePanel);
|
||||
|
||||
Panel detailsPanel = new Panel(PANEL_NAME_DETAILS, panelOutline);
|
||||
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))
|
||||
{
|
||||
Toggle t = (Toggle) map.get(key);
|
||||
t.setValue((drawingLiveVideo) ? 1 : 0);
|
||||
// t.setValue((drawingLiveVideo) ? 1 : 0);
|
||||
}
|
||||
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_QUEUE, getControllersForControllerNames(getControlNamesForQueuePanel()));
|
||||
map.put(PANEL_NAME_GENERAL, getControllersForControllerNames(getControlNamesForGeneralPanel()));
|
||||
map.put(PANEL_NAME_WEBCAM, getControllersForControllerNames(getControlNamesForWebcamPanel()));
|
||||
map.put(PANEL_NAME_TRACE, getControllersForControllerNames(getControlNamesForTracePanel()));
|
||||
return map;
|
||||
}
|
||||
|
||||
@ -724,7 +724,7 @@ List<String> getControlNamesForRovingPanel()
|
||||
return controlNames;
|
||||
}
|
||||
|
||||
List<String> getControlNamesForWebcamPanel()
|
||||
List<String> getControlNamesForTracePanel()
|
||||
{
|
||||
List<String> controlNames = new ArrayList<String>();
|
||||
controlNames.add(MODE_LIVE_BLUR_VALUE);
|
||||
@ -736,9 +736,9 @@ List<String> getControlNamesForWebcamPanel()
|
||||
controlNames.add(MODE_LIVE_CONFIRM_DRAW);
|
||||
// controlNames.add(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF);
|
||||
|
||||
controlNames.add(MODE_SHOW_WEBCAM_RAW_VIDEO);
|
||||
controlNames.add(MODE_FLIP_WEBCAM_INPUT);
|
||||
controlNames.add(MODE_ROTATE_WEBCAM_INPUT);
|
||||
// controlNames.add(MODE_SHOW_WEBCAM_RAW_VIDEO);
|
||||
// controlNames.add(MODE_FLIP_WEBCAM_INPUT);
|
||||
// controlNames.add(MODE_ROTATE_WEBCAM_INPUT);
|
||||
return controlNames;
|
||||
}
|
||||
|
||||
|
@ -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_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";
|
||||
public static final String TAB_NAME_TRACE = "tab_trace";
|
||||
public static final String TAB_LABEL_TRACE = "Trace";
|
||||
|
||||
// Page states
|
||||
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_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_TRACE = "panel_trace";
|
||||
|
||||
public static final String PANEL_NAME_GENERAL = "panel_general";
|
||||
|
||||
@ -460,9 +460,8 @@ boolean overwriteExistingStoreFile = true;
|
||||
public static Console console;
|
||||
public boolean useWindowedConsole = false;
|
||||
|
||||
static boolean webcamEnabled = false;
|
||||
static boolean drawingLiveVideo = false;
|
||||
static boolean drawingWebcamShape = true;
|
||||
static boolean drawingTraceShape = true;
|
||||
static boolean retraceShape = true;
|
||||
static boolean flipWebcamImage = false;
|
||||
static boolean rotateWebcamImage = false;
|
||||
static boolean confirmedDraw = false;
|
||||
@ -488,7 +487,7 @@ int posterizeValue = 5;
|
||||
int sepKeyColour = color(0, 0, 255);
|
||||
|
||||
Map<Integer, PImage> colourSeparations = null;
|
||||
RShape webcamShape = null;
|
||||
RShape traceShape = null;
|
||||
RShape captureShape = null;
|
||||
|
||||
String shapeSavePath = "../../savedcaptures/";
|
||||
@ -576,7 +575,6 @@ void setup()
|
||||
addEventListeners();
|
||||
|
||||
//gamepad_init();
|
||||
webcam_initCamera();
|
||||
}
|
||||
void addEventListeners()
|
||||
{
|
||||
@ -638,9 +636,9 @@ void draw()
|
||||
{
|
||||
drawRovingPage();
|
||||
}
|
||||
else if (getCurrentTab() == TAB_NAME_WEBCAM)
|
||||
else if (getCurrentTab() == TAB_NAME_TRACE)
|
||||
{
|
||||
drawWebcamPage();
|
||||
drawTracePage();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -817,7 +815,7 @@ void drawRovingPage()
|
||||
showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20);
|
||||
}
|
||||
|
||||
void drawWebcamPage()
|
||||
void drawTracePage()
|
||||
{
|
||||
strokeWeight(1);
|
||||
background(100);
|
||||
@ -826,26 +824,30 @@ void drawWebcamPage()
|
||||
strokeWeight(3);
|
||||
stroke(150);
|
||||
noFill();
|
||||
if (webcamEnabled)
|
||||
getDisplayMachine().drawForTrace();
|
||||
if (displayingImage && getDisplayMachine().imageIsReady() && retraceShape)
|
||||
{
|
||||
getDisplayMachine().drawForWebcam();
|
||||
stroke(255, 0, 0);
|
||||
|
||||
for (Panel panel : getPanelsForTab(TAB_NAME_WEBCAM))
|
||||
{
|
||||
panel.draw();
|
||||
}
|
||||
processedLiveImage = trace_processImageForTrace(getDisplayMachine().getImage());
|
||||
colourSeparations = trace_buildSeps(processedLiveImage, sepKeyColour);
|
||||
traceShape = trace_traceImage(colourSeparations);
|
||||
drawingTraceShape = true;
|
||||
}
|
||||
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)
|
||||
showText(250,45);
|
||||
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
|
||||
showCommandQueue((int) width-200, 20);
|
||||
|
||||
|
||||
// processGamepadInput();
|
||||
//
|
||||
// if (displayGamepadOverlay)
|
||||
|
18
tabSetup.pde
18
tabSetup.pde
@ -49,9 +49,9 @@ Map<String, Set<Panel>> buildPanelsForTabs()
|
||||
rovingPanels.add(getPanel(PANEL_NAME_ROVING));
|
||||
rovingPanels.add(getPanel(PANEL_NAME_GENERAL));
|
||||
|
||||
Set<Panel> webcamPanels = new HashSet<Panel>(2);
|
||||
webcamPanels.add(getPanel(PANEL_NAME_WEBCAM));
|
||||
webcamPanels.add(getPanel(PANEL_NAME_WEBCAM));
|
||||
Set<Panel> tracePanels = new HashSet<Panel>(2);
|
||||
tracePanels.add(getPanel(PANEL_NAME_TRACE));
|
||||
tracePanels.add(getPanel(PANEL_NAME_GENERAL));
|
||||
|
||||
Set<Panel> detailsPanels = new HashSet<Panel>(2);
|
||||
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_ROVING, rovingPanels);
|
||||
map.put(TAB_NAME_WEBCAM, webcamPanels);
|
||||
map.put(TAB_NAME_TRACE, tracePanels);
|
||||
map.put(TAB_NAME_DETAILS, detailsPanels);
|
||||
map.put(TAB_NAME_QUEUE, queuePanels);
|
||||
|
||||
@ -75,7 +75,7 @@ List<String> buildTabNames()
|
||||
List<String> list = new ArrayList<String>(5);
|
||||
list.add(TAB_NAME_INPUT);
|
||||
list.add(TAB_NAME_ROVING);
|
||||
list.add(TAB_NAME_WEBCAM);
|
||||
list.add(TAB_NAME_TRACE);
|
||||
list.add(TAB_NAME_DETAILS);
|
||||
list.add(TAB_NAME_QUEUE);
|
||||
return list;
|
||||
@ -95,9 +95,9 @@ 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_TRACE).setLabel(TAB_LABEL_TRACE);
|
||||
cp5.tab(TAB_NAME_TRACE).activateEvent(true);
|
||||
cp5.tab(TAB_NAME_TRACE).setId(4);
|
||||
|
||||
cp5.tab(TAB_NAME_QUEUE).setLabel(TAB_LABEL_QUEUE);
|
||||
cp5.tab(TAB_NAME_QUEUE).activateEvent(true);
|
||||
@ -109,7 +109,7 @@ public Set<String> buildPanelNames()
|
||||
Set<String> set = new HashSet<String>(6);
|
||||
set.add(PANEL_NAME_INPUT);
|
||||
set.add(PANEL_NAME_ROVING);
|
||||
set.add(PANEL_NAME_WEBCAM);
|
||||
set.add(PANEL_NAME_TRACE);
|
||||
set.add(PANEL_NAME_DETAILS);
|
||||
set.add(PANEL_NAME_QUEUE);
|
||||
set.add(PANEL_NAME_GENERAL);
|
||||
|
@ -1,17 +1,18 @@
|
||||
public void webcam_initCamera()
|
||||
public void trace_initTrace(PImage img)
|
||||
{
|
||||
// dummy initCamera(), does nothing
|
||||
webcamEnabled = true;
|
||||
blob_detector = new BlobDetector( 640, 480);
|
||||
// tracetraceEnabled = true;
|
||||
img.loadPixels();
|
||||
blob_detector = new BlobDetector(img.width, img.height);
|
||||
blob_detector.setResolution(1);
|
||||
blob_detector.computeContours(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));
|
||||
}
|
||||
|
||||
public void webcam_initCameraProcCam()
|
||||
public void trace_initCameraProcCam()
|
||||
{
|
||||
// try
|
||||
// {
|
||||
@ -19,17 +20,17 @@ public void webcam_initCameraProcCam()
|
||||
// if (cameras.length > 0) {
|
||||
// liveCamera = new Capture(this, 640, 480, cameras[0]);
|
||||
// //liveCamera.start();
|
||||
// webcamEnabled = true;
|
||||
// traceEnabled = true;
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// 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();
|
||||
// PImage pimg = createImage(640, 480, RGB);
|
||||
@ -69,7 +70,7 @@ public void webcam_initCameraProcCam()
|
||||
// return pimg;
|
||||
//}
|
||||
|
||||
public PImage webcam_processImageForTrace(PImage in)
|
||||
public PImage trace_processImageForTrace(PImage in)
|
||||
{
|
||||
PImage out = createImage(in.width, in.height, RGB);
|
||||
out.loadPixels();
|
||||
@ -83,7 +84,7 @@ public PImage webcam_processImageForTrace(PImage in)
|
||||
return out;
|
||||
}
|
||||
|
||||
public RShape webcam_traceImage(Map<Integer, PImage> seps)
|
||||
public RShape trace_traceImage(Map<Integer, PImage> seps)
|
||||
{
|
||||
RShape allShapes = 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++) {
|
||||
contour_simple= Polyline.SIMPLIFY(contour_simple, 2, simple_cnt);
|
||||
}
|
||||
RShape shp = webcam_convertDiewaldToRShape(contour_simple);
|
||||
RShape shp = trace_convertDiewaldToRShape(contour_simple);
|
||||
if (shp != null)
|
||||
{
|
||||
shapeNo++;
|
||||
@ -129,7 +130,7 @@ public RShape webcam_traceImage(Map<Integer, PImage> seps)
|
||||
}
|
||||
else
|
||||
{
|
||||
RShape shp = webcam_convertDiewaldToRShape(contour.getPixels());
|
||||
RShape shp = trace_convertDiewaldToRShape(contour.getPixels());
|
||||
if (shp != null)
|
||||
allShapes.addChild(shp);
|
||||
}
|
||||
@ -148,7 +149,7 @@ public RShape webcam_traceImage(Map<Integer, PImage> seps)
|
||||
return allShapes;
|
||||
}
|
||||
|
||||
Map<Integer, PImage> webcam_buildSeps(PImage img, Integer keyColour)
|
||||
Map<Integer, PImage> trace_buildSeps(PImage img, Integer keyColour)
|
||||
{
|
||||
// create separations
|
||||
// pull out number of colours
|
||||
@ -176,7 +177,7 @@ Map<Integer, PImage> webcam_buildSeps(PImage img, Integer keyColour)
|
||||
return seps;
|
||||
}
|
||||
|
||||
RShape webcam_convertDiewaldToRShape(List<Pixel> points)
|
||||
RShape trace_convertDiewaldToRShape(List<Pixel> points)
|
||||
{
|
||||
RShape shp = null;
|
||||
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);
|
||||
colourSeparations = webcam_buildSeps(processedCapturedImage, sepKeyColour);
|
||||
captureShape = webcam_traceImage(colourSeparations);
|
||||
captureShape = traceShape;
|
||||
}
|
||||
|
||||
public void webcam_captureCurrentImage()
|
||||
public void trace_captureCurrentImage()
|
||||
{
|
||||
// capturedImage = webcam_buildLiveImage();
|
||||
// webcam_captureCurrentImage(capturedImage);
|
||||
// capturedImage = trace_buildLiveImage();
|
||||
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");
|
||||
String dateCode = sdf.format(new java.util.Date());
|
Loading…
Reference in New Issue
Block a user