#include "stdafx.h"
#include "highgui.hpp"#include "cv.hpp"
#include "iostream"
using namespace std;
using namespace cv;
int main()
{
//读入图像
Mat src = imread("H:\\circle.png", 0);
if (src.empty())
{
cout << "Load image error!" << endl;
return(-1);
}
imshow("source image", src);
//canny
Mat edges;
Canny(src, edges, 100, 255);
//检测轮廓
vector<vector<Point>>contours;
vector<Vec4i>hierarchy;
findContours(edges, contours, RETR_TREE, CHAIN_APPROX_SIMPLE, Point());
cout << "The contours number is " <<contours.size() << endl;