Skip to content

Instantly share code, notes, and snippets.

View jayrambhia's full-sized avatar

Jay Rambhia jayrambhia

View GitHub Profile
@jayrambhia
jayrambhia / down_ted_vids.py
Created March 11, 2012 07:56
A python script to download all the TED videos
import urllib2
import urllib
#import re
from BeautifulSoup import BeautifulSoup
"""
Download this file in html version
https://docs.google.com/spreadsheet/ccc?key=0AsKzpC8gYBmTcGpHbFlILThBSzhmZkRhNm8yYllsWGc&hl=en#gid=0"
"""
url = "The URL of above file" # url = "file:///home/jay/Downloads/index.html"
@jayrambhia
jayrambhia / xkcd_viewer.py
Created March 11, 2012 21:51
xkcd viewer (offline version)
"""
See this gist: https://gist.github.com/1984424
Download both of these gists. save it in same folder. The down_xkcd.py will download all the xkcd comics from net. And view comics using xkcd_viewer.py
"""
import pygtk
import gtk
from PIL import Image
import os
from random import randint
@jayrambhia
jayrambhia / xkcd_comic_viewer.py
Created March 12, 2012 12:26
xkcd viewer (fetches images online)
import pygtk
import gtk
import os
from random import randint
import urllib2
import os
from BeautifulSoup import BeautifulSoup
from threading import Thread
import gobject
gtk.gdk.threads_init()
@jayrambhia
jayrambhia / bb.py
Created May 30, 2012 15:08
mf-tracker
from math import sqrt
def calculateBBCenter(bb):
center = (0.5*(bb[0] + bb[2]),0.5*(bb[1]+bb[3]))
return center
def getFilledBBPoints(bb, numM, numN, margin):
pointDim = 2
bb_local = (bb[0] + margin, bb[1] + margin, bb[2] - margin, bb[3] - margin)
if numM == 1 and numN == 1 :
@jayrambhia
jayrambhia / track1.py
Created June 1, 2012 20:31
mf tracker (doesn't work properly)
from SimpleCV import *
from cv2.cv import *
from cv2 import *
import time
import math
from copy import deepcopy
def fbtrack(imgI, imgJ, bb):
numM = 10
numN = 10
echo "Install SimpleCV"
echo "Installing pre-reqisites"
sleep 1
echo "Installing OpenCV..."
sudo apt-get install libopencv-*
sudo apt-get install python-opencv
echo "OpenCV installed"
echo "Installing numpy and scipy"
sudo apt-get install python-numpy python-scipy
echo "numpy and scipy installed"
@jayrambhia
jayrambhia / Makefile
Created June 27, 2012 10:42
Comparison between run time of SimpleCV, OpenCV(python) and OpenCV(C++) Boost::Python bindings.
PYTHON_VERSION = 2.7
PYTHON_INCLUDE = /usr/include/python$(PYTHON_VERSION)
# location of the Boost Python include files and library
BOOST_INC = /usr/include
BOOST_LIB = /usr/lib
# compile mesh classes
TARGET = opencvtest
@jayrambhia
jayrambhia / houghlines.py
Created August 3, 2012 15:15
Hough Lines test
from SimpleCV import *
import time, cv2
import cv2.cv as cv
i = Image("Python/SimpleCV/line1.jpg")
g = i.getGrayNumpyCv2()
em = cv2.Canny(g, 70, 100)
l = cv2.HoughLines(em, 1.0, cv.CV_PI/180.0, 100)
print l.shape
l = l[0]
@jayrambhia
jayrambhia / LKTrack.py
Created August 8, 2012 14:56
Lucas Kanade Tracker (OpenCV)
import cv2
import numpy as np
import itertools
lk_params = dict( winSize = (10, 10),
maxLevel = 5,
criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 0.03))
feature_params = dict( maxCorners = 3000,
qualityLevel = 0.5,
@jayrambhia
jayrambhia / capture_util.py
Created August 14, 2012 07:07
Utilities for capture in OpenCV
import cv2
import cv2.cv as cv
"""
Got the idea from http://newpathprep.wordpress.com/2012/08/13/opencv-forward-and-rewind-avi/
He has done it in C++.
"""
def start(capture, n):
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES, n-1)
def rewind(capture):