Skip to content

Instantly share code, notes, and snippets.

View smeschke's full-sized avatar

Stephen Meschke smeschke

View GitHub Profile
@smeschke
smeschke / swap_body_parts.py
Created September 21, 2018 19:49
Ensure that body parts are always in the right places
import pandas as pd
import numpy as np
import cv2, os
import csv
input_source = "/home/stephen/Desktop/me.MP4"
cap = cv2.VideoCapture(input_source)
frame_number = 0
font, scale, colorText, thick = cv2.FONT_HERSHEY_SIMPLEX, .5, (234,234,234), 1
size, color, thickness = 5, (255,255,255), 5
@smeschke
smeschke / save_pose_data.py
Last active April 7, 2023 07:08
Saving pose data from video using OpenPose
import cv2, numpy as np, csv
#https://github.com/opencv/opencv/blob/master/samples/dnn/openpose.py
outfile_path = '/home/stephen/Desktop/workout.csv'
protoFile = "/home/stephen/pose/mpi/pose_deploy_linevec_faster_4_stages.prototxt"
weightsFile = "/home/stephen/pose/mpi/pose_iter_160000.caffemodel"
net = cv2.dnn.readNetFromCaffe(protoFile, weightsFile)
data, input_width, input_height, threshold, frame_number = [], 368, 386, 0.1, 0
@smeschke
smeschke / JugglingEdgeRecords
Created July 11, 2018 04:38
Looking at the Juggling Edge Records Database
import pandas as pd
df = pd.read_csv('/home/stephen/Desktop/records.csv')
#get list of jugglers
jugglers = []
for record in df.values:
jugglers.append(record[1])
jugglers = list(set(jugglers))
#get list of comparitive pr's
@smeschke
smeschke / gist:85c3090368bf65afdaa3f71eaaef9efe
Created June 10, 2018 16:15
Tracking object writer with smothing
import cv2
import numpy as np
import numpy as np
from matplotlib import pyplot as plt
import pandas as pd
from scipy import signal
import cv2
from matplotlib import pyplot as plt
import pandas as pd
from mpl_toolkits.mplot3d import Axes3D
import cv2, math, 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
color_values = 168,154,99,177,255,255 #RED
threshold_value = 0
output_path = '/home/stephen/Desktop/1.csv'
cap = cv2.VideoCapture('/home/stephen/Desktop/531.avi')
@smeschke
smeschke / persist.py
Created April 13, 2018 22:40
Persist Colors
#import cv2 for computer vision
#import numpy to make blank images
import cv2, numpy as np
#capture source video
cap = cv2.VideoCapture('/home/acer/Desktop/colorspace/bxx.MP4')
#define
#define orange
orange = 0,145,155,255,255,255
@smeschke
smeschke / optical_flow_tracking.py
Created April 5, 2018 19:52
Tracking with Optical Flow
import cv2, numpy as np
#path to source video
source_path = '/home/acer/Desktop/744.MP4'
#out path to save tracking data
output_path = '/home/acer/Desktop/light_blue.csv'
#parameter of lk optical flow
window_size = 18
lk_params = dict(winSize = (window_size,window_size),
@smeschke
smeschke / gist:df2c5794287fa7044817dc3e00d61351
Last active June 24, 2024 06:51
Using Keras from the Webcam
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
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
@smeschke
smeschke / keras for juggling
Last active April 3, 2020 09:34
predict juggling patterns using keras
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)