1
00:00:00,210 --> 00:00:05,700
Hi and welcome to the section where we take a look at working with video, so to get to this folder?

2
00:00:06,180 --> 00:00:12,450
It's located is the only other subfolder within the open CV directory of the master of the Modern Computer

3
00:00:12,450 --> 00:00:13,800
Vision Directory here.

4
00:00:14,190 --> 00:00:20,220
So open this to further expand it out and you'll see seven AI Python notebook files here.

5
00:00:20,700 --> 00:00:25,650
Now these are personal book files weren't created initially in Google apps, so even though they can

6
00:00:25,650 --> 00:00:31,500
be opened in color, but they don't have the icon, the CoLab icon here, so that's not sure actually

7
00:00:31,500 --> 00:00:32,940
how to get that icon back.

8
00:00:32,940 --> 00:00:37,620
But nevertheless, it's just a different type, just a notebook, but stored differently.

9
00:00:38,520 --> 00:00:40,830
We're not running these notebooks on club.

10
00:00:40,950 --> 00:00:45,120
These are the only seven notebooks in this class that we don't run on collab.

11
00:00:45,450 --> 00:00:48,150
So what to do to get this onto your local machine?

12
00:00:48,570 --> 00:00:57,030
I hope you follow the Anaconda Install tutorial with a PIP Install OpenCV Dush Python, so that would

13
00:00:57,030 --> 00:00:59,880
have installed open TV on your local system and you can use it.

14
00:01:00,390 --> 00:01:02,490
So I'm not going to go back to that.

15
00:01:02,850 --> 00:01:03,660
I want you to know.

16
00:01:03,660 --> 00:01:06,060
Download this folder to your local machine.

17
00:01:06,720 --> 00:01:07,700
Just press download here.

18
00:01:07,710 --> 00:01:11,840
It'll zip all these files and it should download, maybe in a few minutes.

19
00:01:11,850 --> 00:01:14,820
So I'm not going to wait for this right now to minimize it.

20
00:01:15,390 --> 00:01:17,640
I already have these videos on my local system.

21
00:01:17,670 --> 00:01:19,380
So here's what to do.

22
00:01:19,680 --> 00:01:21,670
So assuming Anaconda installed?

23
00:01:22,110 --> 00:01:26,230
That should mean that you have your AI Python lookbook installer as well.

24
00:01:26,250 --> 00:01:27,120
So let's open.

25
00:01:27,720 --> 00:01:30,870
Similarly, we can use Jupyter Lab I Python.

26
00:01:30,870 --> 00:01:36,540
The book is is not as good as Jupiter love, but it's easier on the eyes for beginners, so I teach

27
00:01:36,540 --> 00:01:37,200
using that.

28
00:01:37,830 --> 00:01:43,650
So let's open this here and open on my other monitor.

29
00:01:43,650 --> 00:01:48,030
So give me a second and I'll just bring that to the screen here.

30
00:01:52,370 --> 00:02:01,460
So it can drag it across, so we have of course, this is because this was opened in my base directory,

31
00:02:01,460 --> 00:02:05,700
maybe it's home directory and my neck, some of it similar for windows as well.

32
00:02:05,720 --> 00:02:08,990
So you don't have to worry too much about where you open this.

33
00:02:08,990 --> 00:02:14,510
This is where you open the eye, both in the book of browser that it should open up a browser file browser.

34
00:02:14,510 --> 00:02:16,850
Have all your files on your hard drive.

35
00:02:17,420 --> 00:02:20,630
So for me, I have my files in Python here.

36
00:02:21,050 --> 00:02:24,380
And then there's a directory called Working With VIDEO.

37
00:02:24,890 --> 00:02:25,460
Here it is.

38
00:02:25,850 --> 00:02:28,520
So these are the files that were downloaded and extracted here.

39
00:02:29,120 --> 00:02:31,550
So let's open this first notebook.

40
00:02:33,750 --> 00:02:41,010
So these are some of the visions of the course ahead of the for the other videos, for now, let's leave

41
00:02:41,010 --> 00:02:41,790
this one here.

42
00:02:42,720 --> 00:02:49,320
And what we're doing in this video, we're going to open a stream from your webcam and then apply a

43
00:02:49,320 --> 00:02:54,500
sketch to a sketch like effect to that image life from your webcam data.

44
00:02:54,840 --> 00:02:57,060
So in this video, what are we going to do?

45
00:02:57,450 --> 00:03:04,020
We're going to load an image from a webcam, so we initialize the webcam here by putting zero in this

46
00:03:04,020 --> 00:03:05,130
video capture function.

47
00:03:05,550 --> 00:03:09,810
We tell opens in a video capture to access a webcam instead.

48
00:03:10,290 --> 00:03:15,380
Remember, previously we could actually point this to a follow up path that is a video file and peaceful

49
00:03:15,600 --> 00:03:16,350
event file.

50
00:03:16,980 --> 00:03:18,570
Similarly, we can do it for a webcam.

51
00:03:18,810 --> 00:03:26,340
So while true means that while this loop continuously keep running until something tells it to break,

52
00:03:26,850 --> 00:03:29,820
which is what we use this to the weight key function here.

53
00:03:30,300 --> 00:03:36,450
So when you had to enter key or return key, it's going to break that this quota corresponds to the

54
00:03:36,450 --> 00:03:36,930
end of the queue.

55
00:03:37,530 --> 00:03:41,940
So it's going to break this loop and exit and close the camera and destroy the windows.

56
00:03:42,480 --> 00:03:47,760
So the interesting functions we're going to use here, it's a simple functions that we have seen before.

57
00:03:48,390 --> 00:03:55,080
This is a capped agreed, which reads every frame from the webcam that basically tells it the true or

58
00:03:55,080 --> 00:03:59,880
false billion of that returns true when a frame is read correctly.

59
00:04:00,510 --> 00:04:06,120
And then we just use a CV to improve a function to show that video on screen.

60
00:04:06,540 --> 00:04:09,960
So let's run this and we'll take a look.

61
00:04:10,140 --> 00:04:11,650
So you so nothing happens.

62
00:04:11,670 --> 00:04:14,760
He said he saw this change to an asterix here.

63
00:04:15,210 --> 00:04:16,200
That means it's running.

64
00:04:16,710 --> 00:04:20,280
If you look at your webcam like right now, it should be on as mine is currently on.

65
00:04:20,670 --> 00:04:21,900
But where's the video?

66
00:04:22,380 --> 00:04:25,800
Well, in Windows computers, it usually pops up on top of the screen.

67
00:04:26,220 --> 00:04:31,620
However, on Macs and Linux, Ubuntu, a unique systems, it opens in the background.

68
00:04:31,650 --> 00:04:34,050
So Mac, it's right here.

69
00:04:34,590 --> 00:04:38,670
So this is a video feed from that function.

70
00:04:39,040 --> 00:04:42,540
My webcam that loaded basically my webcam video.

71
00:04:43,170 --> 00:04:44,670
So let's end this here.

72
00:04:44,730 --> 00:04:48,950
Now you notice the window didn't close on windows.

73
00:04:48,960 --> 00:04:50,910
It would have closed on Ubuntu.

74
00:04:50,940 --> 00:04:52,200
It should have closed as well.

75
00:04:52,560 --> 00:04:56,840
However, Mac has a weird issue with the newest OS.

76
00:04:57,540 --> 00:05:04,620
Once I believe, or even in the previous one Big Sur, where it doesn't actually close the windows so

77
00:05:04,620 --> 00:05:07,680
you can see it's killing me at the application, Python is still running.

78
00:05:08,190 --> 00:05:12,450
So I'm just going to force quit it here to remove this window and you can see the window is gone.

79
00:05:12,990 --> 00:05:18,060
It's slightly annoying for Mac users like myself, but it's something we just have to put up.

80
00:05:18,060 --> 00:05:20,100
But for now, it's not a big issue.

81
00:05:20,580 --> 00:05:25,560
It doesn't really hurt my development on Mac systems because it can just have a ton of these windows

82
00:05:25,560 --> 00:05:25,910
open.

83
00:05:25,920 --> 00:05:30,190
It doesn't actually break anything, but otherwise that's it.

84
00:05:30,210 --> 00:05:34,860
So occasionally you may want to if this code crashed.

85
00:05:35,430 --> 00:05:41,380
For some reason, you can run these two lines of code here to close your webcam, so we don't need it

86
00:05:41,380 --> 00:05:41,540
here.

87
00:05:41,540 --> 00:05:45,480
I just had one ranted running that to see you beforehand.

88
00:05:45,900 --> 00:05:48,930
So not, let's do that sketch version of ourselves.

89
00:05:49,500 --> 00:05:56,340
So remember, if you wanted to turn a Real-Life image into a sketch, what would you do?

90
00:05:56,950 --> 00:06:02,010
Remember, there are things like many edges, canny edges give us that very cool drawing like effect.

91
00:06:02,490 --> 00:06:06,120
Basically, it drew a line over every edge in the image.

92
00:06:06,390 --> 00:06:09,510
So what we do, we lodo images here.

93
00:06:10,350 --> 00:06:11,750
Well, we don't know that yet.

94
00:06:12,120 --> 00:06:17,040
We passed that image as a function here called sketch, and we've created it takes an image, convert

95
00:06:17,040 --> 00:06:18,420
it into a grayscale image.

96
00:06:18,900 --> 00:06:20,910
Apply some Gaussian blur to it.

97
00:06:21,420 --> 00:06:23,490
Not much mystified by five kernel.

98
00:06:24,120 --> 00:06:26,970
Then we use Kanae edges here to extract the edges.

99
00:06:27,300 --> 00:06:33,630
And then we do an inverse binary threshold on that to turn it into like a paper and pen type effect

100
00:06:33,630 --> 00:06:37,230
with a white background instead of a black background that we got previously.

101
00:06:37,230 --> 00:06:38,100
What kind of edges?

102
00:06:38,580 --> 00:06:44,600
And then we returned that final image, giving it the mask name, and then we just displayed that into

103
00:06:44,910 --> 00:06:45,540
a function here.

104
00:06:45,930 --> 00:06:48,070
So it's the exact same function we saw before.

105
00:06:48,090 --> 00:06:48,870
Exact same code.

106
00:06:49,470 --> 00:06:51,180
However, the only difference is no.

107
00:06:51,180 --> 00:06:55,350
That is that the image is going through the sketch function that we defined appear.

108
00:06:55,680 --> 00:06:56,910
So let's run this.

109
00:06:58,140 --> 00:07:00,060
And yep, there it is.

110
00:07:01,110 --> 00:07:03,330
So you can see this is me as a sketch.

111
00:07:03,990 --> 00:07:05,430
I can move my hand around.

112
00:07:06,000 --> 00:07:07,200
This looks quite cool.

113
00:07:07,920 --> 00:07:14,340
If you want more edges or more defined edges, you can increase some of the tiny edge sensitivity parameters.

114
00:07:14,880 --> 00:07:19,200
However, as of now, this is this is the final product right here.

115
00:07:19,560 --> 00:07:26,340
So let's go back to a code actually, that's is pressed into two and this and closes the code here.

116
00:07:26,340 --> 00:07:30,300
But a window is still open, as you can see, and there's a beach ball here.

117
00:07:30,480 --> 00:07:32,670
But that's OK for Mac users because we can all this.

118
00:07:33,090 --> 00:07:39,240
Run this again with another one here, which is why I tell you it doesn't really impact my development

119
00:07:39,540 --> 00:07:40,770
on my Mac system.

120
00:07:42,120 --> 00:07:43,770
So that's it for this lesson.

121
00:07:44,400 --> 00:07:48,000
What we're going to do next is opening video files and open TV.

122
00:07:48,330 --> 00:07:53,820
So instead of using a webcam, we're not going to open the files of open video files instead.

123
00:07:54,510 --> 00:07:54,930
Thank you.
