Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding Coordinates
#1
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

#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
    
    
    
  
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Finding overlap of boxed coordinates 83dons 4 1,973 Aug-31-2021, 10:14 PM
Last Post: 83dons

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020