# WEEK 9 (18-22/1) ## Streamlit (Mon, 18/1/2021) ## Intro to OpenCV (Tue, 19/1/2021) ***==WHAT IS COMPUTER VISION?==*** **==Computer Vision==** is an interdisciplinary scientific field that deals with how computers can gain high-level understanding from digital images or videos. * scene reconstruction * video tracking * object recognition * 3D pose estimation * 3D scene modeling * image restoration ### ==IMAGE SEGMENTATION USING COLORSPACE== #### **Contours** Step 1: convert to binary image with black background Step 2: draw contour #### **HSV** ![](https://i.imgur.com/fdN5GmG.png) HSV: cylindrical geometries with hue starting at the red primary at 0°, passing through the green primary at 120° and the blue primary at 240°, and then wrapping back to red at 360°. ### **==findContour==** [**Contour Retrieval Mode (Hierarchy)**: ](https://docs.opencv.org/master/d9/d8b/tutorial_py_contours_hierarchy.html) ![alt text](https://docs.opencv.org/3.4/hierarchy.png) 1. `RETR_LIST`: Retrieves all the contours, but doesn't create any parent-child relationship. 2. `RETR_EXTERNAL`: Returns only extreme outer flags. All child contours are left behind. 3. `RETR_CCOMP`: Retrieves all the contours and arranges them to a 2-level hierarchy. 4. `RETR_TREE`: The final guy, Mr.Perfect. It retrieves all the contours and creates a full family hierarchy list. ---> return 2 things: first thing is a collection of all contours correspoding to the number of items, second is the hierarchy [**Countour Approximation Method**:](https://docs.opencv.org/trunk/d4/d73/tutorial_py_contours_begin.html) cv.CHAIN_APPROX_NONE: all the boundary points are stored cv.CHAIN_APPROX_SIMPLE: just two end points of that line #### Bounding rect: return width height and top left corner --- ## Intermediate OpenCV (Wed, 20/1/2021) ### Thresholding: Step 1: Mask using threshold technique * grayscale * blur * ---> threshold Step 2: contour cv2.threshold: return 2 element 1. The threshold it self 2. the image #### BLUR bigger kernel size ---> more blurry