File size: 8,367 Bytes
17e2002 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | 1
00:00:00,660 --> 00:00:04,120
So what we're going to look at now is called approximating contours.
2
00:00:04,480 --> 00:00:06,700
So fleecy let's open this file here.
3
00:00:06,750 --> 00:00:08,310
This is 4.3.
4
00:00:08,700 --> 00:00:09,530
4.3 here
5
00:00:13,300 --> 00:00:16,060
and that's actually run this could see what's going on.
6
00:00:16,420 --> 00:00:20,680
So I have a very crudely drawn house that I did by hand to do a splint.
7
00:00:20,920 --> 00:00:22,550
Thank you very much.
8
00:00:22,660 --> 00:00:26,330
And this is what happens when we extract contours and approx.
9
00:00:26,340 --> 00:00:31,360
I used a bonding rectangle for Contos so you can see we've have we have a bonding rectangle for the
10
00:00:31,360 --> 00:00:32,530
entire house.
11
00:00:32,680 --> 00:00:33,810
Then one for the roof.
12
00:00:33,820 --> 00:00:39,460
So I'm guessing find Quanto has found contours of this triangle here than the door and then the bottom
13
00:00:39,460 --> 00:00:40,560
half of the hose here.
14
00:00:40,810 --> 00:00:42,130
So that's pretty cool.
15
00:00:42,170 --> 00:00:45,720
Now there they're prox to approx function is what we're going to look at.
16
00:00:45,720 --> 00:00:46,300
No.
17
00:00:46,650 --> 00:00:52,660
And what does that actually as you can see here trace approximate or contour shape better.
18
00:00:53,140 --> 00:01:00,770
So this may look a lot similar to the actual initial contour operation here.
19
00:01:00,900 --> 00:01:04,450
However what it does it actually tries to approximate a polygon here.
20
00:01:04,500 --> 00:01:06,060
So let's take a look at a function here.
21
00:01:10,190 --> 00:01:11,660
So you can see you know a loop here.
22
00:01:11,660 --> 00:01:12,490
We're actually doing.
23
00:01:12,530 --> 00:01:14,030
We're looking through the Contos again.
24
00:01:14,030 --> 00:01:15,950
We found find Contos right here.
25
00:01:16,160 --> 00:01:19,650
And refining all contours and doing no approximation here.
26
00:01:19,730 --> 00:01:24,380
Maybe I should have done a simple approximation although it wouldn't have made much difference in this
27
00:01:24,380 --> 00:01:25,190
example here.
28
00:01:28,110 --> 00:01:35,700
Going back to Otari approximate poly DP function here in TV2 This is how we approximate Contos is actually
29
00:01:35,700 --> 00:01:41,430
very useful if you have a noisy image with jagged contours and you know a ship is supposed to be square
30
00:01:41,490 --> 00:01:47,880
or a triangle whoever you're getting maybe multiple edges and that polygon dysfunction actually basically
31
00:01:48,770 --> 00:01:51,020
approximates approximates it for you.
32
00:01:51,030 --> 00:01:54,390
So let's look at the parameters it takes in here.
33
00:01:54,410 --> 00:01:55,410
So at a high level.
34
00:01:55,430 --> 00:01:57,500
Describe exactly what his function is doing.
35
00:01:57,710 --> 00:02:04,280
So it takes tree parameters into consideration here it takes input CONTO something called an approximation
36
00:02:04,310 --> 00:02:06,520
accuracy which I'll discuss shortly.
37
00:02:06,650 --> 00:02:11,570
And basically what do we want on a closed polygon or open polygon.
38
00:02:11,640 --> 00:02:15,080
So is being preferred in pretty much all cases I believe.
39
00:02:15,200 --> 00:02:21,020
So let's take a look at approximation accuracy approximation accuracy is basically how detailed the
40
00:02:21,020 --> 00:02:25,910
whole finally agree and do you want the approximation to be if you want to low accuracy and a good rule
41
00:02:25,910 --> 00:02:28,960
of thumb here is 5 percent of the contour perimeter.
42
00:02:29,000 --> 00:02:35,660
However if you go to high efficiency with accuracy let's look at c using Point 1 here.
43
00:02:35,660 --> 00:02:40,870
Let's see what happens it actually does something pretty weird it actually tries to approximate the
44
00:02:40,870 --> 00:02:44,350
house into the freedom of the house into a triangle.
45
00:02:44,350 --> 00:02:45,670
That's clearly not good.
46
00:02:45,940 --> 00:02:46,450
So what if.
47
00:02:46,470 --> 00:02:53,820
What about if we use point 0 1 as you can see it actually tries to match the house even closer.
48
00:02:53,830 --> 00:02:58,810
So what I suggest is that you maybe maybe play with these values a bit when he actually works fairly
49
00:02:58,810 --> 00:03:00,700
well in this case here.
50
00:03:00,940 --> 00:03:06,580
Basically the accuracy or to reassure to perimeter the more precise the approximation is going to be
51
00:03:07,030 --> 00:03:13,410
and the higher value here the more logic green that the approximation is going to be.
52
00:03:13,660 --> 00:03:17,310
So let's keep that in mind when you're actually playing with the accuracy parameter here.
53
00:03:18,640 --> 00:03:23,440
OK so let's move on to the convex hull and the convex hole is an interesting concept and it's actually
54
00:03:23,440 --> 00:03:27,070
run Decoud to illustrate this.
55
00:03:27,200 --> 00:03:31,110
So as you can see we have a hand here sort of like a blue.
56
00:03:31,260 --> 00:03:37,900
And right now and continuing we have what is called the convex hull not a convex hole.
57
00:03:37,910 --> 00:03:43,670
Basically if you can kind of figured out from this image here it looks a different do outer edges here
58
00:03:43,760 --> 00:03:46,590
and it draws lines to each edges here.
59
00:03:46,610 --> 00:03:54,410
Basically it's what you call the smallest polygon that can fit or the object itself and HUD's found
60
00:03:54,440 --> 00:03:56,410
it actually is pretty simple as well.
61
00:03:58,260 --> 00:04:04,140
So all that's happening here is that in this loop here we're digging contours that we found here.
62
00:04:04,560 --> 00:04:06,660
There's actually two ends of quid I'll explain shortly here.
63
00:04:06,660 --> 00:04:08,570
It's not too critical just something it does.
64
00:04:08,610 --> 00:04:08,870
I did.
65
00:04:08,870 --> 00:04:16,850
And just to show you guys and using the CV to convex whole function it generates a whole data type here
66
00:04:16,920 --> 00:04:18,320
which is actually in tree.
67
00:04:18,600 --> 00:04:24,540
And then we put the saree into distro Kontos which takes in a list function a list variable I should
68
00:04:24,540 --> 00:04:30,180
say and we just draw all the contorts off the image.
69
00:04:30,530 --> 00:04:32,680
So that's all there is to it and convex whole.
70
00:04:32,960 --> 00:04:39,200
It's actually quite simple to implement and use this sort of line of code is actually when you use to
71
00:04:39,380 --> 00:04:42,170
retrieve list method what happens is that.
72
00:04:42,200 --> 00:04:44,730
Oh mislaying let's just keep this.
73
00:04:44,770 --> 00:04:45,470
Whoops.
74
00:04:48,130 --> 00:04:49,130
And do that.
75
00:04:49,230 --> 00:04:51,650
Let's just keep this here the same.
76
00:04:51,690 --> 00:04:56,430
So let's run the code again and you'll see a box drawn over this image here.
77
00:04:56,700 --> 00:05:02,590
And what happens is that every time you find a console and a white image here it actually identifies
78
00:05:02,590 --> 00:05:05,530
the white background itself as a conto.
79
00:05:05,610 --> 00:05:09,260
If it was a black image it wouldn't have happened in this way.
80
00:05:09,390 --> 00:05:17,070
So to get rid of that which happens what I do I tend to do sometimes just use this little lines of code
81
00:05:17,070 --> 00:05:22,890
here that just if I wanted all Kontos but I wanted to eliminate that largest CONTO I saw the Contos
82
00:05:22,890 --> 00:05:30,930
Bay Area and they just use non-pay to index it at everything except the first or largest Hanzal and
83
00:05:30,930 --> 00:05:32,460
that's simply what they do here.
84
00:05:32,610 --> 00:05:39,340
So this is a way to get rid of that first box or an entire image and generally just decline to be where
85
00:05:39,370 --> 00:05:40,950
I want to look at here.
|