Skip to content

Instantly share code, notes, and snippets.

View smeschke's full-sized avatar

Stephen Meschke smeschke

View GitHub Profile
import cv2
import numpy as np
cap = cv2.VideoCapture('/home/sm/Desktop/VIRB0034.MP4')
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('/home/sm/Desktop/balance.avi',fourcc, 30.0, (1920,1080))
color = (123,123,12)
def dst(f,c):
distance = math.sqrt((f[0]-c[0])**2+(f[1]-c[1])**2)
return distance
#import necessary libraries
import cv2
import numpy as np
#capture video from the webcam
cap = cv2.VideoCapture(0)
#load the face finder
face_cascade = cv2.CascadeClassifier('/home/sm/Desktop/haarcascade_frontalface_default.xml')
@smeschke
smeschke / dealwithit.py
Last active May 3, 2016 05:11
adds sunglasses
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
# params for ShiTomasi corner detection
feature_params = dict( maxCorners = 50,
qualityLevel = 0.2,
minDistance = 7,
blockSize = 7 )
@smeschke
smeschke / geoplotting
Last active August 17, 2016 20:57
Plotting the Proliferation of Mormon Temples with Basemap
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import csv
#get list of temple name, location, dedication data, lat, and lon
path = '/home/sm/Desktop/temple_data.csv'
temples = [] #create a list to store the temple data from the spread sheet
with open(path, 'rb') as csvfile: #open the csv file
temple_data = csv.reader(csvfile, delimiter=',', quotechar='"') #load temple data
for temple in temple_data: #iterate through data to change year to int
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
kernel = np.ones((8,8),np.uint8)
while(1):
# Take each frame
@smeschke
smeschke / partical_tutorial_4.py
Created August 26, 2016 18:53
Particle Tutorial - Ants leave the colony. (from http://www.petercollingridge.co.uk/)
import pygame
import random
import math
background_colour = (255,255,255)
(width, height) = (500, 500)
class Particle():
def __init__(self, (x, y), size):
self.x = x
import pygame
import random
import math
background_colour = (255,255,255)
(width, height) = (400, 400)
drag = 0.999
elasticity = 0.75
gravity = (math.pi, 0.002)
import cv2
@smeschke
smeschke / reality
Created September 4, 2016 05:43
augmented reality
import cv2
import numpy as np
#path to video paths
#source_path = '/home/sm/Desktop/VIRB0054.MP4'
source_path = 0
save_path = '/home/sm/Desktop/mandt_effect.avi'
image_path = '/home/sm/Desktop/map.png'
frame_rate, resolution = 25.0, (640,480)
text = cv2.imread(image_path)
@smeschke
smeschke / furniture_writer.py
Created October 28, 2016 16:07
Creates Catalog
article_path = 'furniture/furniture_invintory' #path to the article
article = open(article_path, 'r') #open the article
products = []
while True:
line = article.readline()
if line[:-1] == 'end_furniture': break
if line[:-1] == 'start_product':
product_key = article.readline()
product_name = article.readline()
banner_line_one = article.readline()
import numpy as np
import cv2
import math
#capture webcam video
cap = cv2.VideoCapture(0)
width, height = 1920,1080
cap.set(3,width)
cap.set(4,height)
#create a method that can seperate the foreground from the background