This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extract ILSVRC2012 without killing your SSD | |
import tarfile | |
import os | |
import sys | |
def mkdir(x): | |
try: | |
os.makedirs(x) | |
except OSError, e: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.models import Sequential, Model | |
from keras.layers import Dense, Input, BatchNormalization as BN | |
input_img1 = Input(shape=(4,), name="input_img1") | |
vision_model = Sequential() | |
vision_model.add(Dense(4, input_shape=(4,))) | |
vision_model.add(BN(axis=1)) | |
vision_model.add(Dense(4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guess = np.concatenate([np.array(map(lambda x: np.array(x[:,3]).ravel(), rts)), fpts[:, 0:3]], axis=0) | |
selects = [] | |
xys = [] | |
for i, trk in enumerate(good_good_tracks): | |
for shot, kp in trk: | |
xy = G.node[(shot,kp)]['kp']/0.81412059 | |
xys.append(xy) | |
select = np.zeros((len(frms)+len(good_good_tracks),)) | |
select[shot] = 1 | |
select[len(frms)+i] = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def msg(x): | |
print "S:",x.encode("hex") | |
if len(x) <= 7: | |
ret = chr(len(x)) + x | |
else: | |
assert False | |
return ret.ljust(8, "\x00") | |
def isotp_send(panda, x, addr, bus=0): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
from tqdm import tqdm | |
def test_frame_gen(limit=None): | |
fq = [] | |
cap = cv2.VideoCapture("data/test.mp4") | |
cnt = 0 | |
while 1: | |
ret, frame = cap.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ransac_polyfit(x, y, order=3, n=20, k=100, t=0.1, d=100, f=0.8): | |
# Thanks https://en.wikipedia.org/wiki/Random_sample_consensus | |
# n – minimum number of data points required to fit the model | |
# k – maximum number of iterations allowed in the algorithm | |
# t – threshold value to determine when a data point fits a model | |
# d – number of close data points required to assert that a model fits well to data | |
# f – fraction of close data points required | |
besterr = np.inf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getFundamentalMatrix(pts1, pts2): | |
vvec = [] | |
for p1, p2 in zip(pts1, pts2): | |
vvec.append([p2[0] * p1[0], p2[0] * p1[1], p2[0], p2[1] * p1[0], p2[1] * p1[1], p2[1], p1[0], p1[1], 1]) | |
vvec = np.array(vvec) | |
U, S, Vt = np.linalg.svd(vvec) | |
Fvl = Vt[-1] | |
om = Fvl.reshape(3,3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
real_colors = [[115,82,68],[194,150,130],[98,122,157],[87,108,67],[133,128,177],[103,189,170],[214,126,44],[80,91,166],[193,90,99],[94,60,108],[157,188,64],[224,163,46],[56,61,150],[70,148,73],[175,54,60],[231,199,31],[187,86,149],[8,133,161],[243,243,242],[200,200,200],[160,160,160],[122,122,121],[85,85,85],[52,52,52]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# homogenous line from two points (this isn't on the internet...) | |
line = [0,0,0] | |
line[0] = (f1[1] - f2[1]) * (f1[1] * f2[0] - f1[0] * f2[1]) | |
line[1] = (f1[0] - f2[0]) * (f1[0] * f2[1] - f1[1] * f2[0]) | |
line[2] = (f1[0] * f2[1] - f1[1] * f2[0]) * (f1[1] * f2[0] - f1[0] * f2[1]) | |
line = np.array(line) | |
# line intersection (https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Using_homogeneous_coordinates) | |
p = np.array([l1[1] * l2[2] - l2[1] * l1[2], l2[0] * l1[2] - l1[0] * l2[2], l1[0] * l2[1] - l2[0] * l1[1]]) | |
p /= p[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import argparse | |
import zmq | |
import json | |
import cv2 | |
import numpy as np | |
from hexdump import hexdump | |
import scipy.misc |
OlderNewer