diff --git a/Cards2Coordinates/openCVGeneralTool/getCoordinatesOfColors.py b/Cards2Coordinates/openCVGeneralTool/getCoordinatesOfColors.py new file mode 100644 index 0000000..34ee7bb --- /dev/null +++ b/Cards2Coordinates/openCVGeneralTool/getCoordinatesOfColors.py @@ -0,0 +1,30 @@ +# Python code to find the co-ordinates of +# the contours detected in an image. +import numpy as np +import cv2 + +# Reading image +font = cv2.FONT_HERSHEY_COMPLEX +img = cv2.imread('card.jpg', cv2.IMREAD_COLOR) + +# Converts images from BGR to HSV +hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) +lower_blue = np.array([110,50,50]) +upper_blue = np.array([130,255,255]) + + +# Here we are defining range of bluecolor in HSV +# This creates a mask of blue coloured +# objects found in the frame. +mask = cv2.inRange(hsv, lower_blue, upper_blue) + +res = cv2.bitwise_and(img,img, mask= mask) +cv2.imshow('img', img) +cv2.imshow('mask', mask) +cv2.imshow('res', res) + + +# Exiting the window if 'q' is pressed on the keyboard. +if cv2.waitKey(0) & 0xFF == ord('q'): + cv2.destroyAllWindows() + diff --git a/Cards2Coordinates/openCVGeneralTool/getCoordinatesOfColorsOfStream.py b/Cards2Coordinates/openCVGeneralTool/getCoordinatesOfColorsOfStream.py new file mode 100644 index 0000000..a124f55 --- /dev/null +++ b/Cards2Coordinates/openCVGeneralTool/getCoordinatesOfColorsOfStream.py @@ -0,0 +1,41 @@ +# Python program for Detection of a +# specific color(blue here) using OpenCV with Python +import cv2 +import numpy as np + +# Webcamera no 0 is used to capture the frames +cap = cv2.VideoCapture(0) + +# This drives the program into an infinite loop. +while(1): + # Captures the live stream frame-by-frame + _, frame = cap.read() + # Converts images from BGR to HSV + hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) + lower_blue = np.array([110,50,50]) + upper_blue = np.array([130,255,255]) + + # Here we are defining range of bluecolor in HSV + # This creates a mask of blue coloured + # objects found in the frame. + mask = cv2.inRange(hsv, lower_blue, upper_blue) + + # The bitwise and of the frame and mask is done so + # that only the blue coloured objects are highlighted + # and stored in res + res = cv2.bitwise_and(frame,frame, mask= mask) + cv2.imshow('frame',frame) + cv2.imshow('mask',mask) + cv2.imshow('res',res) + + # This displays the frame, mask + # and res which we created in 3 separate windows. + k = cv2.waitKey(5) & 0xFF + if k == 27: + break + +# Destroys all of the HighGUI windows. +cv2.destroyAllWindows() + +# release the captured frame +cap.release() diff --git a/Cards2Coordinates/openCVGeneralTool/getCoordinates.py b/Cards2Coordinates/openCVGeneralTool/getCoordinatesOfShapes.py similarity index 100% rename from Cards2Coordinates/openCVGeneralTool/getCoordinates.py rename to Cards2Coordinates/openCVGeneralTool/getCoordinatesOfShapes.py diff --git a/Cards2Coordinates/openCVGeneralTool/res_screenshot_19.10.2022.png b/Cards2Coordinates/openCVGeneralTool/res_screenshot_19.10.2022.png new file mode 100644 index 0000000..ad1602b Binary files /dev/null and b/Cards2Coordinates/openCVGeneralTool/res_screenshot_19.10.2022.png differ