Assignment 4: Learning Processing Chapters 11, 12, 15, & 16

Hello again everyone!

I thought this week would be super tough, but to my surprise I found the material really easy to get through. This is probably because we’ve learned the basics and now it’s all about application. So this week I took my series of ‘Fraag the Frog’ sketches to the next level through the use of libraries. I was really fascinated with the live video capture features shown in the book and I also thought it would be nice to influence the sketch with your body.

*IMPORTANT: I just realized it is considered malicious to capture video from from users’ cameras and so the sketches below do not work right off the bat. As an alternative method, please click each link to view and copy the source code so that you may use the sketch on your own computer. Please try it out! 

So get ready to use your cameras and move around a little bit.

//FRAAG the Frog
//Version #7
//VIDEO: Motion Sensor
//Reference: Learning Processing by Daniel Shiffman, Chapter 16 - Example 16-13

//Instructions: Move in front of your webcam to influence the movement of the Sun/Moon.
//Note: Code can be a bit buggy, so make sure you are moving only one part of your body at a time.
//Click the mouse to toggle day and night.

Click the image below to view, copy and paste the source code:

 
___________________________________________________________________________________________
//FRAAG the Frog
//Version #8
//VIDEO: Color Tracking
//Reference: Learning Processing by Daniel Shiffman, Chapter 16 - Exercise 16-5

//Instructions: When the video begins you should hold a unique coloured object (like a neon post-it note or highlighter) in front of the
//cam and click the mouse where that object appears on the video screen to sample its colour. Now you can move that object in front of
//your webcam to influence the movement of the Sun/Moon. Pressing any key is now used to toggle day and night. The video only displays
//if the mouse is pressed and remains on until you choose to sample a new colour by clicking the mouse again.
//Note: Code can be a bit buggy, try to find a unique coloured object.

Click the image below to view, copy and paste the source code:

UPDATE: I know this second sketch was not working because there were separate tabs. I’ve combined them now so that the code works.

If you’re wondering how I mirrored the on-screen movement, have a look at this code I wrote to manipulate the motion detected on the X-axis. It might be helpful to anyone wanting to do motion sensing without having their image flipped.

    //IMPORTANT: Reverse the X-axis so that movement is mirrored and does not appear to be opposite!
    //Use avgX and avgY from this point on to track movement, instead of mouseX and mouseY.
      avgX = (width/2+(width/2 - avgX));

I hope you’ve found this entertaining. Can’t wait to start something new this week.

1 comment to Assignment 4: Learning Processing Chapters 11, 12, 15, & 16

  • David Anthony Oppenheim

    Hey Harjot, Nice work. Definitely entertaining to swat the sun (or moon) around the screen.