From 9f76032d0cd7f26673642cf3e1e830c42c30ee7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Python=E5=B0=8F=E7=99=BD=E8=BF=9B=E9=98=B6?= <860365566@qq.com> Date: Thu, 9 Dec 2021 15:29:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../5.\350\275\256\345\273\223/Contours.py" | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 "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" 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 0000000..8e0b5b1 --- /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 -- GitLab