From 8886c3d660ef857bd72d695d39e5eafd19992c38 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Jan 2021 19:36:15 -0600 Subject: Initial commit --- dev/a1_textrain/a1_textrain.pde | 159 ++++++++++++++++++++++++++++++++ dev/a1_textrain/data/TextRainInput.mov | Bin 0 -> 5615074 bytes dev/a1_textrain/data/TextRainInput2.mov | Bin 0 -> 7548818 bytes dev/a1_textrain/data/TextRainInput3.mov | Bin 0 -> 11075890 bytes dev/a1_textrain/data/TextRainInput4.mov | Bin 0 -> 12460114 bytes 5 files changed, 159 insertions(+) create mode 100644 dev/a1_textrain/a1_textrain.pde create mode 100644 dev/a1_textrain/data/TextRainInput.mov create mode 100644 dev/a1_textrain/data/TextRainInput2.mov create mode 100644 dev/a1_textrain/data/TextRainInput3.mov create mode 100644 dev/a1_textrain/data/TextRainInput4.mov (limited to 'dev/a1_textrain') diff --git a/dev/a1_textrain/a1_textrain.pde b/dev/a1_textrain/a1_textrain.pde new file mode 100644 index 0000000..686824c --- /dev/null +++ b/dev/a1_textrain/a1_textrain.pde @@ -0,0 +1,159 @@ +/* + * CSci-4611 Assignment #1 Text Rain + */ + + +/* Note: if Processing's video library does not support your particular combination of webcam and + operating system, then the Sketch may hang in the setup() routine when the list of available + image capture devices is requestd with "Capture.list()". If this happens, you can skip all of + the camera initilization code and just run in movie mode by setting the following global + variable to true. + */ +boolean forceMovieMode = false; + +// Global vars used to access video frames from either a live camera or a prerecorded movie file +import processing.video.*; +String[] cameraModes; +Capture cameraDevice; +Movie inputMovie; +boolean initialized = false; + + +// Both modes of input (live camera and movie) will update this same variable with the lastest +// pixel data each frame. Use this variable to access the new pixel data each frame! +PImage inputImage; + + + +// Called automatically by Processing, once when the program starts up +void setup() { + size(1280, 720); + inputImage = createImage(width, height, RGB); + + if (!forceMovieMode) { + println("Querying avaialble camera modes."); + cameraModes = Capture.list(); + println("Found " + cameraModes.length + " camera modes."); + for (int i=0; i= '0') && (key <= '9')) { + int input = key - '0'; + if (input == 0) { + initializeMovieMode(); + } + else if ((input >= 1) && (input <= 9)) { + initializeLiveCameraMode(input); + } + } + } + else { + // CHECK FOR KEYPRESSES DURING NORMAL OPERATION + // TODO: Fill in your code to handle keypresses here.. + if (key == CODED) { + if (keyCode == UP) { + // up arrow key pressed + } + else if (keyCode == DOWN) { + // down arrow key pressed + } + } + else if (key == ' ') { + // spacebar pressed + } + } +} + + + +// Loads a movie from a file to simulate camera input. +void initializeMovieMode() { + String movieFile = "TextRainInput.mov"; + println("Simulating camera input using movie file: " + movieFile); + inputMovie = new Movie(this, movieFile); + inputMovie.loop(); + initialized = true; +} + + +// Starts up a webcam to use for input. +void initializeLiveCameraMode(int cameraMode) { + println("Activating camera mode #" + cameraMode + ": " + cameraModes[cameraMode]); + cameraDevice = new Capture(this, cameraModes[cameraMode-1]); + cameraDevice.start(); + initialized = true; +} + + +// Draws a quick text-based menu to the screen +void drawMenuScreen() { + int y=10; + text("Press a number key to select an input mode", 20, y); + y += 40; + text("O: Offline mode, test with TextRainInput.mov movie file instead of live camera feed.", 20, y); + y += 40; + for (int i = 0; i < min(9,cameraModes.length); i++) { + text(i+1 + ": " + cameraModes[i], 20, y); + y += 40; + } +} diff --git a/dev/a1_textrain/data/TextRainInput.mov b/dev/a1_textrain/data/TextRainInput.mov new file mode 100644 index 0000000..ae45b66 Binary files /dev/null and b/dev/a1_textrain/data/TextRainInput.mov differ diff --git a/dev/a1_textrain/data/TextRainInput2.mov b/dev/a1_textrain/data/TextRainInput2.mov new file mode 100644 index 0000000..d8fce10 Binary files /dev/null and b/dev/a1_textrain/data/TextRainInput2.mov differ diff --git a/dev/a1_textrain/data/TextRainInput3.mov b/dev/a1_textrain/data/TextRainInput3.mov new file mode 100644 index 0000000..c1e6386 Binary files /dev/null and b/dev/a1_textrain/data/TextRainInput3.mov differ diff --git a/dev/a1_textrain/data/TextRainInput4.mov b/dev/a1_textrain/data/TextRainInput4.mov new file mode 100644 index 0000000..9dff13b Binary files /dev/null and b/dev/a1_textrain/data/TextRainInput4.mov differ -- cgit v1.2.3