-
Not Synced
Okay, so, we are now ready to move on
-
Not Synced
to something, pretty,
different and exciting
-
Not Synced
um, and what that is, is
looking at moving images
-
Not Synced
so we spent all this time saying, okay,
I could have a blank PImage
-
Not Synced
and i could figure out some
interesting algorithmic way
-
Not Synced
to set all the pixels of that image
-
Not Synced
or, I could have an image thats coming
from a file, like frog.jpg
-
Not Synced
and i could load that image, and i'll
have all the access to all the pixels
-
Not Synced
and i could draw it on the screen
and i could manipulate it
-
Not Synced
and do all sorts of stuff
what if, however,
-
Not Synced
we could have a camera,
this is my weird drawing of a camera
-
Not Synced
and what if i could pull in a live image
from a camera into my Processing sketch
-
Not Synced
What could I do with that? what if I had a
you know, a movie file?
-
Not Synced
could I pull in that movie and play back
that movie in my Processing sketch?
-
Not Synced
speeding it up, slowing it down,
going in reverse
-
Not Synced
how could I-, how does all this
stuff work?
-
Not Synced
How do we make this happen? So, let's
first just take the basic transition from
-
Not Synced
flat image file to camera and the way
that we're going to do this
-
Not Synced
is with Processing's Capture object
So, the Capture object, is part of,
-
Not Synced
Processing's video package
Now, I just realized,
-
Not Synced
there's kinda a crucial component to this,
if you are using, and again, this part of
-
Not Synced
the video, sadly, is going to just
become obsolete in a little while
-
Not Synced
but, if you are using the 3.0 alpha series
and, hopefully, there will be a beta soon
-
Not Synced
or a final version, this will be true for
all the 3.0 version's of Processing
-
Not Synced
Let's come over here and look, uh, here,
if i go to, Import Library
-
Not Synced
let me just zoom in here
Import Library >> Add Library
-
Not Synced
and i pull this up, you won't, by default,
have the video library, so I'm going to
-
Not Synced
search under Processing, and this is what
you're looking for, you wanna find
-
Not Synced
in this contributions manager, 'Video'
library by The Processing Foundation
-
Not Synced
so, in order to run any of these examples,
or, to work with live video
-
Not Synced
or recorded movies in Processing, you need
this particular video library
-
Not Synced
in all the previous versions of Processing
prior to 3.0, this library came with
-
Not Synced
Processing, but its quite a large... large
library, also it's maintained and updated
-
Not Synced
on a separate schedule, so by pulling it
in separately, all you need to do is,
-
Not Synced
Hey! Whoa! I haven't actually- Amazing!
I forgot that i just did a fresh install
-
Not Synced
of Processing here, so, this is-,
we're going to test this out
-
Not Synced
you just wanna hit this 'install' button
and, uh, while it's downloading
-
Not Synced
and should be ready to go, and now,
we're going to have this library!
-
Not Synced
yeah! and then it'll say 'remove', so, if
you don't have the video library,
-
Not Synced
make sure you get it (button click)
okay, back over here!
-
Not Synced
Once you have the video library, you
now have access to the Capture object
-
Not Synced
you also have access to the Movie object
-
Not Synced
so, Capture being live video from some
camera, that's connected to your computer
-
Not Synced
Movie object, you'll use for video files,
that you're loading and playing
-
Not Synced
back in Processing, so
-
Not Synced
here's the thing, the thing that's
the most wonderful about this
-
Not Synced
is that, both of these things are PImage's
essentially, all the functionality; image,
-
Not Synced
pixels, width, height, copy
any piece of functionality, you learned,
-
Not Synced
and practiced, and did with PImage, you
could do exactly the same functionality
-
Not Synced
with Capture and Movie
-
Not Synced
the only thing that's different, is when
you load a PImage, like frog.jpg,
-
Not Synced
those pixels are never gonna change,
unless you change them, right?
-
Not Synced
that file, that image is a
flat, static image
-
Not Synced
those pixels are the pixels
-
Not Synced
you could do all the same operations! but
with a Capture object or a Movie object,
-
Not Synced
those pixels might be changing according
to some schedule, of course,
-
Not Synced
we have total control over that schedule,
we could say, give me fresh pixels from
-
Not Synced
the camera, or stop giving me fresh
pixelsfrom the camera, or,
-
Not Synced
advance the next frame of the movie, or,
don't advance the next frame of the movie,
-
Not Synced
so this is an added piece of the puzzle,
that we'll be able to work with
-
Not Synced
as we start using these classes, so, let's
sort of, uh, let's look and see how this
-
Not Synced
would work, there's a couple little
nuances here, so, i'm back over here,
-
Not Synced
and i'm in a sketch, so, this is just a,
kind of a simple processing sketch
-
Not Synced
that I think we did at some point in an
earlier video, I'm loading an image,
-
Not Synced
I'm drawing it on the screen,
I'm using a couple things;
-
Not Synced
#1 - you can see I can dynamically resize
the image as i draw it, using the mouse,
-
Not Synced
or I could also tint it, meaning,
change its color, so,
-
Not Synced
what I want to emphasize in this-,
just first part of this video,
-
Not Synced
is let's make this the Capture object from
the camera, I have a laptop in front of me
-
Not Synced
its not all magic, let's get that image
from that camera, and let's see that there
-
Not Synced
and do all the same stuff for it,
so, instead-, the first step is,
-
Not Synced
instead of a PImage, I wanna say,
Capture and I'm gonna say video
-
Not Synced
now notice, as soon as I do that, I get
an error message, it says, um,
-
Not Synced
if I look at the errors, you can see,
the class Capture does not exist,
-
Not Synced
now this needs a little bit of work here,
but it's actually giving me a suggestion
-
Not Synced
which is nice, this is-, Capture and Movie
are both part of that Processing video
-
Not Synced
library that we just installed, so even
though I've installed the library
-
Not Synced
I have to-, in my code, make an explicit
reference that i'm going to use it, so,
-
Not Synced
I'm just gonna-, Processing will
add this for you automatically,
-
Not Synced
in a bunch of different ways,
but I'm just gonna do it manually,
-
Not Synced
so I just need to have an import statement
at the top; import processing.video.*;
-
Not Synced
now I have my Capture object, now,
-
Not Synced
you might think, you would say
something like: "I said loadImage(),
-
Not Synced
so, loadCapture (should work) or
something? createCapture, connectVideo,
-
Not Synced
startVideo", um, the way that
this works however, is,
-
Not Synced
there is no function like that, we need to
use the tools and syntax of
-
Not Synced
object oriented programming,
so lets come back over here
-
Not Synced
and if I have a video object, the syntax
is to say, I wanna make a new...
-
Not Synced
Capture object, and I need to figure out,
what goes in there, so,
-
Not Synced
what might be some parameters
that you need
-
Not Synced
when you're about to connect to
the live camera?
-
Not Synced
maybe you might say:
"Ah! camera over there!
-
Not Synced
I would like a very high resolution image"
or "a very low resolution image"
-
Not Synced
so, some parameters we're going to
put in there as the width and the height
-
Not Synced
of our requested, uh-, images
that we'll get from the camera
-
Not Synced
another piece of information that we
might put over here, is... frame rate
-
Not Synced
do i want to get images from the camera
at, 30 frames? 60 frames? 120 frames?
-
Not Synced
15 frames?
-
Not Synced
now, with both of these-, frames per
second, so, with both of these,
-
Not Synced
certain cameras are only
going to support
-
Not Synced
certain resolutions and
certain frame rates,
-
Not Synced
so, a lot of this really depends
on what you've got,
-
Not Synced
and I'm going to show
you a way to figure out
-
Not Synced
what your camera makes available to you
-
Not Synced
but generally speaking, 640x480, 30 FPS,
those are, kinda good numbers to use,
-
Not Synced
and in fact, this (meaning >> FPS)
is an optional parameter
-
Not Synced
you're just gonna get the default frame
rate, if you don't request a specific one,
-
Not Synced
which is usually 30 frames per second
-
Not Synced
now, there's another argument
that needs to go in here
-
Not Synced
and this is one of those tricky one
that appears, when you're using-,
-
Not Synced
a lot of times when you're using a
Processing library
-
Not Synced
One of the things we need to do, is, we
need to say: "A Capture object camera",
-
Not Synced
"you're (referring to camera) going
to have new images available"
-
Not Synced
"you're looking at the room,
you're looking at me,"
-
Not Synced
"you know where I want you
to give those images?"
-
Not Synced
"I want you to give those images to me"
-
Not Synced
who's 'me'?
this particular Processing sketch,
-
Not Synced
'this' sketch,
-
Not Synced
so the keyword 'this' needs to go in here,
-
Not Synced
now we could have a much longer discussion
about what the keyword 'this' means
-
Not Synced
and Java, and then we can sit here and
complain for a while
-
Not Synced
about how confusing these, like, archaic
concepts, and like, old-fashioned
-
Not Synced
languages like Java are
-
Not Synced
but for-, we don't really need to
worry about it too much
-
Not Synced
to make all this stuff work, we just need
to remember the keyword 'this' goes there
-
Not Synced
and I think it's kinda useful, to kind of
think about the fact that 'this'
-
Not Synced
is referring to this Processing sketch
-
Not Synced
I don't want the camera images to go to
some other program on the computer
-
Not Synced
I want them to go to this Processing
sketch, and we're telling the library that
-
Not Synced
this-, this happens in a lot of other ways
behind the scenes in Processing,
-
Not Synced
but you don't always have
to use that keyword 'this'