From the course: OpenCV for Python Developers
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Contour object detection
From the course: OpenCV for Python Developers
Contour object detection
- [Instructor] Now that we have an understanding of how contours work, let's see how to use them with Python 3 and OpenCV 4. Contours only work with binary images. So let's first convert our loaded image here into gray scale and then perform a quick threshold. We can do this by typing our variable gray equals CV2 dot cvt capital C for color, and then we'll pass in our img, and then we'll specify the kind of conversion we're doing, which is CV2 dot in all caps COLOR underscore RGB the number 2, and then G-R-A-Y for gray, close parentheses. Next, let's perform our threshold. For this, we will type thresh as our output variable and then equals CV2 dot adaptive threshold. And then we're going to pass in our gray image here followed by 255, specifying that's the maximum value for this kind of image and then the kind of thresholding we're going to perform, which is CV2 dot in all caps ADAPTIVE underscore thresh underscore Gaussian,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Segmentation and binary images1m 38s
-
(Locked)
Simple thresholding6m 34s
-
(Locked)
Adaptive thresholding4m 38s
-
(Locked)
Skin detection6m 31s
-
(Locked)
Introduction to contours1m 38s
-
(Locked)
Contour object detection6m 56s
-
(Locked)
Area, perimeter, center, and curvature8m 19s
-
(Locked)
Canny edge detection8m 1s
-
(Locked)
Object detection overview1m 59s
-
(Locked)
Challenge: Assign object ID and attributes50s
-
(Locked)
Solution: Assign object ID and attributes10m 5s
-
-
-