From bd2a52fb8e1247d243197dded52478a7e0785d9c Mon Sep 17 00:00:00 2001 From: aayushray Date: Mon, 25 Oct 2021 00:07:38 +0530 Subject: [PATCH 1/3] task1 --- Task1.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Task1.py diff --git a/Task1.py b/Task1.py new file mode 100644 index 0000000..c27141a --- /dev/null +++ b/Task1.py @@ -0,0 +1,67 @@ +import cv2 + +(width,height) = (130,100) + +cap = cv2.VideoCapture(0) + +while (cap.isOpened()): + ret, img = cap.read() + img = cv2.flip(img, 1) # will return the mirror view + cv2.rectangle(img, (20, 20), (250,250), (255, 0, 0), 2) #BGR + cv2.imshow("BGR Output", img) + + img1 = img[20:250, 20:250] # Extraction + imCopy = img1.copy() #Copy of the extraction + gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) + blur = cv2.GaussianBlur(gray, (5,5), 0) + cv2.imshow("Blur",blur) + + ret, thresh1 = cv2.threshold(blur, 10, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) #0 to 255 + hand_resize = cv2.resize(thresh1, (width,height)) + cv2.imshow("Threshold", thresh1) + + + + contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) #contour tells us the minimum nuber of edges required to express a shape + cv2.drawContours(imCopy, contours, -1, (0, 255, 0)) + cv2.imshow('RETR TREE', imCopy) + + k = 0xFF & cv2.waitKey(10) + if k == 27: + break + +cap.release() +cv2.destroyAllWindows() + +# import cv2 + +# (width, height) = (130, 100) + +# # url = '/video' +# # cap=cv2.VideoCapture(url) + + +# cap=cv2.VideoCapture(0) + +# while (cap.isOpened()): +# ret, img = cap.read() +# img=cv2.flip(img, 1) +# cv2.rectangle(img, (20, 20), (250, 250), (255, 0, 0), 3) +# cv2.imshow("RGB Output", img) +# img1 = img[20:250,20:250] +# imCopy = img1.copy() +# gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) +# blur = cv2.GaussianBlur(gray, (5, 5), 0) +# ret, thresh1 = cv2.threshold(blur, 10, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) +# hand_resize = cv2.resize(thresh1, (width, height)) +# cv2.imshow("Threshold", thresh1) +# contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) +# cv2.drawContours(imCopy, contours, -1, (0, 255, 0)) +# cv2.imshow('Draw Contours', imCopy) + +# k = 0xFF & cv2.waitKey(10) +# if k == 27: +# break + +# cap.release() +# cv2.destroyAllWindows() From cf8f3590bfe77e7879186136a29cca7768cc16f7 Mon Sep 17 00:00:00 2001 From: Ayush Ray Date: Mon, 25 Oct 2021 00:12:55 +0530 Subject: [PATCH 2/3] Update Task1.py --- Task1.py | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/Task1.py b/Task1.py index c27141a..84fa33b 100644 --- a/Task1.py +++ b/Task1.py @@ -32,36 +32,3 @@ cap.release() cv2.destroyAllWindows() - -# import cv2 - -# (width, height) = (130, 100) - -# # url = '/video' -# # cap=cv2.VideoCapture(url) - - -# cap=cv2.VideoCapture(0) - -# while (cap.isOpened()): -# ret, img = cap.read() -# img=cv2.flip(img, 1) -# cv2.rectangle(img, (20, 20), (250, 250), (255, 0, 0), 3) -# cv2.imshow("RGB Output", img) -# img1 = img[20:250,20:250] -# imCopy = img1.copy() -# gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) -# blur = cv2.GaussianBlur(gray, (5, 5), 0) -# ret, thresh1 = cv2.threshold(blur, 10, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) -# hand_resize = cv2.resize(thresh1, (width, height)) -# cv2.imshow("Threshold", thresh1) -# contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) -# cv2.drawContours(imCopy, contours, -1, (0, 255, 0)) -# cv2.imshow('Draw Contours', imCopy) - -# k = 0xFF & cv2.waitKey(10) -# if k == 27: -# break - -# cap.release() -# cv2.destroyAllWindows() From 437d795a1473d8a32d0510dc446a561872204f73 Mon Sep 17 00:00:00 2001 From: Ayush Ray Date: Mon, 25 Oct 2021 00:13:57 +0530 Subject: [PATCH 3/3] Delete Task1.py --- Task1.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 Task1.py diff --git a/Task1.py b/Task1.py deleted file mode 100644 index 84fa33b..0000000 --- a/Task1.py +++ /dev/null @@ -1,34 +0,0 @@ -import cv2 - -(width,height) = (130,100) - -cap = cv2.VideoCapture(0) - -while (cap.isOpened()): - ret, img = cap.read() - img = cv2.flip(img, 1) # will return the mirror view - cv2.rectangle(img, (20, 20), (250,250), (255, 0, 0), 2) #BGR - cv2.imshow("BGR Output", img) - - img1 = img[20:250, 20:250] # Extraction - imCopy = img1.copy() #Copy of the extraction - gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) - blur = cv2.GaussianBlur(gray, (5,5), 0) - cv2.imshow("Blur",blur) - - ret, thresh1 = cv2.threshold(blur, 10, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) #0 to 255 - hand_resize = cv2.resize(thresh1, (width,height)) - cv2.imshow("Threshold", thresh1) - - - - contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) #contour tells us the minimum nuber of edges required to express a shape - cv2.drawContours(imCopy, contours, -1, (0, 255, 0)) - cv2.imshow('RETR TREE', imCopy) - - k = 0xFF & cv2.waitKey(10) - if k == 27: - break - -cap.release() -cv2.destroyAllWindows()