Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

From Canny you get an output map with all edges, pass this edge-matrix to findContours() and you will get a vector of all contourpoints for each contour, i.e. for each contour you'll get the number of edge-points simply by the length of the containing points, here an example:

cv::Mat edges;
cv::Canny(img, edges, 50, 200);
std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Vec4i> hierarchy;
cv::findContours(edges, contours, hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
// if you want the number of edge pixels of the first contour:
size_t num_edge_pts_contour0 = contours[0].size();