Mar-27-2019, 11:25 AM
Hello,
I am new with python and i have been trying to find the cordinates of the tracked yellow color from the webcam. But I am not able to find the cordinates and plot them in csv file could anyone help me with the code.
i have wrote only the following code , could anyone modify the code for me
I am new with python and i have been trying to find the cordinates of the tracked yellow color from the webcam. But I am not able to find the cordinates and plot them in csv file could anyone help me with the code.
i have wrote only the following code , could anyone modify the code for me
#importing the necessary libraries for the project import sys import cv2 import os import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation from matplotlib import style import imutils #code to get the video from the harddrive of my pc to program cap = cv2.VideoCapture('Synchro2.mov') while(cap.isOpened()): ret, frame = cap.read() #resizing the video resized = cv2.resize(frame, None, fx=0.5, fy=0.5, interpolation = cv2.INTER_LINEAR) #croping the frontal view y=0 x=0 h=500 w=450 crop = resized[y:y+h, x:x+w] crop = cv2.medianBlur(crop,5) #turning the crop video file into the HSV hsv = cv2.cvtColor(crop, cv2.COLOR_BGR2HSV) #for yellow color yellow_lower = np.array([20,100,100],np.uint8) yellow_upper = np.array([30,255,255],np.uint8) #thresholding the HSV to only get yellow color mask = cv2.inRange(hsv, yellow_lower, yellow_upper) # Morphological Transform, Dilation #red = cv2.dilate(red, kernal) #res_red = cv2.bitwise_and(crop, crop, mask = red) # Bitwise-AND mask and original image res = cv2.bitwise_and(crop,crop, mask= mask) cv2.imshow("Original",crop) cv2.imshow("Mask",mask) cv2.imshow("Color Tracking", res) if cv2.waitKey(10) & 0xFF == ord('q'): cap.release() cv2.destroyAllWindows() break