Hi and welcome to the section where we take a look at working with video, so to get to this folder?
It's located is the only other subfolder within the open CV directory of the master of the Modern Computer
Vision Directory here.
So open this to further expand it out and you'll see seven AI Python notebook files here.
Now these are personal book files weren't created initially in Google apps, so even though they can
be opened in color, but they don't have the icon, the CoLab icon here, so that's not sure actually
how to get that icon back.
But nevertheless, it's just a different type, just a notebook, but stored differently.
We're not running these notebooks on club.
These are the only seven notebooks in this class that we don't run on collab.
So what to do to get this onto your local machine?
I hope you follow the Anaconda Install tutorial with a PIP Install OpenCV Dush Python, so that would
have installed open TV on your local system and you can use it.
So I'm not going to go back to that.
I want you to know.
Download this folder to your local machine.
Just press download here.
It'll zip all these files and it should download, maybe in a few minutes.
So I'm not going to wait for this right now to minimize it.
I already have these videos on my local system.
So here's what to do.
So assuming Anaconda installed?
That should mean that you have your AI Python lookbook installer as well.
So let's open.
Similarly, we can use Jupyter Lab I Python.
The book is is not as good as Jupiter love, but it's easier on the eyes for beginners, so I teach
using that.
So let's open this here and open on my other monitor.
So give me a second and I'll just bring that to the screen here.
So it can drag it across, so we have of course, this is because this was opened in my base directory,
maybe it's home directory and my neck, some of it similar for windows as well.
So you don't have to worry too much about where you open this.
This is where you open the eye, both in the book of browser that it should open up a browser file browser.
Have all your files on your hard drive.
So for me, I have my files in Python here.
And then there's a directory called Working With VIDEO.
Here it is.
So these are the files that were downloaded and extracted here.
So let's open this first notebook.
So these are some of the visions of the course ahead of the for the other videos, for now, let's leave
this one here.
And what we're doing in this video, we're going to open a stream from your webcam and then apply a
sketch to a sketch like effect to that image life from your webcam data.
So in this video, what are we going to do?
We're going to load an image from a webcam, so we initialize the webcam here by putting zero in this
video capture function.
We tell opens in a video capture to access a webcam instead.
Remember, previously we could actually point this to a follow up path that is a video file and peaceful
event file.
Similarly, we can do it for a webcam.
So while true means that while this loop continuously keep running until something tells it to break,
which is what we use this to the weight key function here.
So when you had to enter key or return key, it's going to break that this quota corresponds to the
end of the queue.
So it's going to break this loop and exit and close the camera and destroy the windows.
So the interesting functions we're going to use here, it's a simple functions that we have seen before.
This is a capped agreed, which reads every frame from the webcam that basically tells it the true or
false billion of that returns true when a frame is read correctly.
And then we just use a CV to improve a function to show that video on screen.
So let's run this and we'll take a look.
So you so nothing happens.
He said he saw this change to an asterix here.
That means it's running.
If you look at your webcam like right now, it should be on as mine is currently on.
But where's the video?
Well, in Windows computers, it usually pops up on top of the screen.
However, on Macs and Linux, Ubuntu, a unique systems, it opens in the background.
So Mac, it's right here.
So this is a video feed from that function.
My webcam that loaded basically my webcam video.
So let's end this here.
Now you notice the window didn't close on windows.
It would have closed on Ubuntu.
It should have closed as well.
However, Mac has a weird issue with the newest OS.
Once I believe, or even in the previous one Big Sur, where it doesn't actually close the windows so
you can see it's killing me at the application, Python is still running.
So I'm just going to force quit it here to remove this window and you can see the window is gone.
It's slightly annoying for Mac users like myself, but it's something we just have to put up.
But for now, it's not a big issue.
It doesn't really hurt my development on Mac systems because it can just have a ton of these windows
open.
It doesn't actually break anything, but otherwise that's it.
So occasionally you may want to if this code crashed.
For some reason, you can run these two lines of code here to close your webcam, so we don't need it
here.
I just had one ranted running that to see you beforehand.
So not, let's do that sketch version of ourselves.
So remember, if you wanted to turn a Real-Life image into a sketch, what would you do?
Remember, there are things like many edges, canny edges give us that very cool drawing like effect.
Basically, it drew a line over every edge in the image.
So what we do, we lodo images here.
Well, we don't know that yet.
We passed that image as a function here called sketch, and we've created it takes an image, convert
it into a grayscale image.
Apply some Gaussian blur to it.
Not much mystified by five kernel.
Then we use Kanae edges here to extract the edges.
And then we do an inverse binary threshold on that to turn it into like a paper and pen type effect
with a white background instead of a black background that we got previously.
What kind of edges?
And then we returned that final image, giving it the mask name, and then we just displayed that into
a function here.
So it's the exact same function we saw before.
Exact same code.
However, the only difference is no.
That is that the image is going through the sketch function that we defined appear.
So let's run this.
And yep, there it is.
So you can see this is me as a sketch.
I can move my hand around.
This looks quite cool.
If you want more edges or more defined edges, you can increase some of the tiny edge sensitivity parameters.
However, as of now, this is this is the final product right here.
So let's go back to a code actually, that's is pressed into two and this and closes the code here.
But a window is still open, as you can see, and there's a beach ball here.
But that's OK for Mac users because we can all this.
Run this again with another one here, which is why I tell you it doesn't really impact my development
on my Mac system.
So that's it for this lesson.
What we're going to do next is opening video files and open TV.
So instead of using a webcam, we're not going to open the files of open video files instead.
Thank you.