int main(int argc, char* argv[])
{
Mat img = imread("test.png");
cv::Mat gray, blur, x, y, absX, absY, edged, thres;
cvtColor(img, gray, COLOR_BGR2GRAY);
GaussianBlur(gray, blur, cv::Size(9, 9), 0);
//imshow("blur", blur);
//求x方向梯度
Sobel(blur, x, CV_16S, 1, 0, 5);
//求y方向梯度
Sobel(blur, y, CV_16S, 0, 1, 5);
//convertScaleAbs:performs three operations sequentially : scaling, taking an absolute\
//value, conversion to an unsigned 8 - bit type
convertScaleAbs(x, absX);
convertScaleAbs(y, absY);
addWeighted(absX, 1, absY, 1, 0, edged);
threshold(edged, thres, 100, 255, THRESH_BINARY);
imshow("thres", thres);
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(thres, contours, hierarchy, RETR_EXTERNAL, CHAI