1 00:00:00,570 --> 00:00:01,070 All right. 2 00:00:01,140 --> 00:00:04,640 So we've reached a second many projects here ship matching. 3 00:00:04,880 --> 00:00:05,860 So what we're going to do. 4 00:00:05,880 --> 00:00:11,460 We're going to take an image that looks like this here with five different images one identify each 5 00:00:11,460 --> 00:00:15,370 ship put the name of the ship inside of the ship here. 6 00:00:15,660 --> 00:00:17,910 And as we all change the color of each ship. 7 00:00:17,970 --> 00:00:19,110 So let's get started. 8 00:00:20,160 --> 00:00:20,510 OK. 9 00:00:20,540 --> 00:00:27,050 So let's get started with opening the code for a second mini projec that's lecture four point five bring 10 00:00:27,340 --> 00:00:27,970 it up here. 11 00:00:28,930 --> 00:00:29,270 OK. 12 00:00:29,310 --> 00:00:33,180 So I'll just tell you beforehand even though the code looks a bit lengthy and maybe a bit confusing 13 00:00:33,690 --> 00:00:35,140 it's actually quite simple. 14 00:00:35,460 --> 00:00:38,990 So let's run the code for this and get a idea of what's going on here. 15 00:00:39,600 --> 00:00:45,540 So D.S.O. input image here with our ship's unlabelled and everything black and white. 16 00:00:45,570 --> 00:00:45,980 There we go. 17 00:00:45,990 --> 00:00:47,160 Stuffings you one by one. 18 00:00:47,170 --> 00:00:47,910 Here's a star. 19 00:00:47,920 --> 00:00:51,540 Here's a circle triangle rectangle and a square. 20 00:00:51,540 --> 00:00:51,980 Cool. 21 00:00:51,990 --> 00:00:53,720 So let's see how it's done. 22 00:00:53,920 --> 00:00:56,870 Seriously what we do we LoDo image in here. 23 00:00:57,180 --> 00:01:03,570 As you can see when we brought up the image here there was just black and white image here. 24 00:01:03,780 --> 00:01:08,250 So it is known really the Trishul just have troubling here because it's actually become maybe about 25 00:01:08,250 --> 00:01:09,000 half that now. 26 00:01:09,270 --> 00:01:13,750 But the most important thing to do is actually to grayscale the image here. 27 00:01:13,770 --> 00:01:20,940 So loading the image here into a fine control function we use these parameters here an approximate none 28 00:01:21,360 --> 00:01:26,770 retrieve list which gives us all our contours and we have we get extractable Cantos here. 29 00:01:28,980 --> 00:01:31,590 So stepping true to us here. 30 00:01:31,740 --> 00:01:33,610 Do you remember dysfunction function approximate poly. 31 00:01:33,600 --> 00:01:40,740 DP Well what we're doing here just in case there any edges or any of the C's that are considered when 32 00:01:40,740 --> 00:01:46,270 we are finding Contos which happens quite often use approximate contours to get the approximate shape. 33 00:01:46,320 --> 00:01:48,860 So these are parameters that are fine tuned for it here. 34 00:01:49,080 --> 00:01:53,120 However feel free to justice as you see fit. 35 00:01:53,280 --> 00:01:56,260 So we have our approximate value here. 36 00:01:56,310 --> 00:01:58,120 Proximate Contos here sorry. 37 00:01:58,500 --> 00:02:04,230 So what we're doing now we're checking the length of each approximate Quanto if it's tree because that's 38 00:02:04,230 --> 00:02:10,770 all approximate that Quanto a sheep then we obviously know a tree polygon a three sided shape or a story 39 00:02:11,080 --> 00:02:12,210 shape retrieve. 40 00:02:12,350 --> 00:02:16,180 The disease is a triangle that took a while to see. 41 00:02:16,410 --> 00:02:22,740 So then we actually draw no or Cantal tell this is CND here we draw over that image and then using the 42 00:02:22,740 --> 00:02:27,870 moments just as this is just done so we can actually place our attacks in the image here and you may 43 00:02:27,870 --> 00:02:28,130 have. 44 00:02:28,160 --> 00:02:31,590 We've done this before but you may have noticed I put minus 50 here. 45 00:02:31,590 --> 00:02:39,090 And the reason they put minus 50 an x axis is because since it starts at the bottom right or bottom 46 00:02:39,090 --> 00:02:41,440 left corner the tech protects here. 47 00:02:41,460 --> 00:02:47,180 I just want to pull back the text a bit more that we had just with this text and image. 48 00:02:47,210 --> 00:02:50,340 Oh this and maybe I can do it for that for you if you want. 49 00:02:50,600 --> 00:02:56,400 But putting the minus 50 here detects was sort of like skewed across the image and it didn't look too 50 00:02:56,400 --> 00:02:57,750 nice. 51 00:02:57,750 --> 00:03:04,060 And this is a fun color we are using which is black and thickness and font size. 52 00:03:04,440 --> 00:03:05,100 So there we go. 53 00:03:05,100 --> 00:03:07,720 So that's homemade and defy if it's a triangle here. 54 00:03:08,030 --> 00:03:09,690 So pretty simple so far. 55 00:03:09,960 --> 00:03:12,070 Hopefully you follow me well. 56 00:03:12,150 --> 00:03:14,510 So what about if it's for say that shape. 57 00:03:14,720 --> 00:03:21,530 Here's what gets a bit more complicated because we have foresighted ship it can either be a square or 58 00:03:21,540 --> 00:03:22,460 rectangle. 59 00:03:22,830 --> 00:03:27,840 So again doing the Mormons and getting the bounding story getting to woman's Foose just to get labels 60 00:03:28,170 --> 00:03:28,870 done right. 61 00:03:30,230 --> 00:03:37,040 We find actually the bounding rectangle here not a bonga rectangle was done so that we can determine 62 00:03:37,190 --> 00:03:43,220 if div foresighted shape we have found here is a square or a rectangle. 63 00:03:43,220 --> 00:03:44,710 So how do we do that. 64 00:03:44,720 --> 00:03:51,280 So what do we do we basically just compare the Derwood minus to height. 65 00:03:51,290 --> 00:03:52,530 As you remember. 66 00:03:52,670 --> 00:03:56,600 When you use Boulding rectangle width and height are basically pixels. 67 00:03:56,600 --> 00:03:58,780 It extends from the x y point. 68 00:03:58,940 --> 00:04:03,470 So I imagine in most cases being x y point top left there isn't destruction. 69 00:04:03,470 --> 00:04:05,950 Height isn't destruction if it's a square. 70 00:04:06,000 --> 00:04:08,360 Those those values should be roughly similar. 71 00:04:08,630 --> 00:04:14,060 So I have here is the absolute value of W minus H is less than or equal to tree. 72 00:04:14,420 --> 00:04:16,350 Then it can be classified as a square. 73 00:04:16,700 --> 00:04:18,370 And we do it we draw it again. 74 00:04:18,410 --> 00:04:22,690 This is DiCarlo we're actually filling in the minus ones to fill the image. 75 00:04:22,780 --> 00:04:25,740 The control this is a color we're using here. 76 00:04:26,030 --> 00:04:28,210 And we're putting the text in the center again. 77 00:04:28,460 --> 00:04:30,090 So now we want to star. 78 00:04:30,470 --> 00:04:36,350 No when you actually run it to run start to it you realized is four is actually five witnesses in a 79 00:04:36,420 --> 00:04:40,960 stall and that's pretty much how we then define a style similar to the triangle. 80 00:04:41,120 --> 00:04:45,610 And again circle cycle basically we just said anything could be more. 81 00:04:45,630 --> 00:04:48,500 Anything that's more than 15 VDC is will be a signal. 82 00:04:48,500 --> 00:04:53,420 Now this could have been started that 11:12 I just have it set it for 15 minute because it gives We 83 00:04:53,420 --> 00:04:59,630 actually got more points on a star maybe maybe because I was tuning this beforehand. 84 00:05:00,800 --> 00:05:05,120 Maybe it just sort of been set 11 that doesn't matter right now because it's still identifying this 85 00:05:05,210 --> 00:05:12,500 signal because as you can imagine even with some unless we do some very non granular approximation a 86 00:05:12,530 --> 00:05:15,580 circle is going to have a lot more points and 15. 87 00:05:15,650 --> 00:05:16,340 So there we go. 88 00:05:16,430 --> 00:05:17,970 So let's run this one more time. 89 00:05:20,360 --> 00:05:23,740 And we have labeled all the images correctly here. 90 00:05:23,810 --> 00:05:29,480 So congratulations you've completed your second many projec hopefully learned a lot by using this project.