From the course: OpenCV for Python Developers

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Area, perimeter, center, and curvature

Area, perimeter, center, and curvature

From the course: OpenCV for Python Developers

Area, perimeter, center, and curvature

- Now that we have segmented out and individually bounded contours of objects in the previous video, let's keep going and extract more information from each of these individual objects. Specifically, we're going to be looking at the area, perimeter and centroids of these objects. To begin, I'm going to start off by deleting our last imshow in our draw contours command, and then I'm going to create an empty array called objects which equals np.zeros, and then in parentheses, we're going to specify the original shape of our image and we can do this by typing open square brackets, img.shape and then index 0 for the width. Then img.shape, passing in 1 for the height and then we'll use a channel count of 3, so that can be in color, and then we're going to specify the format of this image, which is going to be uint8. This is going to be a blank canvas for us to draw onto. The next step is to go ahead and create a loop over…

Contents