Contour Features | OpenCV contour
![Contour Features](https://i.imgur.com/axBPWDg.jpg)
PrevTutorial:Contours:GettingStarted[1]NextTutorial:ContourProperties[2]GoalInthisarticle,wewilllearnTofindthedifferentfeaturesofcontours,likearea,perimeter,centroid,boundingboxetcYouwillseeplentyoffunctionsrelatedtocontours.1.MomentsImagemomentshelpyoutocalculatesomefeatureslikecenterofmassoftheobject,areaoftheobjectetc.CheckoutthewikipediapageonImageMoments[3]Thefunctioncv.moments()[4]givesadictionaryofallmomentvaluescalculated.Seebelow:importnumpyasnpimportcv2ascvimg=cv.imread[5](star.jpg...
![Contour Features](http://pix5.agoda.net/hotelimages/232/2324617/2324617_17062222080053999838.jpg?s=800x)
Prev Tutorial: Contours : Getting Started[1]
Next Tutorial: Contour Properties[2]
GoalIn this article, we will learn
To find the different features of contours, like area, perimeter, centroid, bounding box etc You will see plenty of functions related to contours. 1. MomentsImage moments help you to calculate some features like center of mass of the object, area of the object etc. Check out the wikipedia page on Image Moments[3]
The function cv.moments()[4] gives a dictionary of all moment values calculated. See below:
import numpy as np
import cv2 as cv
img = cv.imread[5](star.jpg, cv.IMREAD_GRAYSCALE)assert img is not None, "file could not be read, check with os.path.exists()"
cnt = contours[0]
From this moments, you can extract useful data like area, centroid etc. Centroid is given by the relations, (C_x = frac{M_{10}}{M_{00}}) and (C_y = frac{M_{01}}{M_{00}}). This can be done as follows:
cx = int(M[m10]...
取得本站獨家住宿推薦 15%OFF 訂房優惠
本站住宿推薦 20%OFF 訂房優惠,親子優惠,住宿折扣,限時回饋,平日促銷
Contour Detection using OpenCV (PythonC++) | OpenCV contour
Contour Features | OpenCV contour
Contours | OpenCV contour
Contours in OpenCV | OpenCV contour
Finding contours in your image | OpenCV contour
OpenCV – Contour輪廓 | OpenCV contour
[Python+OpenCV] 輪廓Contour | 程式好好玩 | OpenCV contour
![](https://i.imgur.com/axBPWDg.jpg)