1
00:00:00,330 --> 00:00:07,140
Welcome back to the course, so the next chapter we take a look at is it involves object tracking by

2
00:00:07,140 --> 00:00:07,570
color.

3
00:00:07,950 --> 00:00:10,620
So let's open this notebook already have it open here.

4
00:00:11,220 --> 00:00:14,160
So this for this, I'll give you a warning.

5
00:00:14,400 --> 00:00:21,870
This lesson isn't it isn't well-done, mainly because I couldn't find a test video to use in club that

6
00:00:21,870 --> 00:00:23,010
actually worked fairly well.

7
00:00:23,400 --> 00:00:27,420
I should have just recorded a video with my webcam to demonstrate this, which I might do later on.

8
00:00:27,960 --> 00:00:33,840
However, for now, I tried to find a video where we can filter on the color yellow and track a yellow

9
00:00:33,840 --> 00:00:38,700
BMW in the see in a scene and demonstrate the track in a color.

10
00:00:39,690 --> 00:00:45,360
However, it doesn't look entirely perfectly to well, it does with briefly for a moment so we can demonstrate

11
00:00:45,360 --> 00:00:45,690
that.

12
00:00:46,290 --> 00:00:47,690
So let's luto images.

13
00:00:47,700 --> 00:00:50,400
Actually, this is the image for the video.

14
00:00:50,820 --> 00:00:52,170
You'll probably not see this.

15
00:00:53,730 --> 00:00:55,410
We can delete this box here.

16
00:00:56,040 --> 00:00:57,360
So this is the code here.

17
00:00:57,360 --> 00:00:59,100
So all this stuff is good.

18
00:00:59,340 --> 00:01:01,410
Well, let me show you the output of this goodness.

19
00:01:02,010 --> 00:01:05,340
This is a fairly long involve code, but it's actually not that complicated.

20
00:01:06,060 --> 00:01:12,120
And this is the output video here where truly we track BMW hopes to go back to this.

21
00:01:13,170 --> 00:01:18,030
So the video resolution is a bit high, so it doesn't fit the whole thing on screen.

22
00:01:18,630 --> 00:01:24,270
So initially, we initialize a random spot here and it's tracking some objects, something hidden in

23
00:01:24,270 --> 00:01:25,170
the film's colorful, too.

24
00:01:25,620 --> 00:01:31,020
However, luckily it does grab on to the yellow car here, and you can see it follows this yellow call.

25
00:01:31,200 --> 00:01:32,070
That's right here.

26
00:01:32,490 --> 00:01:33,990
But then it loses it.

27
00:01:35,160 --> 00:01:36,450
I'm not even sure where here it is.

28
00:01:36,960 --> 00:01:40,380
It loses it for a bit and then tracks some random objects here.

29
00:01:40,930 --> 00:01:44,280
Now, this can probably be improved by improving the HSV color filter.

30
00:01:44,730 --> 00:01:50,280
But what we're actually doing here is we're filtering on a color.

31
00:01:50,280 --> 00:01:55,770
The color filtering as yellow sits between 20 and 40 and HSV each.

32
00:01:55,920 --> 00:02:00,340
I should say the hue and what we're doing, we're creating an empty area for points.

33
00:02:00,360 --> 00:02:04,430
Now this is the points that are being tracked so that you can see that line.

34
00:02:04,440 --> 00:02:06,390
There's a historical line of tracking points.

35
00:02:06,900 --> 00:02:09,060
We just keep appending that to the disarray.

36
00:02:09,930 --> 00:02:15,210
We create our video writer and then all of let's move into the core of the code here.

37
00:02:15,690 --> 00:02:18,240
So like I said, we are tracking one color.

38
00:02:18,360 --> 00:02:20,850
So remember the HSV method to filter and color?

39
00:02:21,300 --> 00:02:22,170
That's what we're doing.

40
00:02:22,170 --> 00:02:25,620
And then after that, we're running fine contours on that output.

41
00:02:26,040 --> 00:02:31,950
So fine contours should only be able to, in theory, fill a get a box.

42
00:02:31,950 --> 00:02:35,700
The largest box around one of the yellow objects on screen.

43
00:02:35,850 --> 00:02:37,590
That's how we have it set here.

44
00:02:39,000 --> 00:02:42,180
So we are creating them to read a story to centroid.

45
00:02:42,180 --> 00:02:43,700
That's the center of the ground control.

46
00:02:44,340 --> 00:02:49,560
So that's how we get contours for filter contours at the center of the control.

47
00:02:50,040 --> 00:02:52,020
If we have contours, this is what we do.

48
00:02:52,410 --> 00:02:55,640
Get the largest contour, get the area, the radius.

49
00:02:55,650 --> 00:02:57,720
That's a minimum closing circle for the contour.

50
00:02:57,750 --> 00:03:04,170
It's a function we haven't discussed before, but basically it takes an input of a cognitive control

51
00:03:04,770 --> 00:03:08,280
and gives you the ex-wife position of the center and the radius.

52
00:03:08,880 --> 00:03:10,800
Then we get the moments here with him.

53
00:03:11,310 --> 00:03:18,300
So this is how we actually get the and using movements, we get the center of the circle as well.

54
00:03:18,660 --> 00:03:22,530
So we can actually use that to plot the circle, plot the point here.

55
00:03:23,370 --> 00:03:25,020
That's how we actually get the trail.

56
00:03:25,710 --> 00:03:31,560
And if the radius is of a 25, which means if it's over a certain size, that's when we actually do

57
00:03:32,460 --> 00:03:33,420
grow in the circle.

58
00:03:33,430 --> 00:03:33,870
So we don't.

59
00:03:33,870 --> 00:03:36,780
We were drawing a circle at a point, a circle around the point.

60
00:03:36,780 --> 00:03:38,880
So one is supposed to be the center of the object.

61
00:03:38,910 --> 00:03:42,220
One is the little circle in closing the object.

62
00:03:43,050 --> 00:03:46,680
And then this is the area here where we just keep track of our points.

63
00:03:46,710 --> 00:03:51,600
So once the radius is over 25, we just store all the points here and then draw a line.

64
00:03:52,020 --> 00:03:55,110
So that line is basically the historical tracking.

65
00:03:55,770 --> 00:03:58,080
So this is a pretty cool system, pretty cool.

66
00:03:58,090 --> 00:03:58,950
Could, I should say.

67
00:04:00,180 --> 00:04:06,690
So we took the output that it produces from our trade frame converted into an empty before then played

68
00:04:06,690 --> 00:04:10,350
back here and we get the output video, which you saw previously.

69
00:04:10,980 --> 00:04:12,170
So that's just video here.

70
00:04:12,420 --> 00:04:14,330
So we can actually play it.

71
00:04:14,340 --> 00:04:14,970
Yeah, there we go.

72
00:04:14,970 --> 00:04:15,600
It's playing.

73
00:04:16,440 --> 00:04:18,000
So that's it for this lesson.

74
00:04:18,090 --> 00:04:24,900
What is a good exercise for you to do is if you want or if you do have open TV installed, you can run

75
00:04:24,900 --> 00:04:29,160
this locally and you can use a webcam and tweak these parameters.

76
00:04:29,520 --> 00:04:33,870
It's going to be much easier to tweak it in a live video running the court locally than on collab.

77
00:04:33,870 --> 00:04:41,100
And that's one of the disadvantages of collab in in terms of working with webcam video, but otherwise

78
00:04:41,400 --> 00:04:43,740
collab is a godsend for so many things.

79
00:04:44,490 --> 00:04:46,290
So I hope you enjoy this lesson.

80
00:04:46,290 --> 00:04:53,040
And then we'll move on now to the 27th lesson, which gets into a very cool topic, which is facial

81
00:04:53,040 --> 00:04:55,830
unlock detection using the dylib library.

82
00:04:56,460 --> 00:04:58,170
So I'll see you in the next lesson.

83
00:04:58,290 --> 00:04:58,770
Thank you.
