Skip to content

Instantly share code, notes, and snippets.


Nate Oostendorp oostendo

View GitHub Profile
oostendo / gist:5901331
Created Jul 1, 2013
Earth mover distance for 2 numpy histograms (uses OpenCV's calcEMD2)
View gist:5901331
#extended from
#Earth Mover Distance = histogram similarity metric. Weights are optional.
def histEMD(hist1, hist2, hist1weights = [], hist2weights = []):
if not len(hist1weights):
hist1weights = np.ones(len(hist1))
if not len(hist2weights):
hist2weights = np.ones(len(hist1))
a64 = cv.fromarray(np.dstack((hist1weights, hist1))[0].copy())
View gist:5345093
[2013-04-09 07:39:21,858: ERROR/MainProcess] Error in timer: ConnectionError('Too many heartbeats missed', None, None, None, '')
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/celery/utils/", line 97, in apply_entry
File "/usr/local/lib/python2.7/dist-packages/celery/utils/", line 51, in __call__
return*self.args, **self.kwargs)
File "/usr/local/lib/python2.7/dist-packages/celery/utils/", line 153, in _reschedules
return fun(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/kombu/", line 264, in heartbeat_check
return self.transport.heartbeat_check(self.connection, rate=rate)
View gist:3975614
from mongoengine import Q
parts = Frame.objects(Q(**{"metadata__Part Number__startswith": "NC"}) | Q(**{"metadata__Part Number__startswith": "OK"}))
symerror = []
for p in parts:
fd = p.features[0].featuredata
symerror.append(abs(fd['transition_length_left_mm'] - fd['transition_length_right_mm']))
print fd['transition_length_left_mm'], " ", fd['transition_length_right_mm']
print "average:", np.sum(symerror) / len(symerror)
View gist:3960617
def findShaftTransition(self,img,left_guess,right_guess,top_cutoff):
Walk the line on the shaft find where it starts to bulge out
def transformFromROI(roi, points):
return np.array([(p[0] + roi[0], p[1] + roi[1]) for p in points])
right_guess = sorted(right_guess, key = lambda l: l[1]) #make sure it's bottom, top
roi_delta = 50
View gist:3428425
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
from random import random
from SimpleCV import Image, Color
from scipy import stats
View gist:3081232
vendor css:
our css:
our "theme" page (header/footer) and any static image files
our templates
View gist:3011708
"cameras": [
{ "id": 0, "name": "Scanner", "scanner": 1 }
"web": { "address": "localhost:8080" },
"mongo": { "host" : "" },
"database": "default",
View gist:2989211
SimpleSeer.Web: ERROR Exception on /grid/thumbnail_file/4fe47a9c598e1e04a90000f8 [GET]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/", line 1504, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/", line 1264, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/", line 1262, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/", line 1248, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
View gist:2955452
import gc
import SimpleSeer.models as M
def start(state):
return state.core.state('waitforbuttons')
View gist:2897922
for v in Image("lenna").findLines()[0].__dict__.values():
for vprime in v:
print type(vprime)
print type(v)