The Camera as a Sensor *

Size: px
Start display at page:

Download "The Camera as a Sensor *"

Transcription

1 OpenStax-CNX module: m The Camera as a Sensor * Davide Rocchesso This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract Simple yet signicant computer vision tasks are made accessible in the Processing language and environment. Pixel-by-pixel processing is possible through the GSVideo library. The JavacvPro library provides access to a large set of functions of OpenCV. In Computer Science, computer vision studies the computational aspects of vision and develops camerabased systems as input devices. Simple techniques of pixel-by-pixel manipulation can be used to implement simple vision mechanisms. The examples that follow are taken from Learning Processing by Daniel Shiman 1 and adapted to use the GSVideo 2 library. A nice introductory article on Computer Vision for Artists and Designers: Pedagogic Tools and Techniques for Novice Programmers has been written by Golan Levin 3. 1 Color Tracking In the code p. 1, the target color is searched pixel-by-pixel in the image buer video, of size video.width * video.height. For example, the pixel of coordinates (2,3) (third row, fourth column) is accessed in position 3 + 2*video.width of the unrolled array containing all the pixels. The target color is selected via mouse clicking. // Daniel Shiffman // // Example 16-11: Simple color tracking // Modified by Davide Rocchesso // Variable for capture device GSCapture video; // A variable for the color we are searching for. color trackcolor; * Version 1.2: May 7, :15 am

2 OpenStax-CNX module: m void setup() { size(320,240); video = new GSCapture(this,width,height,15); video.start(); // Start off tracking for red trackcolor = color(255,0,0); smooth(); void draw() { // Capture and display the video if (video.available()) { video.read(); video.loadpixels(); image(video,0,0); // Before we begin searching, the "world record" for closest color is set to a high number that is eas float worldrecord = 500; // XY coordinate of closest color int closestx = 0; int closesty = 0; // Begin loop to walk through every pixel for (int x = 0; x < video.width; x ++ ) { for (int y = 0; y < video.height; y ++ ) { int loc = x + y*video.width; // What is current color color currentcolor = video.pixels[loc]; float r1 = red(currentcolor); float g1 = green(currentcolor); float b1 = blue(currentcolor); float r2 = red(trackcolor); float g2 = green(trackcolor); float b2 = blue(trackcolor); // Using euclidean distance to compare colors float d = dist(r1,g1,b1,r2,g2,b2); // We are using the dist( ) function to compare the current col // If current color is more similar to tracked color than // closest color, save current location and current difference if (d < worldrecord) { worldrecord = d; closestx = x; closesty = y; // We only consider the color found if its color distance is less than 10.

3 OpenStax-CNX module: m // This threshold of 10 is arbitrary and you can adjust this number depending on how accurate you requ if (worldrecord < 10) { // Draw a circle at the tracked pixel fill(trackcolor); strokeweight(4.0); stroke(0); ellipse(closestx,closesty,16,16); void mousepressed() { // Save color where the mouse is clicked in trackcolor variable int loc = mousex + mousey*video.width; trackcolor = video.pixels[loc]; 2 Background Removal By explicitely storing a background in a buer, it is relatively easy to remove it from the images grabbed with a video camera, provided that the illumination condition remain constant and that the camera is not automatically adjusting its exposure. In the code p. 3, the background is stored upon a mouse click. At each frame, the color of each pixel is compared with the corresponding pixel in the background image, and if such dierence is large enough it is considered to stay in the foreground. // Daniel Shiffman // // Example 16-12: Simple background removal // Modified by Davide Rocchesso // Click the mouse to memorize a current background image // Variable for capture device GSCapture video; // Saved background PImage backgroundimage; // How different must a pixel be to be a foreground pixel float threshold = 20; void setup() { size(320,240); video = new GSCapture(this, width, height, 30); video.start(); // Create an empty image the same size as the video backgroundimage = createimage(video.width,video.height,rgb);

4 OpenStax-CNX module: m void draw() { // Capture video if (video.available()) { video.read(); // We are looking at the video's pixels, the memorized backgroundimage's pixels, as well as accessing // So we must loadpixels() for all! loadpixels(); video.loadpixels(); backgroundimage.loadpixels(); // Begin loop to walk through every pixel for (int x = 0; x < video.width; x ++ ) { for (int y = 0; y < video.height; y ++ ) { int loc = x + y*video.width; // Step 1, what is the 1D pixel location color fgcolor = video.pixels[loc]; // Step 2, what is the foreground color // Step 3, what is the background color color bgcolor = backgroundimage.pixels[loc]; // Step 4, compare the foreground and background color float r1 = red(fgcolor); float g1 = green(fgcolor); float b1 = blue(fgcolor); float r2 = red(bgcolor); float g2 = green(bgcolor); float b2 = blue(bgcolor); float diff = dist(r1,g1,b1,r2,g2,b2); // Step 5, Is the foreground color different from the background color if (diff > threshold) { // If so, display the foreground color pixels[loc] = fgcolor; else { // If not, display green pixels[loc] = color(0,255,0); // We could choose to replace the background pixels with something updatepixels(); void mousepressed() { // Copying the current frame of video into the backgroundimage object // Note copy takes 5 arguments: // The source image // x,y,width, and height of region to be copied from the source // x,y,width, and height of copy destination backgroundimage.copy(video,0,0,video.width,video.height,0,0,video.width,video.height); backgroundimage.updatepixels();

5 OpenStax-CNX module: m Motion Detection To highlight motion, it is sucient to compare, pixel-by-pixel, the current frame with the previous frame. In the code Section 3 (Motion Detection ), if the color dierence is larger than a threshold than the pixel is colored black. // Daniel Shiffman // // Example 16-13: Simple motion detection // Modified by Davide Rocchesso // Variable for capture device GSCapture video; // Previous Frame PImage prevframe; // How different must a pixel be to be a "motion" pixel float threshold = 50; void setup() { size(320,240); video = new GSCapture(this, width, height, 30); video.start(); // Create an empty image the same size as the video prevframe = createimage(video.width,video.height,rgb); void draw() { // Capture video if (video.available()) { // Save previous frame for motion detection!! prevframe.copy(video,0,0,video.width,video.height,0,0,video.width,video.height); // Before we read t prevframe.updatepixels(); video.read(); loadpixels(); video.loadpixels(); prevframe.loadpixels(); // Begin loop to walk through every pixel for (int x = 0; x < video.width; x ++ ) { for (int y = 0; y < video.height; y ++ ) { int loc = x + y*video.width; // Step 1, what is the 1D pixel location

6 OpenStax-CNX module: m color current = video.pixels[loc]; // Step 2, what is the current color color previous = prevframe.pixels[loc]; // Step 3, what is the previous color // Step 4, compare colors (previous vs. current) float r1 = red(current); float g1 = green(current); float b1 = blue(current); float r2 = red(previous); float g2 = green(previous); float b2 = blue(previous); float diff = dist(r1,g1,b1,r2,g2,b2); // Step 5, How different are the colors? // If the color at that pixel has changed, then there is motion at that pixel. if (diff > threshold) { // If motion, display black pixels[loc] = color(0); else { // If not, display white pixels[loc] = color(255); updatepixels(); 4 OpenCV In 1999 Intel Research decided to develop a software library to encourage the development of CPU-intensive applications. Image processing and computer vision tasks certainly make intensive use of the CPU. Objectives of OpenCV to advance research by providing a set of optimized base functions; to encourage the production of readable and reusable software; to encourage the production of commercial software that uses an open and free infrastructure (through proper licensing). The library is written in C language, for maximal eciency and portability, but there are wrappers for C++ (openframeworks), C#, Pyton, Java (JavaCV), and Processing (OpenCV and JavacvPro). It is available under several operating systems, including Linux, Windows, Mac OS, Android, and ios. After several beta releases the rst 1.0 version was released in 2006, and the 2.0 was released in october 2009, with a new C++ interface. At the moment of writing OpenCV 2.4 has been released and is available through the developer web site 4. Within the Processing language and environment, a small set of OpenCV functions has been available for years through the OpenCV "hypermedia" library. The available functions were real-time capture, video le import, basic image treatment, face and body identication, and blob detection. A quick introduction to the use of this library can be found in Andy Best's tutorial 5 or in Programming Interactivity by Joshua Noble 6. This library, no longer updated, is now superseeded by the JavacvPro library 7, which has a much larger set of functions. The JavacvPro library makes its operations on a buer, and it uses two auxiliary buers where images can be stored and recalled with remember() and restore() operations. This allows, for example, to compute the dierence between two neighboring frames

7 OpenStax-CNX module: m Manipulation of buers in OpencvPro Figure 1 Example 1: Background subtraction import monclubelec.javacvpro.*; OpenCV opencv; GSCapture cam; //declare an OpenCV object //declare a camera object void setup(){ size(320,240); opencv = new OpenCV(this); //objectcv instance opencv.allocate(320,240); cam = new GSCapture(this,320,240); //prepare for reading a video stream cam.start();

8 OpenStax-CNX module: m void draw(){ if (cam.available()){ cam.read(); //frame grabbing opencv.copy(cam.get()); opencv.absdiff(); //difference of frames: result in Memory2 image(opencv.getmemory2(),0,0); //display the difference image void keypressed() { opencv.remember(); //store the frame in the memory buffer println("remember"); // stop processing public void stop(){ cam.delete(); super.stop(); By addition of opencv.remember() as the last line of the internal block of the draw() function, the dierence is computed between two contiguous frames, thus obtaining a visualization of motion. If, instead of the image(opencv.getmemory2(),0,0), we put the instructions opencv.restore2(); opencv.gray(); opencv.threshold(0.5); image(opencv.getbuffer(),0,0); the dierence is reduced to gray levels and then thresholded at 0.5 level. Example 2: Blob Tracking Within a frame, a blob is a contiguous area represented in a data structure. A blob has a contour that represent a contrasting edge with neighboring regions. Tracking an object means to follow in time its corresponding blob that is moving across the screen. Previous-frame blobs are compared with the current-frame blobs to identify those blobs that are likely to keep representing the same object. The following code has been derived from Programming Interactivity by Joshua Noble 8, adapted to use the JavacvPro library. import monclubelec.javacvpro.*; int IMG_WIDTH = 320; int IMG_HEIGHT = 240; int BLURAMOUNT = 7; float THRESHOLD = 0.8; OpenCV opencv; 8

9 OpenStax-CNX module: m GSCapture cam; void setup(){ size(img_width*2, IMG_HEIGHT*2); cam = new GSCapture(this, IMG_WIDTH, IMG_HEIGHT); opencv = new OpenCV(this); opencv.allocate(img_width, IMG_HEIGHT); cam.start(); void draw(){ if (cam.available() == true) { cam.read(); opencv.copy(cam.get()); opencv.remember(); opencv.blur(bluramount); image(opencv.getbuffer(),img_width,0); opencv.restore(); opencv.invert(); image(opencv.getbuffer(),0,img_height); opencv.restore(); opencv.gray(); opencv.threshold(threshold); image(opencv.getbuffer(),0,0); // Args: minareain, maxareain, maxblobin, findholesin, maxverticesin, debug Blob[] blobs = opencv.blobs(opencv.area()/256, opencv.area()/2, 20, false, 100, false); for (int i=0; i < blobs.length; i++){ nofill(); rect(blobs[i].rectangle.x, blobs[i].rectangle.y, blobs[i].rectangle.width, blobs[i].rectangle.height stroke(0,0,255); line(blobs[i].centroid.x-5, blobs[i].centroid.y, blobs[i].centroid.x+5, blobs[i].centroid.y); line(blobs[i].centroid.x, blobs[i].centroid.y-5, blobs[i].centroid.x, blobs[i].centroid.y+5); fill(255,0,255,64); stroke(0,255,0); if (blobs[i].points.length > 0){ beginshape(); for (int j=0; j < blobs[i].points.length; j++){ vertex(blobs[i].points[j].x, blobs[i].points[j].y); endshape(close); Example 3: Face Detection With OpenCV, it is possible to load the conguration of a classier that has been trained to recognize a specic shape, such as a human face or body.

10 OpenStax-CNX module: m import monclubelec.javacvpro.*; import java.awt.*; // for classes Point, Rectangle,... OpenCV opencv; GSCapture cam; //declare an OpenCV object //declare a camera object void setup(){ size(320,240); opencv = new OpenCV(this); //objectcv instance opencv.allocate(320,240); cam = new GSCapture(this,320,240); //prepare for reading a video stream cam.start(); opencv.cascade("/usr/local/share/opencv/haarcascades/","haarcascade_frontalface_alt.xml"); // load th void draw(){ if (cam.available()){ cam.read(); //frame grabbing opencv.copy(cam.get()); image(opencv.getbuffer(),0,0); Rectangle[] faces = opencv.detect(); //look for faces nofill(); stroke(255,0,0); for (int i=0; i < faces.length; i++) rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);

Lecture 6: Processing

Lecture 6: Processing stanford hci group / cs377s Designing Applications that See Lecture 6: Processing Dan Maynes-Aminzade 24 January 2008 Designing Applications that See http://cs377s.stanford.edu Reminders Assignment t#

More information

Class Notes CN19 Class PImage Page

Class Notes CN19 Class PImage Page 1 Images and the Graphics Window Prior to beginning the work with different parts of the libraries, we spent time with classes. One reason for that was to provide some background when we started this part

More information

Watch the following for more announcements

Watch the following for more announcements Review "plain text file" loadstrings() split() splittokens() selectinput() println(), float(), int(), can take an array argument, will return an array easy way to convert an array of Strings to an array

More information

We will start our journey into Processing with creating static images using commands available in Processing:

We will start our journey into Processing with creating static images using commands available in Processing: Processing Notes Chapter 1: Starting Out We will start our journey into Processing with creating static images using commands available in Processing: rect( ) line ( ) ellipse() triangle() NOTE: to find

More information

CS 101 Media (Images, Video, etc) Lecture 20

CS 101 Media (Images, Video, etc) Lecture 20 CS 101 Media (Images, Video, etc) Lecture 20 1 Images Though we ve displayed many shapes and colors to the screen, we have yet to display an actual image! Processing has a special type called PImage, for

More information

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013 1. A first program // Create 200x200 canvas // Print favorite quote size(200, 200); println("it is what it is"); // Draw rectangle and a line rect(100,100,50,50); line(0,0,50,50); // Save as.pde. Can be

More information

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created. + Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create

More information

Miscellaneous Stuff That Might Be Important.

Miscellaneous Stuff That Might Be Important. 1 Miscellaneous Stuff That Might Be Important. Variable mousepressed VS function mousepressed( ) For much of the work in this class, it is usually safer to use the function form of mousepressed( ) instead

More information

Conditional Events. Mouse events and Operators. Dr. Siobhán Drohan Mairead Meagher. Produced by:

Conditional Events. Mouse events and Operators. Dr. Siobhán Drohan Mairead Meagher. Produced by: Conditional Events Mouse events and Operators Produced by: Dr. Siobhán Drohan Mairead Meagher Department of Computing and Mathematics http://www.wit.ie/ Topics list Mouse Events Recap: Arithmetic Operators

More information

1 Getting started with Processing

1 Getting started with Processing cisc3665, fall 2011, lab I.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For

More information

Real Time Data Plotting

Real Time Data Plotting Real Time Data Plotting Introduction This lesson will show how to write a program plot data on a X-Y graph. On the Arduino, write a program to sample a sensor and print the voltage to the Serial interface.

More information

CSE120 Wi18 Final Review

CSE120 Wi18 Final Review CSE120 Wi18 Final Review Practice Question Solutions 1. True or false? Looping is necessary for complex programs. Briefly explain. False. Many loops can be explicitly written out as individual statements

More information

A B C D CS105 03a Interaction

A B C D CS105 03a Interaction Interaction Function Definition Events Built-in Variables CS105 03a Interaction 1 Which image is drawn by this code? strokeweight(10); stroke(0, 255, 0); // green line(99, 0, 0, 99); stroke(200, 0, 200);

More information

The way I feel about music is that there is no right and wrong. Only true and false. Fiona Apple. true false false

The way I feel about music is that there is no right and wrong. Only true and false. Fiona Apple. true false false 5 Conditionals Conditionals 59 That language is an instrument of human reason, and not merely a medium for the expression of thought, is a truth generally admitted. George Boole The way I feel about music

More information

CISC 1600, Lab 2.2: Interactivity in Processing

CISC 1600, Lab 2.2: Interactivity in Processing CISC 1600, Lab 2.2: Interactivity in Processing Prof Michael Mandel 1 Getting set up For this lab, we will again be using Sketchpad, a site for building processing sketches online using processing.js.

More information

IMAGE PROCESSING OVERVIEW

IMAGE PROCESSING OVERVIEW IMAGE PROCESSING OVERVIEW During this section of the workshop, participants will have an opportunity to learn the fundamentals of image processing. The concepts explored in this section have familiar applications

More information

Interaction Design A.A. 2017/2018

Interaction Design A.A. 2017/2018 Corso di Laurea Magistrale in Design, Comunicazione Visiva e Multimediale - Sapienza Università di Roma Interaction Design A.A. 2017/2018 7 Conditionals in Processing Francesco Leotta, Andrea Marrella

More information

CISC 1600, Lab 3.2: Interactivity in Processing

CISC 1600, Lab 3.2: Interactivity in Processing CISC 1600, Lab 3.2: Interactivity in Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using OpenProcessing, a site for building processing sketches online using processing.js. 1.1.

More information

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

CISC 1600 Lecture 2.2 Interactivity&animation in Processing CISC 1600 Lecture 2.2 Interactivity&animation in Processing Topics: Interactivity: keyboard and mouse variables Interactivity: keyboard and mouse listeners Animation: vector graphics Animation: bitmap

More information

Lab Lab 4 : Pretty, Pretty Pretty, Pretty Pictures Picture Joshua Cuneo

Lab Lab 4 : Pretty, Pretty Pretty, Pretty Pictures Picture Joshua Cuneo Computation as an Expressive Medium Lab 4: Pretty, Pretty Pictures Joshua Cuneo For today ¼ Checkpoint Building Blocks Assignment 2 Images + More Images Accessing Pixels 2D Arrays Project 2 Checkpoint

More information

Introduction to Processing

Introduction to Processing Processing Introduction to Processing Processing is a programming environment that makes writing programs easier. It contains libraries and functions that make interacting with the program simple. The

More information

CSC 220 Object-Oriented Multimedia Programming, Spring 2017

CSC 220 Object-Oriented Multimedia Programming, Spring 2017 CSC 220 Object-Oriented Multimedia Programming, Spring 2017 Dr. Dale E. Parson, Assignment 2, Working with 3D shapes and geometric transforms. This assignment is due via D2L Dropbox Assignment 2 ShapePaint3DIntro

More information

Module 01 Processing Recap. CS 106 Winter 2018

Module 01 Processing Recap. CS 106 Winter 2018 Module 01 Processing Recap CS 106 Winter 2018 Processing is a language a library an environment Variables A variable is a named value. It has a type (which can t change) and a current value (which can

More information

Interaction Design A.A. 2017/2018

Interaction Design A.A. 2017/2018 Corso di Laurea Magistrale in Design, Comunicazione Visiva e Multimediale - Sapienza Università di Roma Interaction Design A.A. 2017/2018 5 Basics of Processing Francesco Leotta, Andrea Marrella Last update

More information

CISC 1600 Lecture 3.1 Introduction to Processing

CISC 1600 Lecture 3.1 Introduction to Processing CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists

More information

Basic Computer Programming (Processing)

Basic Computer Programming (Processing) Contents 1. Basic Concepts (Page 2) 2. Processing (Page 2) 3. Statements and Comments (Page 6) 4. Variables (Page 7) 5. Setup and Draw (Page 8) 6. Data Types (Page 9) 7. Mouse Function (Page 10) 8. Keyboard

More information

mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut

mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu Important Review Does the animation leave a trace? Are the moving objects move without a

More information

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

CISC 1600 Lecture 2.2 Interactivity&animation in Processing CISC 1600 Lecture 2.2 Interactivity&animation in Processing Topics: Interactivity: keyboard and mouse variables Interactivity: keyboard and mouse listeners Animation: vector graphics Animation: bitmap

More information

2D Shapes. Creative Coding & Generative Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar

2D Shapes. Creative Coding & Generative Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar 2D Shapes Creative Coding & Generative Art in Processing 2 Ira Greenberg, Dianna Xu, Deepak Kumar Did you do this? Read Chapter 2 (pages 33-50) Read and do the Coordinate Systems & Shapes and Color tutorials

More information

The Processing language

The Processing language The Processing language Developed by Ben Fry and Casey Reas at MIT in 2001 Related to the languages Logo and Java Free, open-source software processing.org contains many programming resources www.openprocessing.org

More information

Basic Input and Output

Basic Input and Output Basic Input and Output CSE 120 Winter 2019 Instructor: Teaching Assistants: Justin Hsia Ann Shan, Eunia Lee, Pei Lee Yap, Sam Wolfson, Travis McGaha Facebook to integrate WhatsApp, Instagram and Messenger

More information

Introduction to Programming (Java) 4/12

Introduction to Programming (Java) 4/12 Introduction to Programming (Java) 4/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

Transportation Informatics Group, ALPEN-ADRIA University of Klagenfurt. Transportation Informatics Group University of Klagenfurt 12/24/2009 1

Transportation Informatics Group, ALPEN-ADRIA University of Klagenfurt. Transportation Informatics Group University of Klagenfurt 12/24/2009 1 Machine Vision Transportation Informatics Group University of Klagenfurt Alireza Fasih, 2009 12/24/2009 1 Address: L4.2.02, Lakeside Park, Haus B04, Ebene 2, Klagenfurt-Austria 2D Shape Based Matching

More information

[ the academy_of_code] Senior Beginners

[ the academy_of_code] Senior Beginners [ the academy_of_code] Senior Beginners 1 Drawing Circles First step open Processing Open Processing by clicking on the Processing icon (that s the white P on the blue background your teacher will tell

More information

Using Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Using Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics Using Methods Methods that handle events Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Caveat The term function is used in Processing e.g. line(),

More information

Module 01 Processing Recap

Module 01 Processing Recap Module 01 Processing Recap Processing is a language a library an environment Variables A variable is a named value. It has a type (which can t change) and a current value (which can change). Variables

More information

Repetition is the reality and the seriousness of life. Soren Kierkegaard

Repetition is the reality and the seriousness of life. Soren Kierkegaard 6 Loops Loops 81 Repetition is the reality and the seriousness of life. Soren Kierkegaard What s the key to comedy? Repetition. What s the key to comedy? Repetition. Anonymous In this chapter: The concept

More information

University of Cincinnati. P5.JS: Getting Started. p5.js

University of Cincinnati. P5.JS: Getting Started. p5.js p5.js P5.JS: Getting Started Matthew Wizinsky University of Cincinnati School of Design HTML + CSS + P5.js File Handling & Management Environment Canvas Coordinates Syntax Drawing Variables Mouse Position

More information

To specify the dimensions of the drawing canvas use the size statement: ! size( 300, 400 );

To specify the dimensions of the drawing canvas use the size statement: ! size( 300, 400 ); Study Guide We have examined three main topics: drawing static pictures, drawing simple moving pictures, and manipulating images. The Final Exam will be concerned with each of these three topics. Each

More information

Basic Input and Output

Basic Input and Output Basic Input and Output CSE 120 Spring 2017 Instructor: Justin Hsia Teaching Assistants: Anupam Gupta, Braydon Hall, Eugene Oh, Savanna Yee Administrivia Assignments: Animal Functions due today (4/12) Reading

More information

1. Complete these exercises to practice creating user functions in small sketches.

1. Complete these exercises to practice creating user functions in small sketches. Lab 6 Due: Fri, Nov 4, 9 AM Consult the Standard Lab Instructions on LEARN for explanations of Lab Days ( D1, D2, D3 ), the Processing Language and IDE, and Saving and Submitting. Rules: Do not use the

More information

Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1

Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1 Conditionals Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary CS105 04 Conditionals 1 Pick a number CS105 04 Conditionals 2 Boolean Expressions An expression that

More information

CISC 1600, Lab 3.1: Processing

CISC 1600, Lab 3.1: Processing CISC 1600, Lab 3.1: Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using OpenProcessing, a site for building processing sketches online using processing.js. 1.1. Go to https://www.openprocessing.org/class/57767/

More information

Solution Notes. COMP 151: Terms Test

Solution Notes. COMP 151: Terms Test Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Solution Notes COMP 151: Terms

More information

Notes from the Boards Set # 5 Page

Notes from the Boards Set # 5 Page 1 Yes, this stuff is on the exam. Know it well. Read this before class and bring your questions to class. Starting today, we can no longer write our code as a list of function calls and variable declarations

More information

EXAMINATIONS 2017 TRIMESTER 2

EXAMINATIONS 2017 TRIMESTER 2 EXAMINATIONS 2017 TRIMESTER 2 CGRA 151 INTRODUCTION TO COMPUTER GRAPHICS Time Allowed: TWO HOURS CLOSED BOOK Permitted materials: Silent non-programmable calculators or silent programmable calculators

More information

Computer Graphics. Interaction

Computer Graphics. Interaction Computer Graphics Interaction Jordi Linares i Pellicer Escola Politècnica Superior d Alcoi Dep. de Sistemes Informàtics i Computació jlinares@dsic.upv.es http://www.dsic.upv.es/~jlinares processing allows

More information

CISC 1600, Lab 2.1: Processing

CISC 1600, Lab 2.1: Processing CISC 1600, Lab 2.1: Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using Sketchpad, a site for building processing sketches online using processing.js. 1.1. Go to http://cisc1600.sketchpad.cc

More information

Variables. location where in memory is the information stored type what sort of information is stored in that memory

Variables. location where in memory is the information stored type what sort of information is stored in that memory Variables Processing, like many programming languages, uses variables to store information Variables are stored in computer memory with certain attributes location where in memory is the information stored

More information

Variables One More (but not the last) Time with feeling

Variables One More (but not the last) Time with feeling 1 One More (but not the last) Time with feeling All variables have the following in common: a name a type ( int, float, ) a value an owner We can describe variables in terms of: who owns them ( Processing

More information

if / if else statements

if / if else statements if / if else statements December 1 2 3 4 5 Go over if notes and samples 8 9 10 11 12 Conditionals Quiz Conditionals TEST 15 16 17 18 19 1 7:30 8:21 2 8:27 9:18 3 9:24 10:14 1 CLASS 7:30 8:18 1 FINAL 8:24

More information

CSE/EE-576, Final Project

CSE/EE-576, Final Project 1 CSE/EE-576, Final Project Torso tracking Ke-Yu Chen Introduction Human 3D modeling and reconstruction from 2D sequences has been researcher s interests for years. Torso is the main part of the human

More information

Functions. Functions. nofill(); point(20, 30); float angle = map(i, 0, 10, -2, 2); parameters return values

Functions. Functions. nofill(); point(20, 30); float angle = map(i, 0, 10, -2, 2); parameters return values Functions parameters return values 06 Functions 1 Functions Code that is packaged so it can be run by name Often has parameters to change how the function works (but not always) Often performs some computation

More information

Old 257 Exam #2s for Practice

Old 257 Exam #2s for Practice Old Exam #2s 257/757 Exploring Programming with Graphics Page 1 Old 257 Exam #2s for Practice Exams will be taken on Thursday March 27 in the cluster. You will have the entire class time to do the exam.

More information

CS110 Introduction to Computing Fall 2016 Practice Exam 1 -- Solutions

CS110 Introduction to Computing Fall 2016 Practice Exam 1 -- Solutions CS110 Introduction to Computing Fall 2016 Practice Exam 1 -- Solutions The exam will be closed-note and closed-book; please consider this fact before using your notes on this practice version. Please see

More information

Topic 7: Algebraic Data Types

Topic 7: Algebraic Data Types Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,

More information

CMSC427 Interac/ve programs in Processing: Polyline editor

CMSC427 Interac/ve programs in Processing: Polyline editor CMSC427 Interac/ve programs in Processing: Polyline editor Interactive programming Example: PaperSnowFlake hbp://rectangleworld.com/papersnowflake/ Big ideas today Event driven programming Object list

More information

Introduction to Flash - Creating a Motion Tween

Introduction to Flash - Creating a Motion Tween Introduction to Flash - Creating a Motion Tween This tutorial will show you how to create basic motion with Flash, referred to as a motion tween. Download the files to see working examples or start by

More information

Project Report for EE7700

Project Report for EE7700 Project Report for EE7700 Name: Jing Chen, Shaoming Chen Student ID: 89-507-3494, 89-295-9668 Face Tracking 1. Objective of the study Given a video, this semester project aims at implementing algorithms

More information

What is a variable? A named locajon in the computer s memory. A variable stores values

What is a variable? A named locajon in the computer s memory. A variable stores values Chapter 4 Summary/review coordinate system basic drawing commands and their parameters (rect, line, ellipse,background, stroke, fill) color model - RGB + alpha Processing IDE - entering/saving/running

More information

Basic Input and Output

Basic Input and Output Basic Input and Output CSE 120 Winter 2018 Instructor: Teaching Assistants: Justin Hsia Anupam Gupta, Cheng Ni, Eugene Oh, Sam Wolfson, Sophie Tian, Teagan Horkan How the Facebook algorithm update will

More information

CS 106 Winter Lab 05: User Interfaces

CS 106 Winter Lab 05: User Interfaces CS 106 Winter 2018 Lab 05: User Interfaces Due: Wednesday, February 6th, 11:59pm This lab will allow you to practice User Interfaces using Direct Manipulation and ControlP5. Each question is on a separate

More information

Mouse Pointer Tracking with Eyes

Mouse Pointer Tracking with Eyes Mouse Pointer Tracking with Eyes H. Mhamdi, N. Hamrouni, A. Temimi, and M. Bouhlel Abstract In this article, we expose our research work in Human-machine Interaction. The research consists in manipulating

More information

Connected Component Analysis and Change Detection for Images

Connected Component Analysis and Change Detection for Images Connected Component Analysis and Change Detection for Images Prasad S.Halgaonkar Department of Computer Engg, MITCOE Pune University, India Abstract Detection of the region of change in images of a particular

More information

Digital Image Processing COSC 6380/4393

Digital Image Processing COSC 6380/4393 Digital Image Processing COSC 6380/4393 Lecture 21 Nov 16 th, 2017 Pranav Mantini Ack: Shah. M Image Processing Geometric Transformation Point Operations Filtering (spatial, Frequency) Input Restoration/

More information

Programming for Non-Programmers

Programming for Non-Programmers Programming for Non-Programmers Python Chapter 2 Source: Dilbert Agenda 6:00pm Lesson Begins 6:15pm First Pillow example up and running 6:30pm First class built 6:45pm Food & Challenge Problem 7:15pm Wrap

More information

Basic Input and Output

Basic Input and Output Basic Input and Output CSE 120 Spring 2017 Instructor: Justin Hsia Teaching Assistants: Anupam Gupta, Braydon Hall, Eugene Oh, Savanna Yee How airlines like United choose who to kick off a flight On Sunday

More information

EXAMINATIONS 2016 TRIMESTER 2

EXAMINATIONS 2016 TRIMESTER 2 EXAMINATIONS 2016 TRIMESTER 2 CGRA 151 INTRODUCTION TO COMPUTER GRAPHICS Time Allowed: TWO HOURS CLOSED BOOK Permitted materials: Silent non-programmable calculators or silent programmable calculators

More information

Class #1. introduction, functions, variables, conditionals

Class #1. introduction, functions, variables, conditionals Class #1 introduction, functions, variables, conditionals what is processing hello world tour of the grounds functions,expressions, statements console/debugging drawing data types and variables decisions

More information

GRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing

GRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing BRIDGES TO COMPUTING General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. This work is licensed under the Creative Commons Attribution-ShareAlike

More information

Counting Particles or Cells Using IMAQ Vision

Counting Particles or Cells Using IMAQ Vision Application Note 107 Counting Particles or Cells Using IMAQ Vision John Hanks Introduction To count objects, you use a common image processing technique called particle analysis, often referred to as blob

More information

Exploring Processing

Exploring Processing Exploring Processing What is Processing? Easy-to-use programming environment Let s you edit, run, save, share all in one application Designed to support interactive, visual applications Something we ve

More information

CISC 1600, Lab 2.3: Processing animation, objects, and arrays

CISC 1600, Lab 2.3: Processing animation, objects, and arrays CISC 1600, Lab 2.3: Processing animation, objects, and arrays Prof Michael Mandel 1 Getting set up For this lab, we will again be using Sketchpad. sketchpad.cc in your browser and log in. Go to http://cisc1600.

More information

Java3018: Darkening, Brightening, and Tinting the Colors in a Picture *

Java3018: Darkening, Brightening, and Tinting the Colors in a Picture * OpenStax-CNX module: m44234 1 Java3018: Darkening, Brightening, and Tinting the Colors in a Picture * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution

More information

OpenStax-CNX module: m Java3002r Review * R.G. (Dick) Baldwin

OpenStax-CNX module: m Java3002r Review * R.G. (Dick) Baldwin OpenStax-CNX module: m45762 1 Java3002r Review * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract This module contains

More information

Step 1: Create A New Photoshop Document

Step 1: Create A New Photoshop Document Snowflakes Photo Border In this Photoshop tutorial, we ll learn how to create a simple snowflakes photo border, which can be a fun finishing touch for photos of family and friends during the holidays,

More information

Image Processing (1) Basic Concepts and Introduction of OpenCV

Image Processing (1) Basic Concepts and Introduction of OpenCV Intelligent Control Systems Image Processing (1) Basic Concepts and Introduction of OpenCV Shingo Kagami Graduate School of Information Sciences, Tohoku University swk(at)ic.is.tohoku.ac.jp http://www.ic.is.tohoku.ac.jp/ja/swk/

More information

CS110 Introduction to Computing Fall 2016 Practice Exam 1

CS110 Introduction to Computing Fall 2016 Practice Exam 1 CS110 Introduction to Computing Fall 2016 Practice Exam 1 The exam will be closed-note and closed-book; please consider this fact before using your notes on this practice version. Please see the abbreviated

More information

CST112 Looping Statements Page 1

CST112 Looping Statements Page 1 CST112 Looping Statements Page 1 1 2 3 4 5 Processing: Looping Statements CST112 Algorithms Procedure for solving problem: 1. Actions to be executed 2. Order in which actions are executed order of elements

More information

Depatment of Computer Science Rutgers University CS443 Digital Imaging and Multimedia Assignment 4 Due Apr 15 th, 2008

Depatment of Computer Science Rutgers University CS443 Digital Imaging and Multimedia Assignment 4 Due Apr 15 th, 2008 CS443 Spring 2008 - page 1/5 Depatment of Computer Science Rutgers University CS443 Digital Imaging and Multimedia Assignment 4 Due Apr 15 th, 2008 This assignment is supposed to be a tutorial assignment

More information

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca final float MAX_SPEED = 10; final float BALL_SIZE = 5; void setup() { size(500, 500); void draw() { stroke(255); fill(255);

More information

Loops. Variable Scope Remapping Nested Loops. Donald Judd. CS Loops 1. CS Loops 2

Loops. Variable Scope Remapping Nested Loops. Donald Judd. CS Loops 1. CS Loops 2 Loops Variable Scope Remapping Nested Loops CS105 05 Loops 1 Donald Judd CS105 05 Loops 2 judd while (expression) { statements CS105 05 Loops 3 Four Loop Questions 1. What do I want to repeat? - a rect

More information

float[][] myfloats = new float[10][20]; All elements of a 2D array can be accessed using nested loops

float[][] myfloats = new float[10][20]; All elements of a 2D array can be accessed using nested loops Review We can declare an array of any type, even other arrays A 2D array is an array of arrays float[][] myfloats = new float[10][20]; All elements of a 2D array can be accessed using nested loops for

More information

MathML Editor: The Basics *

MathML Editor: The Basics * OpenStax-CNX module: m26312 1 MathML Editor: The Basics * Natalie Weber This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract This module provides

More information

OpenStax-CNX module: m :Hough Transform * Alice Xie. 2. Software Implementation of the Hough Transform

OpenStax-CNX module: m :Hough Transform * Alice Xie. 2. Software Implementation of the Hough Transform OpenStax-CNX module: m58714 1 2:Hough Transform * Alice Xie This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 2. Software Implementation of the Hough

More information

Unit Testing with JUnit in DrJava *

Unit Testing with JUnit in DrJava * OpenStax-CNX module: m11707 1 Unit Testing with JUnit in DrJava * Stephen Wong Dung Nguyen This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 1.0 Object oriented

More information

Getting Started in Java CIS 110

Getting Started in Java CIS 110 Getting Started in Java CIS 110 2 Your First Program Program name 3 Your First Program The 4 li es aside fro the System.out li e are o sidered the Scaffolding of the program. Section 1.1 4 Your First Program

More information

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca order of operations with the explicit cast! int integervariable = (int)0.5*3.0; Casts happen first! the cast converts the

More information

Processing Assignment Write- Ups

Processing Assignment Write- Ups Processing Assignment Write- Ups Exercise 1-1 Processing is not an elaborate series of points like connect the dots or is it? Can t be cause I got it all wrong when I mapped out each and every point that

More information

This Week Assignment 1 Arrays Time Casting Reading code Project 1

This Week Assignment 1 Arrays Time Casting Reading code Project 1 Computation as an Expressive Medium Lab 2: Kindergarten Cubbies, Back to the Future and Lego Mania Joshua Cuneo This Week Assignment 1 Arrays Time Casting Reading code Project 1 Assignment 1 A1-01: Draw

More information

Using Methods. More on writing methods. Dr. Siobhán Drohan Mairead Meagher. Produced by: Department of Computing and Mathematics

Using Methods. More on writing methods. Dr. Siobhán Drohan Mairead Meagher. Produced by: Department of Computing and Mathematics Using Methods More on writing methods Produced by: Dr. Siobhán Drohan Mairead Meagher Department of Computing and Mathematics http://www.wit.ie/ Topics list Method example: Eyes Method example: X s Overloading

More information

Quick Multitouch Apps using kivy and Python

Quick Multitouch Apps using kivy and Python Quick Multitouch Apps using kivy and Python About Me! Python and Kivy + Setting up Kivy... 1) in Linux 2) in Windows 3) Mac OSX Hello World in Kivy :) Controlling the Environment Many environment variables

More information

How to make a "hello world" program in Java with Eclipse *

How to make a hello world program in Java with Eclipse * OpenStax-CNX module: m43473 1 How to make a "hello world" program in Java with Eclipse * Hannes Hirzel Based on How to make a "hello world" program in Java. by Rodrigo Rodriguez This work is produced by

More information

cs6964 March TOOLKITS Miriah Meyer University of Utah

cs6964 March TOOLKITS Miriah Meyer University of Utah cs6964 March 8 2012 TOOLKITS Miriah Meyer University of Utah administrivia 2 feb 14-23 : proposal meetings march 7 : presentation topics due march 9 : proposals due march 27-april 3 : project updates april

More information

If the ball goes off either the right or left edge, turn the ball around. If x is greater than width or if x is less than zero, reverse speed.

If the ball goes off either the right or left edge, turn the ball around. If x is greater than width or if x is less than zero, reverse speed. Conditionals 75 Reversing the Polarity of a Number When we want to reverse the polarity of a number, we mean that we want a positive number to become negative and a negative number to become positive.

More information

1 Getting started with Processing

1 Getting started with Processing cis3.5, spring 2009, lab II.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For

More information

3D-Modeling with Microscopy Image Browser (im_browser) (pdf version) Ilya Belevich, Darshan Kumar, Helena Vihinen

3D-Modeling with Microscopy Image Browser (im_browser) (pdf version) Ilya Belevich, Darshan Kumar, Helena Vihinen 3D-Modeling with Microscopy Image Browser (im_browser) (pdf version) Ilya Belevich, Darshan Kumar, Helena Vihinen Dataset: Huh7.tif (original), obtained by Serial Block Face-SEM (Gatan 3View) Huh7_crop.tif

More information

Practice Written Examination, Fall 2016 Roger B. Dannenberg, instructor

Practice Written Examination, Fall 2016 Roger B. Dannenberg, instructor 15-104 Practice Written Examination, Fall 2016 Roger B. Dannenberg, instructor Possibly useful function signatures (italics mean an expression goes here ): createcanvas(w, h); width height key background(r,

More information

Bus Detection and recognition for visually impaired people

Bus Detection and recognition for visually impaired people Bus Detection and recognition for visually impaired people Hangrong Pan, Chucai Yi, and Yingli Tian The City College of New York The Graduate Center The City University of New York MAP4VIP Outline Motivation

More information

Requirements for region detection

Requirements for region detection Region detectors Requirements for region detection For region detection invariance transformations that should be considered are illumination changes, translation, rotation, scale and full affine transform

More information