1
00:00:00,240 --> 00:00:05,650
So now let's move on to section four, where we take a look at drawing on images.

2
00:00:05,700 --> 00:00:07,410
So let's open up this notebook here.

3
00:00:07,440 --> 00:00:10,050
Let's close off the previous two to one.

4
00:00:12,300 --> 00:00:13,230
So here we go.

5
00:00:13,560 --> 00:00:16,020
So now let's look at this chapter.

6
00:00:16,020 --> 00:00:18,060
Him the chapters pretty cool and pretty useful.

7
00:00:18,570 --> 00:00:22,950
And it's something that even though it's it's a bit silly, but it's something that we actually do often

8
00:00:22,950 --> 00:00:28,410
in computer vision, which is putting text on images to four different labels or for whatever reason.

9
00:00:28,890 --> 00:00:34,110
But it's something you might do quite often just do if you just want to enhance a show of your work.

10
00:00:34,740 --> 00:00:37,530
So you'll see how how it's done in Open City now.

11
00:00:38,160 --> 00:00:45,380
So again, let's just load off or input our libraries and motor function or plotting function.

12
00:00:48,690 --> 00:00:51,390
So now we can do something here.

13
00:00:51,930 --> 00:00:55,020
Let's firstly create a black blank image.

14
00:00:55,530 --> 00:01:01,560
So we're going to create an image here five, 12 by 512 by tree, which means it's a color black image

15
00:01:01,560 --> 00:01:06,250
as opposed to a gray scale black image, which looks the same.

16
00:01:06,300 --> 00:01:08,310
It's black as again.

17
00:01:08,400 --> 00:01:13,520
As you can see here, we can make a black and white grayscale one to remember with zeros.

18
00:01:13,530 --> 00:01:18,360
Everything is going to be dark, dearest, darkest color, which is absence of color, which is black.

19
00:01:18,960 --> 00:01:24,010
So we can plot this here, and you can see we get two images right here.

20
00:01:24,630 --> 00:01:28,580
Will be black and gray scale black, if exactly the same thing.

21
00:01:28,590 --> 00:01:34,710
However, this one is going to take up to three times the memory space because it has three dimensions

22
00:01:35,040 --> 00:01:37,650
three, five, 12 three times.

23
00:01:38,580 --> 00:01:44,190
So now let's take a look at see how we can draw a line of all black square.

24
00:01:44,730 --> 00:01:51,480
So the reason we actually have a watch three dimensional black image here is because we want our blue

25
00:01:51,480 --> 00:01:53,460
line to show up as blue as opposed to gray.

26
00:01:53,910 --> 00:01:58,440
So we want to have a color image effectively so quick to open.

27
00:01:58,440 --> 00:02:00,870
TV has a cool function called a v2.0 line.

28
00:02:01,440 --> 00:02:04,590
And it takes the input of our image here.

29
00:02:05,580 --> 00:02:11,250
It takes this is a starting coordinates here, which is zero zero, which is zero zero as a reference

30
00:02:11,250 --> 00:02:11,520
point.

31
00:02:11,910 --> 00:02:13,320
You can see this zero here.

32
00:02:13,960 --> 00:02:17,400
So this is basically the same axis here.

33
00:02:18,440 --> 00:02:19,060
This is on top.

34
00:02:19,080 --> 00:02:21,000
It just labels on bottom, but it's the same thing.

35
00:02:21,210 --> 00:02:27,570
Zero starts here, so it's zero zero here, five 11 here you can see five 11 is all the way here.

36
00:02:27,570 --> 00:02:28,800
Five, 11, five 11.

37
00:02:29,400 --> 00:02:30,930
So we're connecting two points here.

38
00:02:31,830 --> 00:02:37,110
I've already put what what the function here is so we can see we have and then coordinate something

39
00:02:37,110 --> 00:02:39,990
coordinates color and line thickness.

40
00:02:41,340 --> 00:02:45,060
So let's take a look at this do this nice little blue line.

41
00:02:46,530 --> 00:02:50,880
I do encourage you to experiment and do different lines if you want.

42
00:02:51,180 --> 00:02:52,640
It's quite fun to do this.

43
00:02:52,700 --> 00:02:57,210
Basically pin playing like a windows pinch or one of those painting programs.

44
00:02:57,210 --> 00:02:58,650
Except no, you're actually coding.

45
00:02:58,650 --> 00:03:04,410
And the lines are programmatically which could be interesting to do if you wanted to make something

46
00:03:04,410 --> 00:03:05,050
more elaborate.

47
00:03:05,080 --> 00:03:10,020
You can have like rows and rows of these little line functions doing all sort of intricate lines, or

48
00:03:10,020 --> 00:03:13,530
you can have a polygon or circles, which you'll see below.

49
00:03:13,830 --> 00:03:15,630
So it's actually a rectangle, that's the next one.

50
00:03:16,170 --> 00:03:17,810
So actually, I didn't run this.

51
00:03:17,820 --> 00:03:19,710
So let's just run this for running at sake.

52
00:03:21,000 --> 00:03:22,560
So now we're going to do a rectangle.

53
00:03:23,100 --> 00:03:28,470
So rectangles are actually pretty cool because in things like object detectors, you may want to draw

54
00:03:28,470 --> 00:03:33,690
a box or something or some kind of contour or some sort of region you're looking at in an image.

55
00:03:34,170 --> 00:03:38,460
So having the ability to draw a box is actually quite useful.

56
00:03:38,460 --> 00:03:45,930
Surprisingly, so similarly, we have this takes this function takes the image as an input takes it,

57
00:03:45,930 --> 00:03:51,780
starting with X, which is the top left with X and the opposite with X, which is a bottom right with

58
00:03:51,780 --> 00:03:52,000
X.

59
00:03:52,000 --> 00:03:55,980
So we have a top left, bottom right color and thickness again.

60
00:03:57,060 --> 00:04:02,040
So let's create our blank image here or black canvas we use.

61
00:04:02,040 --> 00:04:03,580
We use two rectangles.

62
00:04:03,580 --> 00:04:04,380
You can see it here.

63
00:04:04,830 --> 00:04:10,470
Now this this function, which I didn't mention previously, this function basically takes the image

64
00:04:10,470 --> 00:04:12,840
here and manipulates the image itself.

65
00:04:12,840 --> 00:04:14,850
It's called in function.

66
00:04:15,210 --> 00:04:17,010
It doesn't have something click.

67
00:04:17,490 --> 00:04:21,350
It is an output and a function image, and you call it equal to that.

68
00:04:21,420 --> 00:04:23,060
That's not how this one works.

69
00:04:23,100 --> 00:04:25,560
It manipulates the image in that line right there.

70
00:04:26,070 --> 00:04:30,930
Which is something to note because if you wanted to keep the original image as the original, this is

71
00:04:30,930 --> 00:04:33,120
going to draw a box over that original image.

72
00:04:33,540 --> 00:04:37,080
So your input variable is has changed, basically.

73
00:04:37,560 --> 00:04:41,370
So now we can run this and you can see we have this here.

74
00:04:41,910 --> 00:04:43,890
This cool purple pink?

75
00:04:44,490 --> 00:04:50,250
Well, I think it's put this purple more in pink, but is this a triangle here?

76
00:04:52,230 --> 00:04:55,980
So now let's draw some circles so you can see the circle function again is similar.

77
00:04:56,160 --> 00:04:59,730
However, you don't have a top left and bottom right vertices.

78
00:05:00,090 --> 00:05:06,420
You have a center and a radius, which is all you need when you want to specify how big a circle.

79
00:05:06,420 --> 00:05:11,610
In a way, you want to put it just drop percent center in specified radius and it just fills the circle

80
00:05:11,610 --> 00:05:11,940
here.

81
00:05:12,420 --> 00:05:14,730
Now you don't actually have to fill if used.

82
00:05:15,600 --> 00:05:19,140
If you use different value here, it actually wouldn't fill the circle.

83
00:05:19,150 --> 00:05:20,880
So let's take a look at that and see.

84
00:05:23,520 --> 00:05:25,290
It's been a while since I actually did this.

85
00:05:25,860 --> 00:05:27,370
This should just affect.

86
00:05:27,390 --> 00:05:28,110
Let's take a look.

87
00:05:29,400 --> 00:05:29,710
Yeah.

88
00:05:29,740 --> 00:05:36,210
Blindsides so you can see by putting him negative one here, you actually follow through the cycle automatically

89
00:05:36,600 --> 00:05:40,230
with that color, the color that you actually specified here.

90
00:05:40,650 --> 00:05:43,860
Color because you can specify any color you want.

91
00:05:44,730 --> 00:05:47,730
255, 255 255 is all white.

92
00:05:48,420 --> 00:05:52,290
If you wanted to see it and not, take my word for it, we can run that.

93
00:05:52,290 --> 00:05:55,010
No, oops.

94
00:05:57,060 --> 00:05:59,080
And you can see we got a nice wide circle there.

95
00:05:59,130 --> 00:06:04,200
So let's go back to a green circle, the leaf negative one.

96
00:06:05,430 --> 00:06:07,650
So now let's move on to polygons.

97
00:06:07,650 --> 00:06:09,780
So polygons are pretty interesting and cool.

98
00:06:10,590 --> 00:06:16,860
Remember, I said you can draw a bunch of lines together by having a lot of line functions to create

99
00:06:16,860 --> 00:06:17,460
something weird.

100
00:06:17,490 --> 00:06:19,260
Well, you can use it here.

101
00:06:19,560 --> 00:06:21,690
You can use this polygon function instead.

102
00:06:22,230 --> 00:06:27,120
What this does, it takes an array of points so you can see carefully.

103
00:06:27,120 --> 00:06:27,840
Look at this here.

104
00:06:27,960 --> 00:06:30,180
This is an array one tree hill.

105
00:06:31,620 --> 00:06:35,450
It's a single, a single array, but you have submarines in it.

106
00:06:35,460 --> 00:06:36,120
Here we have.

107
00:06:36,120 --> 00:06:37,170
These are coordinate points.

108
00:06:38,340 --> 00:06:44,070
So you got this list here, which is 10, 50, 450 and 90 200.

109
00:06:44,220 --> 00:06:49,450
Whatever the five hundred five fifty five hundred does it a four points here.

110
00:06:49,470 --> 00:06:53,670
We're going to draw one two three four.

111
00:06:55,150 --> 00:06:56,790
And this connects back to the last one.

112
00:06:57,540 --> 00:06:59,310
So let's reshape four points.

113
00:06:59,310 --> 00:07:07,350
This is how we have to reshape the points here for these four to see V to polyolefins function.

114
00:07:08,070 --> 00:07:09,310
So this reset function?

115
00:07:09,330 --> 00:07:10,930
Don't worry about it too much.

116
00:07:10,930 --> 00:07:12,900
It just actually changes the format around.

117
00:07:12,900 --> 00:07:16,140
If you wanted to actually see it, you can print it out yourself and take a look at it.

118
00:07:16,980 --> 00:07:22,310
So we use a C V to pull the lines here to image the points.

119
00:07:23,490 --> 00:07:23,980
True.

120
00:07:24,000 --> 00:07:27,220
Basically means we are going to join the last point with the this point.

121
00:07:27,630 --> 00:07:29,550
The color you want it at and the thickness.

122
00:07:30,690 --> 00:07:31,450
And there we go.

123
00:07:31,950 --> 00:07:32,510
Pretty cool.

124
00:07:32,520 --> 00:07:34,140
Boomerang airplane type.

125
00:07:34,350 --> 00:07:35,220
Which you there.

126
00:07:36,240 --> 00:07:41,460
So yes, sir, I did see how it requires a degree to behave that way.

127
00:07:41,850 --> 00:07:47,640
Basically, what you're doing here, you're just adding in a point in extra dimension in the middle.

128
00:07:48,090 --> 00:07:53,130
And the reason for that for is just because of how it probably seemed to function the internal function

129
00:07:53,130 --> 00:08:00,900
inside of poly lines and how it's basically how addict decodes the points here.

130
00:08:01,410 --> 00:08:06,840
So it's pretty much it's not really that intuitive is not really important to know, but you can see

131
00:08:06,840 --> 00:08:07,950
the difference in shape here.

132
00:08:07,980 --> 00:08:10,890
What what this ratio of function did just for your information.

133
00:08:11,850 --> 00:08:18,060
So now let's look at putting text, which is the key to put text function, which is often something,

134
00:08:18,600 --> 00:08:20,070
something I use quite often as well.

135
00:08:21,300 --> 00:08:23,640
You can see this is a variable fonts here.

136
00:08:24,030 --> 00:08:26,460
I'll show you how to use it and change it quickly.

137
00:08:27,000 --> 00:08:32,610
So let's create our blank image here and let's create a string string is going to call Hello World.

138
00:08:33,330 --> 00:08:36,330
And what we're going to do, we're going to use to put text function here.

139
00:08:36,780 --> 00:08:39,690
So it just takes the image text to display here.

140
00:08:40,560 --> 00:08:46,140
Bottom left starting point right here, font.

141
00:08:46,440 --> 00:08:51,120
We specify here font size, color, the color and thickness.

142
00:08:51,360 --> 00:08:54,540
So we've have all of we have all the stuff we need right now.

143
00:08:55,650 --> 00:08:59,550
So remember, the bottom of the starting point is actually here.

144
00:08:59,640 --> 00:09:06,060
So this is where the text starts right now, so we can run this function and we've placed some text

145
00:09:06,060 --> 00:09:06,390
here.

146
00:09:07,050 --> 00:09:08,870
Let's try a different font.

147
00:09:08,910 --> 00:09:10,530
Let's try the complex.

148
00:09:10,920 --> 00:09:21,090
So, oops, this is just gives us access to the markdown, but you do have access to and we get a nice

149
00:09:21,090 --> 00:09:26,610
little fancy font here going, which actually don't if you use this one because it looks a bit unprofessional

150
00:09:26,610 --> 00:09:33,200
sometimes, but you can pretty up pretty easily anything you want using these different fonts here,

151
00:09:33,210 --> 00:09:36,510
and you can change the color, the thickness, the size position.

152
00:09:36,510 --> 00:09:38,970
Anything you want to do is within this function.

153
00:09:39,510 --> 00:09:40,390
So that's quite cool.

154
00:09:40,410 --> 00:09:43,860
So that now concludes this lesson on drawing on images.

155
00:09:43,860 --> 00:09:45,330
Hope you find it useful and cool.

156
00:09:45,930 --> 00:09:52,440
What we're going to do next is transmission's, which is includes translations and rotations, so stay

157
00:09:52,440 --> 00:09:53,610
tuned for the next lesson.

158
00:09:53,760 --> 00:09:54,230
Thank you.
