This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
fourcc = cv2.VideoWriter_fourcc(*'XVID') | |
out = cv2.VideoWriter('/home/sm/Desktop/nodcontrol.avi',fourcc, 20.0, (640,480)) | |
#dinstance function | |
def distance(x,y): | |
import math | |
return math.sqrt((x[0]-y[0])**2+(x[1]-y[1])**2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import cv2 for vision | |
#numpy to generate backgrounds | |
import cv2 | |
import numpy as np | |
#capture video from the webcam | |
cap = cv2.VideoCapture(0) | |
#read one frame | |
_, img = cap.read() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
#path to source video | |
source_path = '/home/stephen/Desktop/105.avi' | |
#out path to save tracking data | |
output_path = '/home/stephen/Desktop/ball2.csv' | |
#parameter of lk optical flow | |
www = 15 #www is the diameter of the object in pixles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
cols, rows = 1100 , 750 | |
fps = 30.0 | |
video_out_name = '/home/stephen/Desktop/finished.avi' | |
# Define the codec and create VideoWriter object | |
fourcc = cv2.VideoWriter_fourcc(*'XVID') | |
out = cv2.VideoWriter(video_out_name,fourcc, fps, (cols,rows)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
#h,s,v range of the object to be tracked | |
#h,s,v,h1,s1,v1 = 27,0,0,82,190,255 #GREEN | |
#h,s,v,h1,s1,v1 = 168,154,99,177,255,255 #RED | |
h,s,v,h1,s1,v1 = 156,74,76,166,255,255 #pink | |
threshold_value = 0 | |
output_path = '/home/stephen/Desktop/423_pink.csv' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
cap = cv2.VideoCapture(0) | |
def nothing(arg): pass | |
#takes an image, and a lower and upper bound | |
#returns only the parts of the image in bounds | |
def only_color(frame, (b,r,g,b1,r1,g1), morph): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
cap = cv2.VideoCapture('/home/stephen/Desktop/fedex.avi') | |
h,s,v,h1,s1,v1 = 104,0,134,133,255,255#values for the blue | |
morph = 1 | |
last_box_depart = -10000 #frame number that the last box departed | |
tracking_box = False | |
box_ready = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np, os, cv2 | |
from keras.utils import to_categorical | |
from keras.models import load_model | |
#reads images from folder (images must be labeled 0.png, 1.png, etc...) | |
def read_from_folder(folder, pattern, image_number, stop): | |
images = [] | |
while image_number < stop: | |
path = folder + pattern + '/' + str(image_number) + '.png' | |
img = cv2.imread(path, 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2, numpy as np, os | |
#parameters | |
working_dir = '/home/stephen/Desktop/keras_demo/' | |
cap = cv2.VideoCapture(1) | |
org, font, scale, color, thickness, linetype = (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1.2, (234,12,123), 2, cv2.LINE_AA | |
#chromakey values | |
h,s,v,h1,s1,v1 = 16,0,64,123,111,187 | |
#amount of data to use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2, numpy as np, os | |
#parameters | |
working_dir = '/home/stephen/Desktop/keras_demo/' | |
cap = cv2.VideoCapture(0) | |
org, font, scale, color, thickness, linetype = (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1.2, (234,12,123), 2, cv2.LINE_AA | |
#chromakey values | |
h,s,v,h1,s1,v1 = 16,0,64,123,111,187 #green | |
h,s,v,h1,s1,v1 = 0,74,53,68,181,157 #skin tone |