Skip to content

Instantly share code, notes, and snippets.

View smeschke's full-sized avatar

Stephen Meschke smeschke

View GitHub Profile
@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 / 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
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 / 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
@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 / 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 / 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 / smooth_pose_data.py
Last active March 17, 2025 14:56
Smooth Pose Estimation Data
import pandas as pd
import numpy as np
import cv2, os
import scipy
from scipy import signal
import csv
circle_color, line_color = (255,255,0), (0,0,255)
window_length, polyorder = 13, 2
sd = "workout"
@smeschke
smeschke / manual_crop.py
Created October 30, 2018 18:18
Crop rectangle out of image using mouse clicks
import cv2, numpy as np
# Click on one corner of the image,
# then, click on the other corner on the image.
# The image will be cropped and saved into the folder (see below)
# Press 'esc' to quit
# Before you begin, change the path to you own video:
cap = cv2.VideoCapture('/home/stephen/Desktop/track.MP4')
@smeschke
smeschke / sine_fitter.py
Created November 1, 2018 18:38
OpenCV gui to manually fit sine waves
import cv2, math
import numpy as np
import pandas as pd
import scipy
from sklearn import preprocessing
from scipy import signal
import matplotlib.pyplot as plt