diff --git "a/data/1.OpenCV\345\210\235\351\230\266/2.\344\272\214\345\200\274\345\233\276\345\203\217\345\244\204\347\220\206/5.\350\275\256\345\273\223/Contours.py" "b/data/1.OpenCV\345\210\235\351\230\266/2.\344\272\214\345\200\274\345\233\276\345\203\217\345\244\204\347\220\206/5.\350\275\256\345\273\223/Contours.py" new file mode 100644 index 0000000000000000000000000000000000000000..8e0b5b1bf41b9092df4ee74bbc840f897fda726b --- /dev/null +++ "b/data/1.OpenCV\345\210\235\351\230\266/2.\344\272\214\345\200\274\345\233\276\345\203\217\345\244\204\347\220\206/5.\350\275\256\345\273\223/Contours.py" @@ -0,0 +1,12 @@ +import cv2 as cv + +if __name__ == '__main__': + img = cv.imread("Contours.jpg", flags=1) + imgGray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) + + ret, thresh = cv.threshold(imgGray, 127, 255, cv.THRESH_BINARY_INV) + image, contours, hierarchy = cv.findContours(thresh, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE) + contourPic = cv.drawContours(img, contours, -1, (0, 0, 255), 2) + + cv.imshow("ContourPicture", contourPic) + cv.waitKey(0) \ No newline at end of file