webcam works

This commit is contained in:
jan 2016-07-09 17:51:24 -07:00
parent 5f0a62d9bf
commit 8edc1224bb
4 changed files with 161 additions and 81 deletions

View File

@ -2,22 +2,10 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="6e752a8c-6cb9-4ef9-9031-0329ce15fcb4" name="Default" comment=""> <list default="true" id="6e752a8c-6cb9-4ef9-9031-0329ce15fcb4" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/dictionaries/jan.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/opencv.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/serial.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/video.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/Camera.java" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/EuglenaApplet.java" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/LEDControl.java" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/ProjectorApplet.java" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/src/Settings.java" />
<change type="DELETED" beforePath="$PROJECT_DIR$/src/ExampleApplet.java" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/gluegen-rt-natives-macosx-universal.jar" afterPath="$PROJECT_DIR$/lib/gluegen-rt-natives-macosx-universal.jar" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/compiler.xml" afterPath="$PROJECT_DIR$/.idea/compiler.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/libraries/lib.xml" afterPath="$PROJECT_DIR$/.idea/libraries/lib.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/misc.xml" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/processing-intellij.iml" afterPath="$PROJECT_DIR$/processing-intellij.iml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Camera.java" afterPath="$PROJECT_DIR$/src/Camera.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/EuglenaApplet.java" afterPath="$PROJECT_DIR$/src/EuglenaApplet.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/LEDControl.java" afterPath="$PROJECT_DIR$/src/LEDControl.java" />
</list> </list>
<ignored path="processing-intellij.iws" /> <ignored path="processing-intellij.iws" />
<ignored path=".idea/workspace.xml" /> <ignored path=".idea/workspace.xml" />
@ -41,8 +29,8 @@
<file leaf-file-name="euglena_basic_stimuli.java" pinned="false" current-in-tab="true"> <file leaf-file-name="euglena_basic_stimuli.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/euglena_basic_stimuli.java"> <entry file="file://$PROJECT_DIR$/src/euglena_basic_stimuli.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="702"> <state relative-caret-position="525">
<caret line="281" column="32" selection-start-line="281" selection-start-column="32" selection-end-line="281" selection-end-column="32" /> <caret line="318" column="9" selection-start-line="318" selection-start-column="9" selection-end-line="318" selection-end-column="9" />
<folding> <folding>
<element signature="e#0#16478#0" expanded="true" /> <element signature="e#0#16478#0" expanded="true" />
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
@ -65,8 +53,8 @@
<file leaf-file-name="EuglenaApplet.java" pinned="false" current-in-tab="true"> <file leaf-file-name="EuglenaApplet.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/EuglenaApplet.java"> <entry file="file://$PROJECT_DIR$/src/EuglenaApplet.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="630"> <state relative-caret-position="443">
<caret line="38" column="0" selection-start-line="38" selection-start-column="0" selection-end-line="38" selection-end-column="0" /> <caret line="41" column="24" selection-start-line="41" selection-start-column="24" selection-end-line="41" selection-end-column="24" />
<folding> <folding>
<element signature="e#322#323#0" expanded="true" /> <element signature="e#322#323#0" expanded="true" />
<element signature="e#367#368#0" expanded="true" /> <element signature="e#367#368#0" expanded="true" />
@ -80,8 +68,8 @@
<file leaf-file-name="ProjectorApplet.java" pinned="false" current-in-tab="false"> <file leaf-file-name="ProjectorApplet.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ProjectorApplet.java"> <entry file="file://$PROJECT_DIR$/src/ProjectorApplet.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="432"> <state relative-caret-position="0">
<caret line="24" column="1" selection-start-line="24" selection-start-column="1" selection-end-line="24" selection-end-column="1" /> <caret line="0" column="31" selection-start-line="0" selection-start-column="31" selection-end-line="0" selection-end-column="31" />
<folding> <folding>
<element signature="e#216#217#0" expanded="true" /> <element signature="e#216#217#0" expanded="true" />
<element signature="e#275#276#0" expanded="true" /> <element signature="e#275#276#0" expanded="true" />
@ -95,9 +83,13 @@
<file leaf-file-name="Camera.java" pinned="false" current-in-tab="false"> <file leaf-file-name="Camera.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Camera.java"> <entry file="file://$PROJECT_DIR$/src/Camera.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18"> <state relative-caret-position="90">
<caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" /> <caret line="5" column="16" selection-start-line="5" selection-start-column="16" selection-end-line="5" selection-end-column="16" />
<folding /> <folding>
<element signature="imports" expanded="true" />
<element signature="e#957#958#0" expanded="true" />
<element signature="e#983#984#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
@ -105,12 +97,12 @@
<file leaf-file-name="LEDControl.java" pinned="false" current-in-tab="false"> <file leaf-file-name="LEDControl.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/LEDControl.java"> <entry file="file://$PROJECT_DIR$/src/LEDControl.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54"> <state relative-caret-position="270">
<caret line="3" column="6" selection-start-line="3" selection-start-column="6" selection-end-line="3" selection-end-column="6" /> <caret line="15" column="16" selection-start-line="15" selection-start-column="16" selection-end-line="15" selection-end-column="16" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#1148#1149#0" expanded="true" /> <element signature="e#1002#1003#0" expanded="true" />
<element signature="e#1192#1193#0" expanded="true" /> <element signature="e#1046#1047#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -119,8 +111,8 @@
<file leaf-file-name="Menu.java" pinned="false" current-in-tab="false"> <file leaf-file-name="Menu.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Menu.java"> <entry file="file://$PROJECT_DIR$/src/Menu.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="234"> <state relative-caret-position="666">
<caret line="167" column="79" selection-start-line="167" selection-start-column="71" selection-end-line="167" selection-end-column="79" /> <caret line="178" column="30" selection-start-line="178" selection-start-column="30" selection-end-line="178" selection-end-column="30" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
@ -171,10 +163,12 @@
<option value="$PROJECT_DIR$/src/Settings.java" /> <option value="$PROJECT_DIR$/src/Settings.java" />
<option value="$PROJECT_DIR$/src/ExampleApplet.java" /> <option value="$PROJECT_DIR$/src/ExampleApplet.java" />
<option value="$PROJECT_DIR$/src/euglena_basic_stimuli.java" /> <option value="$PROJECT_DIR$/src/euglena_basic_stimuli.java" />
<option value="$PROJECT_DIR$/src/Menu.java" /> <option value="$PROJECT_DIR$/src/Projector.java" />
<option value="$PROJECT_DIR$/src/heatup.java" />
<option value="$PROJECT_DIR$/src/LEDControl.java" /> <option value="$PROJECT_DIR$/src/LEDControl.java" />
<option value="$PROJECT_DIR$/src/Camera.java" /> <option value="$PROJECT_DIR$/src/Camera.java" />
<option value="$PROJECT_DIR$/src/Projector.java" /> <option value="$PROJECT_DIR$/src/ProjectorApplet.java" />
<option value="$PROJECT_DIR$/src/Menu.java" />
<option value="$PROJECT_DIR$/src/EuglenaApplet.java" /> <option value="$PROJECT_DIR$/src/EuglenaApplet.java" />
</list> </list>
</option> </option>
@ -244,6 +238,24 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT> </PATH_ELEMENT>
</PATH> </PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="processing-intellij" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="eug3" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="Presets.java" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.ClassesTreeStructureProvider$PsiClassOwnerTreeNode" />
</PATH_ELEMENT>
</PATH>
</subPane> </subPane>
</pane> </pane>
</panes> </panes>
@ -380,6 +392,14 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1468081878478</updated> <updated>1468081878478</updated>
</task> </task>
<task id="LOCAL-00001" summary="Start javaifying">
<created>1468109775159</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1468109775159</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers /> <servers />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
@ -418,6 +438,10 @@
<component name="VcsContentAnnotationSettings"> <component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Start javaifying" />
<option name="LAST_COMMIT_MESSAGE" value="Start javaifying" />
</component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager /> <breakpoint-manager />
<watches-manager /> <watches-manager />
@ -541,6 +565,30 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/LEDtest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/heatup.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="72">
<caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/gradientWindow.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/angleGather.java"> <entry file="file://$PROJECT_DIR$/src/angleGather.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="216"> <state relative-caret-position="216">
@ -557,40 +605,10 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Menu.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="234">
<caret line="167" column="79" selection-start-line="167" selection-start-column="71" selection-end-line="167" selection-end-column="79" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Camera.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/LEDControl.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54">
<caret line="3" column="6" selection-start-line="3" selection-start-column="6" selection-end-line="3" selection-end-column="6" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#1148#1149#0" expanded="true" />
<element signature="e#1192#1193#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ProjectorApplet.java"> <entry file="file://$PROJECT_DIR$/src/ProjectorApplet.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="432"> <state relative-caret-position="0">
<caret line="24" column="1" selection-start-line="24" selection-start-column="1" selection-end-line="24" selection-end-column="1" /> <caret line="0" column="31" selection-start-line="0" selection-start-column="31" selection-end-line="0" selection-end-column="31" />
<folding> <folding>
<element signature="e#216#217#0" expanded="true" /> <element signature="e#216#217#0" expanded="true" />
<element signature="e#275#276#0" expanded="true" /> <element signature="e#275#276#0" expanded="true" />
@ -600,10 +618,44 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Camera.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="5" column="16" selection-start-line="5" selection-start-column="16" selection-end-line="5" selection-end-column="16" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#957#958#0" expanded="true" />
<element signature="e#983#984#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/LEDControl.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="270">
<caret line="15" column="16" selection-start-line="15" selection-start-column="16" selection-end-line="15" selection-end-column="16" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#1002#1003#0" expanded="true" />
<element signature="e#1046#1047#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Menu.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="666">
<caret line="178" column="30" selection-start-line="178" selection-start-column="30" selection-end-line="178" selection-end-column="30" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/euglena_basic_stimuli.java"> <entry file="file://$PROJECT_DIR$/src/euglena_basic_stimuli.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="702"> <state relative-caret-position="525">
<caret line="281" column="32" selection-start-line="281" selection-start-column="32" selection-end-line="281" selection-end-column="32" /> <caret line="318" column="9" selection-start-line="318" selection-start-column="9" selection-end-line="318" selection-end-column="9" />
<folding> <folding>
<element signature="e#0#16478#0" expanded="true" /> <element signature="e#0#16478#0" expanded="true" />
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
@ -613,8 +665,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/EuglenaApplet.java"> <entry file="file://$PROJECT_DIR$/src/EuglenaApplet.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="630"> <state relative-caret-position="443">
<caret line="38" column="0" selection-start-line="38" selection-start-column="0" selection-end-line="38" selection-end-column="0" /> <caret line="41" column="24" selection-start-line="41" selection-start-column="24" selection-end-line="41" selection-end-column="24" />
<folding> <folding>
<element signature="e#322#323#0" expanded="true" /> <element signature="e#322#323#0" expanded="true" />
<element signature="e#367#368#0" expanded="true" /> <element signature="e#367#368#0" expanded="true" />

View File

@ -25,6 +25,20 @@ class Camera {
} }
} }
boolean updateImage() {
boolean newImageAvailable = cam.available();
if (newImageAvailable) {
cam.read();
}
return newImageAvailable;
}
Capture getCam() {
return cam;
}
} }

View File

@ -18,7 +18,7 @@ public class EuglenaApplet extends PApplet {
@Override @Override
public void settings() { public void settings() {
size(1000, 1000, P2D); size(1920, 1200, P2D);
} }
@Override @Override
@ -26,22 +26,23 @@ public class EuglenaApplet extends PApplet {
clear(); clear();
smooth(); smooth();
// Start up projectorApplet window
projectorApplet = new ProjectorApplet();
String[] args = {"Euglena projector"};
PApplet.runSketch(args, projectorApplet);
camera = new Camera(this, cameraMode); camera = new Camera(this, cameraMode);
ledControl = new LEDControl(this, whichArduino); ledControl = new LEDControl(this, whichArduino);
menu = new Menu(this); menu = new Menu(this);
// Start up projectorApplet window
// Do this last, in case ProjectorApplet wants to use the camera, arduino, etc.
projectorApplet = new ProjectorApplet();
String[] args = {"Euglena projector"};
PApplet.runSketch(args, projectorApplet);
} }
@Override @Override
public void draw() { public void draw() {
clear(); camera.updateImage();
fill(255); imageMode(PApplet.CORNER);
rect(50, 50, 100, 100); image(camera.getCam(), 0, 0, width - menu.width, height);
} }

View File

@ -20,12 +20,12 @@ class LEDControl {
} }
PApplet.print("Using arduino "); PApplet.print("Using arduino ");
PApplet.println(arduinos[whichArduino]); PApplet.println(arduinos[whichArduino]);
this.arduino = new Arduino(applet, arduinos[whichArduino], comRate); this.arduino = new Arduino(applet, arduinos[whichArduino], comRate);
this.arduino.pinMode(Direction.LEFT.pin, Arduino.OUTPUT); for (Direction dir : Direction.values()) {
this.arduino.pinMode(Direction.RIGHT.pin, Arduino.OUTPUT); this.arduino.pinMode(dir.pin, Arduino.OUTPUT);
this.arduino.pinMode(Direction.UP.pin, Arduino.OUTPUT); }
this.arduino.pinMode(Direction.DOWN.pin, Arduino.OUTPUT);
} }
} }
@ -51,6 +51,19 @@ class LEDControl {
} }
} }
public void allOn() {
for (Direction dir : Direction.values()) {
turnOn(dir);
}
}
public void allOff() {
for (Direction dir : Direction.values()) {
turnOff(dir);
}
}
enum Direction { enum Direction {
LEFT (0, 10), LEFT (0, 10),
RIGHT (1, 5), RIGHT (1, 5),