├── .gitignore ├── LICENSE ├── README.md ├── Resources ├── Faces │ ├── train │ │ ├── Ben Afflek │ │ │ ├── 1.jpg │ │ │ ├── 10.jpg │ │ │ ├── 11.jpg │ │ │ ├── 12.jpg │ │ │ ├── 13.jpg │ │ │ ├── 14.jpg │ │ │ ├── 2.jpg │ │ │ ├── 3.jpg │ │ │ ├── 4.jpg │ │ │ ├── 5.jpg │ │ │ ├── 6.jpg │ │ │ ├── 7.jpg │ │ │ ├── 8.jpg │ │ │ └── 9.jpg │ │ ├── Elton John │ │ │ ├── 1.jpg │ │ │ ├── 10.jpg │ │ │ ├── 11.jpg │ │ │ ├── 12.jpg │ │ │ ├── 13.jpg │ │ │ ├── 14.jpg │ │ │ ├── 15.jpg │ │ │ ├── 16.jpg │ │ │ ├── 17.jpg │ │ │ ├── 2.jpg │ │ │ ├── 3.jpg │ │ │ ├── 4.jpg │ │ │ ├── 5.jpg │ │ │ ├── 6.jpg │ │ │ ├── 7.jpg │ │ │ ├── 8.jpg │ │ │ └── 9.jpg │ │ ├── Jerry Seinfield │ │ │ ├── 1.jpg │ │ │ ├── 10.jpg │ │ │ ├── 11.jpg │ │ │ ├── 12.jpg │ │ │ ├── 13.jpg │ │ │ ├── 14.jpg │ │ │ ├── 15.jpg │ │ │ ├── 16.jpg │ │ │ ├── 17.jpg │ │ │ ├── 18.jpg │ │ │ ├── 19.jpg │ │ │ ├── 2.jpg │ │ │ ├── 20.jpg │ │ │ ├── 21.jpg │ │ │ ├── 3.jpg │ │ │ ├── 4.jpg │ │ │ ├── 5.jpg │ │ │ ├── 6.jpg │ │ │ ├── 7.jpg │ │ │ ├── 8.jpg │ │ │ └── 9.jpg │ │ ├── Madonna │ │ │ ├── 1.jpg │ │ │ ├── 10.jpg │ │ │ ├── 11.jpg │ │ │ ├── 12.jpg │ │ │ ├── 13.jpg │ │ │ ├── 14.jpg │ │ │ ├── 15.jpg │ │ │ ├── 16.jpg │ │ │ ├── 17.jpg │ │ │ ├── 18.jpg │ │ │ ├── 19.jpg │ │ │ ├── 2.jpg │ │ │ ├── 3.jpg │ │ │ ├── 4.jpg │ │ │ ├── 5.jpg │ │ │ ├── 6.jpg │ │ │ ├── 7.jpg │ │ │ ├── 8.jpg │ │ │ └── 9.jpg │ │ └── Mindy Kaling │ │ │ ├── 1.jpg │ │ │ ├── 10.jpg │ │ │ ├── 11.jpg │ │ │ ├── 12.jpg │ │ │ ├── 13.jpg │ │ │ ├── 14.jpg │ │ │ ├── 15.jpg │ │ │ ├── 16.jpg │ │ │ ├── 17.jpg │ │ │ ├── 18.jpg │ │ │ ├── 19.jpg │ │ │ ├── 2.jpg │ │ │ ├── 20.jpg │ │ │ ├── 21.jpg │ │ │ ├── 22.jpg │ │ │ ├── 3.jpg │ │ │ ├── 4.jpg │ │ │ ├── 5.jpg │ │ │ ├── 6.jpg │ │ │ ├── 7.jpg │ │ │ ├── 8.jpg │ │ │ └── 9.jpg │ └── val │ │ ├── ben_afflek │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ └── 5.jpg │ │ ├── elton_john │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ └── 5.jpg │ │ ├── jerry_seinfeld │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ └── 5.jpg │ │ ├── madonna │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ └── 5.jpg │ │ └── mindy_kaling │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ └── 5.jpg ├── Photos │ ├── cat.jpg │ ├── cat_large.jpg │ ├── cats 2.jpg │ ├── cats.jpg │ ├── group 1.jpg │ ├── group 2.jpg │ ├── lady.jpg │ └── park.jpg └── Videos │ ├── dog.mp4 │ └── kitten.mp4 ├── Section #1 - Basics ├── basic_functions.py ├── contours.py ├── draw.py ├── read.py ├── thresh.py └── transformations.py ├── Section #2 - Advanced ├── bitwise.py ├── blurring.py ├── colour_spaces.py ├── gradients.py ├── histogram.py ├── masking.py ├── rescale_resize.py └── splitmerge.py ├── Section #3 - Faces ├── face_detect.py ├── face_recognition.py ├── face_trained.yml ├── faces_train.py ├── features.npy ├── haar_face.xml └── labels.npy └── Section #4 - Capstone ├── simpsons.ipynb └── simpsons.py /.gitignore: -------------------------------------------------------------------------------- 1 | .pylintrc -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Jason Dsouza 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenCV with Python in 4 Hours 2 | Notes and code used in my [**Python and OpenCV course**](https://youtu.be/oXlwWbU8l2o) on [freeCodeCamp.org](http://freecodecamp.org). You can find me on [Twitter](https://twitter.com/jasmcaus) for more info on courses I'm working on currently. 3 | 4 | 5 | ## Important Updates: 6 | `caer.train_val_split()` is a deprecated feature in [`caer`](https://github.com/jasmcaus/caer/). Use `sklearn.model_selection.train_test_split()` instead. See [#9](https://github.com/jasmcaus/opencv-course/issues/9) for more details. 7 | 8 | 9 | # Course Outline (with timestamps) 10 | ## 1. Installation 11 | Besides installing OpenCV, we cover the installation of the following package: 12 | 13 | [**`Caer`**](https://github.com/jasmcaus/caer/) is a *lightweight, high-performance* Vision library for high-performance AI research. It simplifies your approach towards Computer Vision by abstracting away unnecessary boilerplate code giving you the **flexibility** to quickly prototype deep learning models and research ideas. 14 | ```bash 15 | $ pip install caer 16 | ``` 17 | 18 | 19 | ## 2. Basic Concepts: 20 | - Reading Images and Video ([0:04:12](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=252s)) 21 | - Resizing and Rescaling Images and Video Frames ([0:12:57](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=777s)) 22 | - Drawing Shapes and Placing text on images ([0:20:21](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=1221s)) 23 | - 5 Essential Methods in OpenCV ([0:31:55](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=1915s)) 24 | - Image Transformations ([0:44:13](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=2653s)) 25 | - Contour Detection ([0:57:06](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=3426s)) 26 | 27 | ## 3. Advanced Concepts: 28 | - Switching between Colour Spaces (RGB, BGR, Grayscale, HSV and L*a*b) ([1:12:53](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=4373s)) 29 | - Splitting and Merging Colour Channels ([1:23:10](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=4990s)) 30 | - Blurring ([1:31:03](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=5463s)) 31 | - BITWISE operations ([1:44:27](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=6267s)) 32 | - Masking ([1:53:06](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=6786s)) 33 | - Histogram Computation ([2:01:43](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=7303s)) 34 | - Thresholding/Binarizing Images ([2:15:22](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=8122s)) 35 | - Advanced Edge Detection ([2:26:27](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=8787s)) 36 | 37 | ## 4. Face Detection and Recognition 38 | - Face Detection using Haar Cascades ([2:35:25](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=9325s)) 39 | - Face Recognition using OpenCV's LBPHFaceRecognizer algorithm ([2:49:05](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=10145s)) 40 | 41 | ## 5. Capstone: Deep Computer Vision 42 | - Building a Deep Computer Vision model to classify between the characters in the popular TV series The Simpsons ([3:11:57](https://www.youtube.com/watch?v=x3c8w2ruhjs&t=11517s)) 43 | 44 | # Credits 45 | The images in the [Photos](https://github.com/jasmcaus/opencv-course/tree/master/Resources/Photos) and [Videos](https://github.com/jasmcaus/opencv-course/tree/master/Resources/Videos) folders were downloaded from [Unsplash](http://unsplash.com) and [Pixabay](http://pixabay.com), unless otherwise mentioned. 46 | 47 | 48 | The images in the [Faces](https://github.com/jasmcaus/opencv-course/tree/master/Resources/Faces) folder were procurred from a [repo](https://www.kaggle.com/dansbecker/5-celebrity-faces-dataset) on Kaggle. 49 | -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/10.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/11.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/12.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/13.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/14.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/5.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/6.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/7.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/8.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Ben Afflek/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Ben Afflek/9.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/10.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/11.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/12.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/13.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/14.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/15.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/16.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/17.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/5.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/6.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/7.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/8.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Elton John/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Elton John/9.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/10.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/11.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/12.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/13.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/14.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/15.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/16.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/17.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/18.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/19.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/20.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/21.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/5.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/6.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/7.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/8.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Jerry Seinfield/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Jerry Seinfield/9.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/10.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/11.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/12.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/13.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/14.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/15.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/16.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/17.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/18.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/19.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/5.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/6.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/7.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/8.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Madonna/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Madonna/9.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/10.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/11.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/12.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/13.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/14.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/15.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/16.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/17.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/18.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/19.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/20.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/21.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/22.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/5.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/6.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/7.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/8.jpg -------------------------------------------------------------------------------- /Resources/Faces/train/Mindy Kaling/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/train/Mindy Kaling/9.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/ben_afflek/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/ben_afflek/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/ben_afflek/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/ben_afflek/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/ben_afflek/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/ben_afflek/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/ben_afflek/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/ben_afflek/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/ben_afflek/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/ben_afflek/5.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/elton_john/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/elton_john/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/elton_john/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/elton_john/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/elton_john/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/elton_john/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/elton_john/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/elton_john/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/elton_john/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/elton_john/5.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/jerry_seinfeld/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/jerry_seinfeld/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/jerry_seinfeld/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/jerry_seinfeld/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/jerry_seinfeld/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/jerry_seinfeld/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/jerry_seinfeld/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/jerry_seinfeld/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/jerry_seinfeld/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/jerry_seinfeld/5.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/madonna/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/madonna/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/madonna/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/madonna/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/madonna/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/madonna/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/madonna/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/madonna/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/madonna/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/madonna/5.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/mindy_kaling/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/mindy_kaling/1.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/mindy_kaling/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/mindy_kaling/2.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/mindy_kaling/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/mindy_kaling/3.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/mindy_kaling/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/mindy_kaling/4.jpg -------------------------------------------------------------------------------- /Resources/Faces/val/mindy_kaling/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Faces/val/mindy_kaling/5.jpg -------------------------------------------------------------------------------- /Resources/Photos/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Photos/cat.jpg -------------------------------------------------------------------------------- /Resources/Photos/cat_large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Photos/cat_large.jpg -------------------------------------------------------------------------------- /Resources/Photos/cats 2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Photos/cats 2.jpg -------------------------------------------------------------------------------- /Resources/Photos/cats.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Photos/cats.jpg -------------------------------------------------------------------------------- /Resources/Photos/group 1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Photos/group 1.jpg -------------------------------------------------------------------------------- /Resources/Photos/group 2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Photos/group 2.jpg -------------------------------------------------------------------------------- /Resources/Photos/lady.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Photos/lady.jpg -------------------------------------------------------------------------------- /Resources/Photos/park.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Photos/park.jpg -------------------------------------------------------------------------------- /Resources/Videos/dog.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Videos/dog.mp4 -------------------------------------------------------------------------------- /Resources/Videos/kitten.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Resources/Videos/kitten.mp4 -------------------------------------------------------------------------------- /Section #1 - Basics/basic_functions.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | 5 | # Read in an image 6 | img = cv.imread('../Resources/Photos/park.jpg') 7 | cv.imshow('Park', img) 8 | 9 | # Converting to grayscale 10 | gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) 11 | cv.imshow('Gray', gray) 12 | 13 | # Blur 14 | blur = cv.GaussianBlur(img, (7,7), cv.BORDER_DEFAULT) 15 | cv.imshow('Blur', blur) 16 | 17 | # Edge Cascade 18 | canny = cv.Canny(blur, 125, 175) 19 | cv.imshow('Canny Edges', canny) 20 | 21 | # Dilating the image 22 | dilated = cv.dilate(canny, (7,7), iterations=3) 23 | cv.imshow('Dilated', dilated) 24 | 25 | # Eroding 26 | eroded = cv.erode(dilated, (7,7), iterations=3) 27 | cv.imshow('Eroded', eroded) 28 | 29 | # Resize 30 | resized = cv.resize(img, (500,500), interpolation=cv.INTER_CUBIC) 31 | cv.imshow('Resized', resized) 32 | 33 | # Cropping 34 | cropped = img[50:200, 200:400] 35 | cv.imshow('Cropped', cropped) -------------------------------------------------------------------------------- /Section #1 - Basics/contours.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | import numpy as np 5 | 6 | img = cv.imread('../Resources/Photos/cats.jpg') 7 | cv.imshow('Cats', img) 8 | 9 | blank = np.zeros(img.shape, dtype='uint8') 10 | cv.imshow('Blank', blank) 11 | 12 | gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) 13 | cv.imshow('Gray', gray) 14 | 15 | blur = cv.GaussianBlur(gray, (5,5), cv.BORDER_DEFAULT) 16 | cv.imshow('Blur', blur) 17 | 18 | canny = cv.Canny(blur, 125, 175) 19 | cv.imshow('Canny Edges', canny) 20 | 21 | # ret, thresh = cv.threshold(gray, 125, 255, cv.THRESH_BINARY) 22 | # cv.imshow('Thresh', thresh) 23 | 24 | contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.CHAIN_APPROX_SIMPLE) 25 | print(f'{len(contours)} contour(s) found!') 26 | 27 | cv.drawContours(blank, contours, -1, (0,0,255), 1) 28 | cv.imshow('Contours Drawn', blank) 29 | 30 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #1 - Basics/draw.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | import numpy as np 5 | 6 | blank = np.zeros((500,500,3), dtype='uint8') 7 | cv.imshow('Blank', blank) 8 | 9 | # 1. Paint the image a certain colour 10 | blank[200:300, 300:400] = 0,0,255 11 | cv.imshow('Green', blank) 12 | 13 | # 2. Draw a Rectangle 14 | cv.rectangle(blank, (0,0), (blank.shape[1]//2, blank.shape[0]//2), (0,255,0), thickness=-1) 15 | cv.imshow('Rectangle', blank) 16 | 17 | # 3. Draw A circle 18 | cv.circle(blank, (blank.shape[1]//2, blank.shape[0]//2), 40, (0,0,255), thickness=-1) 19 | cv.imshow('Circle', blank) 20 | 21 | # 4. Draw a line 22 | cv.line(blank, (100,250), (300,400), (255,255,255), thickness=3) 23 | cv.imshow('Line', blank) 24 | 25 | # 5. Write text 26 | cv.putText(blank, 'Hello, my name is Jason!!!', (0,225), cv.FONT_HERSHEY_TRIPLEX, 1.0, (0,255,0), 2) 27 | cv.imshow('Text', blank) 28 | 29 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #1 - Basics/read.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | 5 | img = cv.imread('../Resources/Photos/cats.jpg') 6 | cv.imshow('Cats', img) 7 | 8 | cv.waitKey(0) 9 | 10 | # Reading Videos 11 | capture = cv.VideoCapture('../Resources/Videos/dog.mp4') 12 | 13 | while True: 14 | isTrue, frame = capture.read() 15 | 16 | # if cv.waitKey(20) & 0xFF==ord('d'): 17 | # This is the preferred way - if `isTrue` is false (the frame could 18 | # not be read, or we're at the end of the video), we immediately 19 | # break from the loop. 20 | if isTrue: 21 | cv.imshow('Video', frame) 22 | if cv.waitKey(20) & 0xFF==ord('d'): 23 | break 24 | else: 25 | break 26 | 27 | capture.release() 28 | cv.destroyAllWindows() 29 | -------------------------------------------------------------------------------- /Section #1 - Basics/thresh.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | 5 | img = cv.imread('../Resources/Photos/cats.jpg') 6 | cv.imshow('Cats', img) 7 | 8 | gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) 9 | cv.imshow('Gray', gray) 10 | 11 | # Simple Thresholding 12 | threshold, thresh = cv.threshold(gray, 150, 255, cv.THRESH_BINARY ) 13 | cv.imshow('Simple Thresholded', thresh) 14 | 15 | threshold, thresh_inv = cv.threshold(gray, 150, 255, cv.THRESH_BINARY_INV ) 16 | cv.imshow('Simple Thresholded Inverse', thresh_inv) 17 | 18 | # Adaptive Thresholding 19 | adaptive_thresh = cv.adaptiveThreshold(gray, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY_INV, 11, 9) 20 | cv.imshow('Adaptive Thresholding', adaptive_thresh) 21 | 22 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #1 - Basics/transformations.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | import numpy as np 5 | 6 | img = cv.imread('../Resources/Photos/park.jpg') 7 | cv.imshow('Park', img) 8 | 9 | # Translation 10 | def translate(img, x, y): 11 | transMat = np.float32([[1,0,x],[0,1,y]]) 12 | dimensions = (img.shape[1], img.shape[0]) 13 | return cv.warpAffine(img, transMat, dimensions) 14 | 15 | # -x --> Left 16 | # -y --> Up 17 | # x --> Right 18 | # y --> Down 19 | 20 | translated = translate(img, -100, 100) 21 | cv.imshow('Translated', translated) 22 | 23 | # Rotation 24 | def rotate(img, angle, rotPoint=None): 25 | (height,width) = img.shape[:2] 26 | 27 | if rotPoint is None: 28 | rotPoint = (width//2,height//2) 29 | 30 | rotMat = cv.getRotationMatrix2D(rotPoint, angle, 1.0) 31 | dimensions = (width,height) 32 | 33 | return cv.warpAffine(img, rotMat, dimensions) 34 | 35 | rotated = rotate(img, -45) 36 | cv.imshow('Rotated', rotated) 37 | 38 | rotated_rotated = rotate(img, -90) 39 | cv.imshow('Rotated Rotated', rotated_rotated) 40 | 41 | # Resizing 42 | resized = cv.resize(img, (500,500), interpolation=cv.INTER_CUBIC) 43 | cv.imshow('Resized', resized) 44 | 45 | # Flipping 46 | flip = cv.flip(img, -1) 47 | cv.imshow('Flip', flip) 48 | 49 | # Cropping 50 | cropped = img[200:400, 300:400] 51 | cv.imshow('Cropped', cropped) 52 | 53 | 54 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #2 - Advanced/bitwise.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | import numpy as np 5 | 6 | blank = np.zeros((400,400), dtype='uint8') 7 | 8 | rectangle = cv.rectangle(blank.copy(), (30,30), (370,370), 255, -1) 9 | circle = cv.circle(blank.copy(), (200,200), 200, 255, -1) 10 | 11 | cv.imshow('Rectangle', rectangle) 12 | cv.imshow('Circle', circle) 13 | 14 | # bitwise AND --> intersecting regions 15 | bitwise_and = cv.bitwise_and(rectangle, circle) 16 | cv.imshow('Bitwise AND', bitwise_and) 17 | 18 | # bitwise OR --> non-intersecting and intersecting regions 19 | bitwise_or = cv.bitwise_or(rectangle, circle) 20 | cv.imshow('Bitwise OR', bitwise_or) 21 | 22 | # bitwise XOR --> non-intersecting regions 23 | bitwise_xor = cv.bitwise_xor(rectangle, circle) 24 | cv.imshow('Bitwise XOR', bitwise_xor) 25 | 26 | # bitwise NOT 27 | bitwise_not = cv.bitwise_not(circle) 28 | cv.imshow('Circle NOT', bitwise_not) 29 | 30 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #2 - Advanced/blurring.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | 5 | img = cv.imread('../Resources/Photos/cats.jpg') 6 | cv.imshow('Cats', img) 7 | 8 | # Averaging 9 | average = cv.blur(img, (3,3)) 10 | cv.imshow('Average Blur', average) 11 | 12 | # Gaussian Blur 13 | gauss = cv.GaussianBlur(img, (3,3), 0) 14 | cv.imshow('Gaussian Blur', gauss) 15 | 16 | # Median Blur 17 | median = cv.medianBlur(img, 3) 18 | cv.imshow('Median Blur', median) 19 | 20 | # Bilateral 21 | bilateral = cv.bilateralFilter(img, 10, 35, 25) 22 | cv.imshow('Bilateral', bilateral) 23 | 24 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #2 - Advanced/colour_spaces.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | import matplotlib.pyplot as plt 5 | 6 | img = cv.imread('../Resources/Photos/park.jpg') 7 | cv.imshow('Park', img) 8 | 9 | # plt.imshow(img) 10 | # plt.show() 11 | 12 | # BGR to Grayscale 13 | gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) 14 | cv.imshow('Gray', gray) 15 | 16 | # BGR to HSV 17 | hsv = cv.cvtColor(img, cv.COLOR_BGR2HSV) 18 | cv.imshow('HSV', hsv) 19 | 20 | # BGR to L*a*b 21 | lab = cv.cvtColor(img, cv.COLOR_BGR2LAB) 22 | cv.imshow('LAB', lab) 23 | 24 | # BGR to RGB 25 | rgb = cv.cvtColor(img, cv.COLOR_BGR2RGB) 26 | cv.imshow('RGB', rgb) 27 | 28 | # HSV to BGR 29 | lab_bgr = cv.cvtColor(lab, cv.COLOR_LAB2BGR) 30 | cv.imshow('LAB --> BGR', lab_bgr) 31 | 32 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #2 - Advanced/gradients.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | import numpy as np 5 | 6 | img = cv.imread('../Resources/Photos/park.jpg') 7 | cv.imshow('Park', img) 8 | 9 | gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) 10 | cv.imshow('Gray', gray) 11 | 12 | # Laplacian 13 | lap = cv.Laplacian(gray, cv.CV_64F) 14 | lap = np.uint8(np.absolute(lap)) 15 | cv.imshow('Laplacian', lap) 16 | 17 | # Sobel 18 | sobelx = cv.Sobel(gray, cv.CV_64F, 1, 0) 19 | sobely = cv.Sobel(gray, cv.CV_64F, 0, 1) 20 | combined_sobel = cv.bitwise_or(sobelx, sobely) 21 | 22 | cv.imshow('Sobel X', sobelx) 23 | cv.imshow('Sobel Y', sobely) 24 | cv.imshow('Combined Sobel', combined_sobel) 25 | 26 | canny = cv.Canny(gray, 150, 175) 27 | cv.imshow('Canny', canny) 28 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #2 - Advanced/histogram.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | import matplotlib.pyplot as plt 5 | import numpy as np 6 | 7 | img = cv.imread('../Resources/Photos/cats.jpg') 8 | cv.imshow('Cats', img) 9 | 10 | blank = np.zeros(img.shape[:2], dtype='uint8') 11 | 12 | # gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) 13 | # cv.imshow('Gray', gray) 14 | 15 | mask = cv.circle(blank, (img.shape[1]//2,img.shape[0]//2), 100, 255, -1) 16 | 17 | masked = cv.bitwise_and(img,img,mask=mask) 18 | cv.imshow('Mask', masked) 19 | 20 | # GRayscale histogram 21 | # gray_hist = cv.calcHist([gray], [0], mask, [256], [0,256] ) 22 | 23 | # plt.figure() 24 | # plt.title('Grayscale Histogram') 25 | # plt.xlabel('Bins') 26 | # plt.ylabel('# of pixels') 27 | # plt.plot(gray_hist) 28 | # plt.xlim([0,256]) 29 | # plt.show() 30 | 31 | # Colour Histogram 32 | 33 | plt.figure() 34 | plt.title('Colour Histogram') 35 | plt.xlabel('Bins') 36 | plt.ylabel('# of pixels') 37 | colors = ('b', 'g', 'r') 38 | for i,col in enumerate(colors): 39 | hist = cv.calcHist([img], [i], mask, [256], [0,256]) 40 | plt.plot(hist, color=col) 41 | plt.xlim([0,256]) 42 | 43 | plt.show() 44 | 45 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #2 - Advanced/masking.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | import numpy as np 5 | 6 | img = cv.imread('../Resources/Photos/cats 2.jpg') 7 | cv.imshow('Cats', img) 8 | 9 | blank = np.zeros(img.shape[:2], dtype='uint8') 10 | cv.imshow('Blank Image', blank) 11 | 12 | circle = cv.circle(blank.copy(), (img.shape[1]//2 + 45,img.shape[0]//2), 100, 255, -1) 13 | 14 | rectangle = cv.rectangle(blank.copy(), (30,30), (370,370), 255, -1) 15 | 16 | weird_shape = cv.bitwise_and(circle,rectangle) 17 | cv.imshow('Weird Shape', weird_shape) 18 | 19 | masked = cv.bitwise_and(img,img,mask=weird_shape) 20 | cv.imshow('Weird Shaped Masked Image', masked) 21 | 22 | cv.waitKey(0) 23 | -------------------------------------------------------------------------------- /Section #2 - Advanced/rescale_resize.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | 5 | # img = cv.imread('../Resources/Photos/cat.jpg') 6 | # cv.imshow('Cat', img) 7 | 8 | def rescaleFrame(frame, scale=0.75): 9 | # Images, Videos and Live Video 10 | width = int(frame.shape[1] * scale) 11 | height = int(frame.shape[0] * scale) 12 | 13 | dimensions = (width,height) 14 | 15 | return cv.resize(frame, dimensions, interpolation=cv.INTER_AREA) 16 | 17 | def changeRes(width,height): 18 | # Live video 19 | capture.set(3,width) 20 | capture.set(4,height) 21 | 22 | # Reading Videos 23 | capture = cv.VideoCapture('../Resources/Videos/dog.mp4') 24 | 25 | while True: 26 | isTrue, frame = capture.read() 27 | 28 | frame_resized = rescaleFrame(frame, scale=.2) 29 | 30 | cv.imshow('Video', frame) 31 | cv.imshow('Video Resized', frame_resized) 32 | 33 | if cv.waitKey(20) & 0xFF==ord('d'): 34 | break 35 | 36 | capture.release() 37 | cv.destroyAllWindows() -------------------------------------------------------------------------------- /Section #2 - Advanced/splitmerge.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | import numpy as np 5 | 6 | img = cv.imread('../Resources/Photos/park.jpg') 7 | cv.imshow('Park', img) 8 | 9 | blank = np.zeros(img.shape[:2], dtype='uint8') 10 | 11 | b,g,r = cv.split(img) 12 | 13 | blue = cv.merge([b,blank,blank]) 14 | green = cv.merge([blank,g,blank]) 15 | red = cv.merge([blank,blank,r]) 16 | 17 | 18 | cv.imshow('Blue', blue) 19 | cv.imshow('Green', green) 20 | cv.imshow('Red', red) 21 | 22 | print(img.shape) 23 | print(b.shape) 24 | print(g.shape) 25 | print(r.shape) 26 | 27 | merged = cv.merge([b,g,r]) 28 | cv.imshow('Merged Image', merged) 29 | 30 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #3 - Faces/face_detect.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import cv2 as cv 4 | 5 | img = cv.imread('../Resources/Photos/group 1.jpg') 6 | cv.imshow('Group of 5 people', img) 7 | 8 | gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) 9 | cv.imshow('Gray People', gray) 10 | 11 | haar_cascade = cv.CascadeClassifier('haar_face.xml') 12 | 13 | faces_rect = haar_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=1) 14 | 15 | print(f'Number of faces found = {len(faces_rect)}') 16 | 17 | for (x,y,w,h) in faces_rect: 18 | cv.rectangle(img, (x,y), (x+w,y+h), (0,255,0), thickness=2) 19 | 20 | cv.imshow('Detected Faces', img) 21 | 22 | 23 | 24 | cv.waitKey(0) -------------------------------------------------------------------------------- /Section #3 - Faces/face_recognition.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import numpy as np 4 | import cv2 as cv 5 | 6 | haar_cascade = cv.CascadeClassifier('haar_face.xml') 7 | 8 | people = ['Ben Afflek', 'Elton John', 'Jerry Seinfield', 'Madonna', 'Mindy Kaling'] 9 | # features = np.load('features.npy', allow_pickle=True) 10 | # labels = np.load('labels.npy') 11 | 12 | face_recognizer = cv.face.LBPHFaceRecognizer_create() 13 | face_recognizer.read('face_trained.yml') 14 | 15 | img = cv.imread(r'../Resources\Faces\val\elton_john/1.jpg') 16 | 17 | gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) 18 | cv.imshow('Person', gray) 19 | 20 | # Detect the face in the image 21 | faces_rect = haar_cascade.detectMultiScale(gray, 1.1, 4) 22 | 23 | for (x,y,w,h) in faces_rect: 24 | faces_roi = gray[y:y+h,x:x+w] 25 | 26 | label, confidence = face_recognizer.predict(faces_roi) 27 | print(f'Label = {people[label]} with a confidence of {confidence}') 28 | 29 | cv.putText(img, str(people[label]), (20,20), cv.FONT_HERSHEY_COMPLEX, 1.0, (0,255,0), thickness=2) 30 | cv.rectangle(img, (x,y), (x+w,y+h), (0,255,0), thickness=2) 31 | 32 | cv.imshow('Detected Face', img) 33 | 34 | cv.waitKey(0) 35 | -------------------------------------------------------------------------------- /Section #3 - Faces/faces_train.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member 2 | 3 | import os 4 | import cv2 as cv 5 | import numpy as np 6 | 7 | people = ['Ben Afflek', 'Elton John', 'Jerry Seinfield', 'Madonna', 'Mindy Kaling'] 8 | DIR = r'..Media Files\Faces\train' 9 | 10 | haar_cascade = cv.CascadeClassifier('haar_face.xml') 11 | 12 | features = [] 13 | labels = [] 14 | 15 | def create_train(): 16 | for person in people: 17 | path = os.path.join(DIR, person) 18 | label = people.index(person) 19 | 20 | for img in os.listdir(path): 21 | img_path = os.path.join(path,img) 22 | 23 | img_array = cv.imread(img_path) 24 | if img_array is None: 25 | continue 26 | 27 | gray = cv.cvtColor(img_array, cv.COLOR_BGR2GRAY) 28 | 29 | faces_rect = haar_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=4) 30 | 31 | for (x,y,w,h) in faces_rect: 32 | faces_roi = gray[y:y+h, x:x+w] 33 | features.append(faces_roi) 34 | labels.append(label) 35 | 36 | create_train() 37 | print('Training done ---------------') 38 | 39 | features = np.array(features, dtype='object') 40 | labels = np.array(labels) 41 | 42 | face_recognizer = cv.face.LBPHFaceRecognizer_create() 43 | 44 | # Train the Recognizer on the features list and the labels list 45 | face_recognizer.train(features,labels) 46 | 47 | face_recognizer.save('face_trained.yml') 48 | np.save('features.npy', features) 49 | np.save('labels.npy', labels) 50 | -------------------------------------------------------------------------------- /Section #3 - Faces/features.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Section #3 - Faces/features.npy -------------------------------------------------------------------------------- /Section #3 - Faces/labels.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasmcaus/opencv-course/c028d3624fd77f34ae9f1a57a13106551a018c4c/Section #3 - Faces/labels.npy -------------------------------------------------------------------------------- /Section #4 - Capstone/simpsons.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", 8 | "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", 9 | "id": "MQoxjirY4S5o", 10 | "trusted": true 11 | }, 12 | "outputs": [], 13 | "source": [ 14 | "# Installing `caer` and `canaro` since they don't come pre-installed\n", 15 | "# !pip install --upgrade caer canaro" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": { 22 | "_cell_guid": "79c7e3d0-c299-4dcb-8224-4455121ee9b0", 23 | "_uuid": "d629ff2d2480ee46fbb7e2d37f6b5fab8052498a", 24 | "id": "_yldS7bG4S58", 25 | "trusted": true 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "import os\n", 30 | "import caer\n", 31 | "import canaro\n", 32 | "import numpy as np\n", 33 | "import cv2 as cv\n", 34 | "import gc\n", 35 | "#pylint:disable=no-member (Removes linting problems with cv)" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": null, 41 | "metadata": { 42 | "id": "TuC64gTq4S6K", 43 | "trusted": true 44 | }, 45 | "outputs": [], 46 | "source": [ 47 | "IMG_SIZE = (80,80)\n", 48 | "channels = 1\n", 49 | "char_path = r'../input/the-simpsons-characters-dataset/simpsons_dataset'" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": null, 55 | "metadata": { 56 | "id": "RD5OHUE84S6U", 57 | "trusted": true 58 | }, 59 | "outputs": [], 60 | "source": [ 61 | "# Creating a character dictionary, sorting it in descending order\n", 62 | "char_dict = {}\n", 63 | "for char in os.listdir(char_path):\n", 64 | " char_dict[char] = len(os.listdir(os.path.join(char_path,char)))\n", 65 | "\n", 66 | "# Sort in descending order\n", 67 | "char_dict = caer.sort_dict(char_dict, descending=True)\n", 68 | "char_dict" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": null, 74 | "metadata": { 75 | "id": "OQ09DqmI4S6g", 76 | "trusted": true 77 | }, 78 | "outputs": [], 79 | "source": [ 80 | "# Getting the first 10 categories with the most number of images\n", 81 | "characters = []\n", 82 | "count = 0\n", 83 | "for i in char_dict:\n", 84 | " characters.append(i[0])\n", 85 | " count += 1\n", 86 | " if count >= 10:\n", 87 | " break\n", 88 | "characters" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": null, 94 | "metadata": { 95 | "id": "X4UnTWk74S6q", 96 | "trusted": true 97 | }, 98 | "outputs": [], 99 | "source": [ 100 | "# Create the training data\n", 101 | "train = caer.preprocess_from_dir(char_path, characters, channels=channels, IMG_SIZE=IMG_SIZE, isShuffle=True)" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "metadata": { 108 | "id": "ZaSuzC2J4S6z", 109 | "trusted": true 110 | }, 111 | "outputs": [], 112 | "source": [ 113 | "# Number of training samples\n", 114 | "len(train)" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": null, 120 | "metadata": { 121 | "id": "hSw-V2H24S7A", 122 | "trusted": true 123 | }, 124 | "outputs": [], 125 | "source": [ 126 | "# Visualizing the data (OpenCV doesn't display well in Jupyter notebooks)\n", 127 | "import matplotlib.pyplot as plt\n", 128 | "plt.figure(figsize=(30,30))\n", 129 | "plt.imshow(train[0][0], cmap='gray')\n", 130 | "plt.show()" 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": null, 136 | "metadata": { 137 | "id": "arO-90034S7J", 138 | "trusted": true 139 | }, 140 | "outputs": [], 141 | "source": [ 142 | "# Separating the array and corresponding labels\n", 143 | "featureSet, labels = caer.sep_train(train, IMG_SIZE=IMG_SIZE)" 144 | ] 145 | }, 146 | { 147 | "cell_type": "code", 148 | "execution_count": null, 149 | "metadata": { 150 | "id": "Sl8VnLCY4S7O", 151 | "trusted": true 152 | }, 153 | "outputs": [], 154 | "source": [ 155 | "from tensorflow.keras.utils import to_categorical\n", 156 | "\n", 157 | "# Normalize the featureSet ==> (0,1)\n", 158 | "featureSet = caer.normalize(featureSet)\n", 159 | "# Converting numerical labels to binary class vectors\n", 160 | "labels = to_categorical(labels, len(characters))" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": null, 166 | "metadata": { 167 | "id": "pzXXrqbt4S7S", 168 | "trusted": true 169 | }, 170 | "outputs": [], 171 | "source": [ 172 | "x_train, x_val, y_train, y_val = caer.train_val_split(featureSet, labels, val_ratio=.2)" 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": null, 178 | "metadata": { 179 | "id": "emsrpYWZ4S7W", 180 | "trusted": true 181 | }, 182 | "outputs": [], 183 | "source": [ 184 | "del train\n", 185 | "del featureSet\n", 186 | "del labels \n", 187 | "gc.collect()" 188 | ] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "execution_count": null, 193 | "metadata": { 194 | "id": "NkS1ceD94S7a", 195 | "trusted": true 196 | }, 197 | "outputs": [], 198 | "source": [ 199 | "# Useful variables when training\n", 200 | "BATCH_SIZE = 32\n", 201 | "EPOCHS = 10" 202 | ] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": null, 207 | "metadata": { 208 | "id": "_atEyygG4S7g", 209 | "trusted": true 210 | }, 211 | "outputs": [], 212 | "source": [ 213 | "# Image data generator (introduces randomness in network ==> better accuracy)\n", 214 | "datagen = canaro.generators.imageDataGenerator()\n", 215 | "train_gen = datagen.flow(x_train, y_train, batch_size=BATCH_SIZE)" 216 | ] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": null, 221 | "metadata": { 222 | "id": "Y8fjXBuH4S7m", 223 | "trusted": true 224 | }, 225 | "outputs": [], 226 | "source": [ 227 | "# Create our model (returns a compiled model)\n", 228 | "from tensorflow.keras.models import Sequential\n", 229 | "from tensorflow.keras.layers import Dense, Flatten, Dropout, Conv2D, MaxPooling2D\n", 230 | "\n", 231 | "output_dim=10\n", 232 | "\n", 233 | "w, h = IMG_SIZE[:2]\n", 234 | "\n", 235 | "model = Sequential()\n", 236 | "model.add(Conv2D(32, (3, 3), activation='relu', padding='same', input_shape=(w, h,channels)))\n", 237 | "model.add(Conv2D(32, (3, 3), activation='relu'))\n", 238 | "model.add(MaxPooling2D(pool_size=(2, 2)))\n", 239 | "model.add(Dropout(0.2))\n", 240 | "\n", 241 | "model.add(Conv2D(64, (3, 3), padding='same', activation='relu'))\n", 242 | "model.add(Conv2D(64, (3, 3), activation='relu'))\n", 243 | "model.add(MaxPooling2D(pool_size=(2, 2)))\n", 244 | "model.add(Dropout(0.2))\n", 245 | "\n", 246 | "model.add(Conv2D(256, (3, 3), padding='same', activation='relu')) \n", 247 | "model.add(Conv2D(256, (3, 3), activation='relu'))\n", 248 | "model.add(MaxPooling2D(pool_size=(2, 2)))\n", 249 | "model.add(Dropout(0.2))\n", 250 | "\n", 251 | "model.add(Flatten())\n", 252 | "model.add(Dropout(0.5))\n", 253 | "model.add(Dense(1024, activation='relu'))\n", 254 | "\n", 255 | "# Output Layer\n", 256 | "model.add(Dense(output_dim, activation='softmax'))\n" 257 | ] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": null, 262 | "metadata": { 263 | "id": "CepcT54J4S7t", 264 | "trusted": true 265 | }, 266 | "outputs": [], 267 | "source": [ 268 | "model.summary()" 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": null, 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [ 277 | "from tensorflow.keras.optimizers.legacy import SGD\n", 278 | "optimizer = SGD(learning_rate=0.001, decay=1e-7, momentum=0.9, nesterov=True)\n", 279 | "model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])" 280 | ] 281 | }, 282 | { 283 | "cell_type": "code", 284 | "execution_count": null, 285 | "metadata": { 286 | "id": "AknG90ch4S7-", 287 | "trusted": true 288 | }, 289 | "outputs": [], 290 | "source": [ 291 | "# Training the model\n", 292 | "\n", 293 | "from tensorflow.keras.callbacks import LearningRateScheduler\n", 294 | "callbacks_list = [LearningRateScheduler(canaro.lr_schedule)]\n", 295 | "training = model.fit(train_gen,\n", 296 | " steps_per_epoch=len(x_train)//BATCH_SIZE,\n", 297 | " epochs=EPOCHS,\n", 298 | " validation_data=(x_val,y_val),\n", 299 | " validation_steps=len(y_val)//BATCH_SIZE,\n", 300 | " callbacks = callbacks_list)" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": null, 306 | "metadata": { 307 | "id": "CUifBqOG4S8G", 308 | "trusted": true 309 | }, 310 | "outputs": [], 311 | "source": [ 312 | "characters" 313 | ] 314 | }, 315 | { 316 | "cell_type": "markdown", 317 | "metadata": { 318 | "id": "qiNY_zSy6Quj" 319 | }, 320 | "source": [ 321 | "## Testing" 322 | ] 323 | }, 324 | { 325 | "cell_type": "code", 326 | "execution_count": null, 327 | "metadata": { 328 | "id": "ETnmB3DC4S8M", 329 | "trusted": true 330 | }, 331 | "outputs": [], 332 | "source": [ 333 | "test_path = r'../input/the-simpsons-characters-dataset/kaggle_simpson_testset/kaggle_simpson_testset/charles_montgomery_burns_0.jpg'\n", 334 | "\n", 335 | "img = cv.imread(test_path)\n", 336 | "\n", 337 | "plt.imshow(img)\n", 338 | "plt.show()" 339 | ] 340 | }, 341 | { 342 | "cell_type": "code", 343 | "execution_count": null, 344 | "metadata": { 345 | "id": "yJjmMuvj4S8T", 346 | "trusted": true 347 | }, 348 | "outputs": [], 349 | "source": [ 350 | "def prepare(image):\n", 351 | " image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)\n", 352 | " image = cv.resize(image, IMG_SIZE)\n", 353 | " image = caer.reshape(image, IMG_SIZE, 1)\n", 354 | " return image" 355 | ] 356 | }, 357 | { 358 | "cell_type": "code", 359 | "execution_count": null, 360 | "metadata": { 361 | "id": "hZTjUKKn4S8a", 362 | "trusted": true 363 | }, 364 | "outputs": [], 365 | "source": [ 366 | "predictions = model.predict(prepare(img))" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": null, 372 | "metadata": { 373 | "id": "3a4AW8qT4S8g", 374 | "trusted": true 375 | }, 376 | "outputs": [], 377 | "source": [ 378 | "# Getting class with the highest probability\n", 379 | "print(characters[np.argmax(predictions[0])])" 380 | ] 381 | } 382 | ], 383 | "metadata": { 384 | "colab": { 385 | "name": "simpsons.ipynb", 386 | "provenance": [] 387 | }, 388 | "kernelspec": { 389 | "display_name": "Python 3", 390 | "language": "python", 391 | "name": "python3" 392 | }, 393 | "language_info": { 394 | "codemirror_mode": { 395 | "name": "ipython", 396 | "version": 3 397 | }, 398 | "file_extension": ".py", 399 | "mimetype": "text/x-python", 400 | "name": "python", 401 | "nbconvert_exporter": "python", 402 | "pygments_lexer": "ipython3", 403 | "version": "3.9.17" 404 | } 405 | }, 406 | "nbformat": 4, 407 | "nbformat_minor": 2 408 | } 409 | -------------------------------------------------------------------------------- /Section #4 - Capstone/simpsons.py: -------------------------------------------------------------------------------- 1 | #pylint:disable=no-member (Removes linting problems with cv) 2 | 3 | # Installing `caer` and `canaro` since they don't come pre-installed 4 | # Uncomment the following line: 5 | # !pip install --upgrade caer canaro 6 | 7 | import os 8 | import caer 9 | import canaro 10 | import numpy as np 11 | import cv2 as cv 12 | import gc 13 | import matplotlib.pyplot as plt 14 | from tensorflow.keras.utils import to_categorical 15 | from tensorflow.keras.callbacks import LearningRateScheduler 16 | from tensorflow.keras.models import Sequential 17 | from tensorflow.keras.layers import Dense, Flatten, Dropout, Conv2D, MaxPooling2D 18 | from tensorflow.keras.optimizers.legacy import SGD 19 | 20 | IMG_SIZE = (80,80) 21 | channels = 1 22 | char_path = r'../input/the-simpsons-characters-dataset/simpsons_dataset' 23 | 24 | # Creating a character dictionary, sorting it in descending order 25 | char_dict = {} 26 | for char in os.listdir(char_path): 27 | char_dict[char] = len(os.listdir(os.path.join(char_path,char))) 28 | 29 | # Sort in descending order 30 | char_dict = caer.sort_dict(char_dict, descending=True) 31 | char_dict 32 | 33 | # Getting the first 10 categories with the most number of images 34 | characters = [] 35 | count = 0 36 | for i in char_dict: 37 | characters.append(i[0]) 38 | count += 1 39 | if count >= 10: 40 | break 41 | characters 42 | 43 | # Create the training data 44 | train = caer.preprocess_from_dir(char_path, characters, channels=channels, IMG_SIZE=IMG_SIZE, isShuffle=True) 45 | 46 | # Number of training samples 47 | len(train) 48 | 49 | # Visualizing the data (OpenCV doesn't display well in Jupyter notebooks) 50 | plt.figure(figsize=(30,30)) 51 | plt.imshow(train[0][0], cmap='gray') 52 | plt.show() 53 | 54 | # Separating the array and corresponding labels 55 | featureSet, labels = caer.sep_train(train, IMG_SIZE=IMG_SIZE) 56 | 57 | 58 | # Normalize the featureSet ==> (0,1) 59 | featureSet = caer.normalize(featureSet) 60 | # Converting numerical labels to binary class vectors 61 | labels = to_categorical(labels, len(characters)) 62 | 63 | 64 | # Creating train and validation data 65 | x_train, x_val, y_train, y_val = caer.train_val_split(featureSet, labels, val_ratio=.2) 66 | 67 | # Deleting variables to save memory 68 | del train 69 | del featureSet 70 | del labels 71 | gc.collect() 72 | 73 | # Useful variables when training 74 | BATCH_SIZE = 32 75 | EPOCHS = 10 76 | 77 | # Image data generator (introduces randomness in network ==> better accuracy) 78 | datagen = canaro.generators.imageDataGenerator() 79 | train_gen = datagen.flow(x_train, y_train, batch_size=BATCH_SIZE) 80 | 81 | # Create our model (returns the compiled model) 82 | output_dim=10 83 | 84 | w, h = IMG_SIZE[:2] 85 | 86 | model = Sequential() 87 | model.add(Conv2D(32, (3, 3), activation='relu', padding='same', input_shape=(w, h,channels))) 88 | model.add(Conv2D(32, (3, 3), activation='relu')) 89 | model.add(MaxPooling2D(pool_size=(2, 2))) 90 | model.add(Dropout(0.2)) 91 | 92 | model.add(Conv2D(64, (3, 3), padding='same', activation='relu')) 93 | model.add(Conv2D(64, (3, 3), activation='relu')) 94 | model.add(MaxPooling2D(pool_size=(2, 2))) 95 | model.add(Dropout(0.2)) 96 | 97 | model.add(Conv2D(256, (3, 3), padding='same', activation='relu')) 98 | model.add(Conv2D(256, (3, 3), activation='relu')) 99 | model.add(MaxPooling2D(pool_size=(2, 2))) 100 | model.add(Dropout(0.2)) 101 | 102 | model.add(Flatten()) 103 | model.add(Dropout(0.5)) 104 | model.add(Dense(1024, activation='relu')) 105 | 106 | # Output Layer 107 | model.add(Dense(output_dim, activation='softmax')) 108 | 109 | model.summary() 110 | 111 | # Training the model 112 | optimizer = SGD(learning_rate=0.001, decay=1e-7, momentum=0.9, nesterov=True) 113 | model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy']) 114 | callbacks_list = [LearningRateScheduler(canaro.lr_schedule)] 115 | training = model.fit(train_gen, 116 | steps_per_epoch=len(x_train)//BATCH_SIZE, 117 | epochs=EPOCHS, 118 | validation_data=(x_val,y_val), 119 | validation_steps=len(y_val)//BATCH_SIZE, 120 | callbacks = callbacks_list) 121 | 122 | print(characters) 123 | 124 | 125 | """## Testing""" 126 | 127 | test_path = r'../input/the-simpsons-characters-dataset/kaggle_simpson_testset/kaggle_simpson_testset/charles_montgomery_burns_0.jpg' 128 | 129 | img = cv.imread(test_path) 130 | 131 | plt.imshow(img) 132 | plt.show() 133 | 134 | def prepare(image): 135 | image = cv.cvtColor(image, cv.COLOR_BGR2GRAY) 136 | image = cv.resize(image, IMG_SIZE) 137 | image = caer.reshape(image, IMG_SIZE, 1) 138 | return image 139 | 140 | predictions = model.predict(prepare(img)) 141 | 142 | # Getting class with the highest probability 143 | print(characters[np.argmax(predictions[0])]) 144 | --------------------------------------------------------------------------------