AI_DL_Assignment / 5. OpenCV Tutorial - Learn Classic Computer Vision & Face Detection (OPTIONAL) /12. Rotations - How To Spin Your Image Around And Do Horizontal Flipping.srt
| 1 | |
| 00:00:02,190 --> 00:00:05,050 | |
| So let's talk a bit about rotations now rotations. | |
| 2 | |
| 00:00:05,220 --> 00:00:06,180 | |
| Pretty simple as well. | |
| 3 | |
| 00:00:06,180 --> 00:00:09,590 | |
| HOLOVATY also more Quick's that I'll teach you quickly. | |
| 4 | |
| 00:00:09,720 --> 00:00:15,980 | |
| So using a favorite politician again Donald Trump issued exactly what a rotation is. | |
| 5 | |
| 00:00:15,990 --> 00:00:20,660 | |
| So as you can see it rotates about a point and this point here in this image is the center. | |
| 6 | |
| 00:00:20,970 --> 00:00:26,010 | |
| And just to set the image around that point so imagine that point as a pivot. | |
| 7 | |
| 00:00:26,010 --> 00:00:29,710 | |
| So similarly in no translation transformation. | |
| 8 | |
| 00:00:30,160 --> 00:00:31,270 | |
| We had a matrix. | |
| 9 | |
| 00:00:31,290 --> 00:00:36,650 | |
| Now we have an M matrix which is the shorthand used for the rotation matrix. | |
| 10 | |
| 00:00:36,660 --> 00:00:38,390 | |
| Here is the angle of rotation. | |
| 11 | |
| 00:00:38,430 --> 00:00:42,920 | |
| As you can see it's an anti-clockwise angle measured from this point here. | |
| 12 | |
| 00:00:43,650 --> 00:00:50,520 | |
| And one important thing to note is that the open Sivy function which is get tradition which is 2D actually | |
| 13 | |
| 00:00:50,520 --> 00:00:55,580 | |
| does scaling an irritation at the same time which you will see in the code. | |
| 14 | |
| 00:00:56,010 --> 00:01:01,460 | |
| So let's implement some mortician's using open C-v superstitions are very similar to translations in | |
| 15 | |
| 00:01:01,470 --> 00:01:04,290 | |
| that we actually have to generate a transformation matrix. | |
| 16 | |
| 00:01:04,290 --> 00:01:09,420 | |
| What we call the rotation matrix here and to do that we actually use an open CB function called Get | |
| 17 | |
| 00:01:09,420 --> 00:01:11,450 | |
| a rotation matrix 2d. | |
| 18 | |
| 00:01:11,450 --> 00:01:13,840 | |
| Now this function is fairly simple as well. | |
| 19 | |
| 00:01:13,890 --> 00:01:21,900 | |
| What you give it is this argument is sense of x and y Center which corresponds to width and height that's | |
| 20 | |
| 00:01:21,900 --> 00:01:23,120 | |
| the center point of the image. | |
| 21 | |
| 00:01:23,130 --> 00:01:28,950 | |
| In most cases however you can and you are free to retaliate among among any point in image for whatever | |
| 22 | |
| 00:01:28,950 --> 00:01:32,780 | |
| reason that maybe this is a theater which is an angle of addition. | |
| 23 | |
| 00:01:32,790 --> 00:01:38,420 | |
| Remember it's anti-clockwise and this is a scaling factor which will bring or bring up shortly. | |
| 24 | |
| 00:01:38,820 --> 00:01:44,030 | |
| And we use this rotation matrix again and it happens if you walk a fine function. | |
| 25 | |
| 00:01:44,060 --> 00:01:46,810 | |
| So let's run this could see what it looks like. | |
| 26 | |
| 00:01:46,820 --> 00:01:47,250 | |
| There we go. | |
| 27 | |
| 00:01:47,260 --> 00:01:52,610 | |
| So that's that image rotated 90 degrees anti-clockwise and you may have noticed that a top and bottom | |
| 28 | |
| 00:01:52,610 --> 00:01:57,370 | |
| parts of the image are cropped mainly because the canvas séjour means a seam. | |
| 29 | |
| 00:01:57,440 --> 00:01:59,660 | |
| So there are two ways we can fix that one. | |
| 30 | |
| 00:02:00,110 --> 00:02:01,430 | |
| Let's adjust the scale here. | |
| 31 | |
| 00:02:01,440 --> 00:02:05,610 | |
| So let's put this point five wiggle. | |
| 32 | |
| 00:02:05,700 --> 00:02:08,520 | |
| However it is a lot of black space around this image. | |
| 33 | |
| 00:02:08,910 --> 00:02:15,450 | |
| Now to avoid that you would actually have to actually put the specific width and height of the new rotated | |
| 34 | |
| 00:02:15,450 --> 00:02:16,210 | |
| image. | |
| 35 | |
| 00:02:16,320 --> 00:02:19,880 | |
| So whatever you anticipate it to be you can program it here. | |
| 36 | |
| 00:02:20,490 --> 00:02:23,190 | |
| However that's not often what is not. | |
| 37 | |
| 00:02:23,190 --> 00:02:27,510 | |
| It's a bit tedious to do sometimes unless you have a special case for it. | |
| 38 | |
| 00:02:27,510 --> 00:02:33,420 | |
| There's another way we can do it and that's by using the transpose function here not the transpose function | |
| 39 | |
| 00:02:33,640 --> 00:02:34,990 | |
| that's run the school and see what happens. | |
| 40 | |
| 00:02:35,020 --> 00:02:39,640 | |
| This is actually transposes image 100 percent. | |
| 41 | |
| 00:02:39,660 --> 00:02:44,530 | |
| No you may not see the bottom because it's cut off from the screen casting off here. | |
| 42 | |
| 00:02:44,970 --> 00:02:52,340 | |
| Over that image is fully done and here anti-clockwise and there's no black space around it. | |
| 43 | |
| 00:02:55,230 --> 00:02:58,960 | |
| So this is just another easy and convenient way for teaching images. | |
| 44 | |
| 00:02:58,980 --> 00:03:04,470 | |
| However when he does it in 90 degrees increments at one time so he can play around with us and actually | |
| 45 | |
| 00:03:04,470 --> 00:03:10,230 | |
| do some cool rotations without having to actually program it with a new with a new height of the new | |
| 46 | |
| 00:03:10,230 --> 00:03:10,860 | |
| canvas. | |