-class V(object):
- def __init__(self, x, y):
- self.x = x
- self.y = y
-
- def __add__(self, other):
- return V(self.x + other.x, self.y + other.y)
-
- def __sub__(self, other):
- return V(self.x - other.x, self.y - other.y)
-
- def __rmul__(self, other):
- return V(other * self.x, other * self.y)
-
- def __len__(self):
- return 2;
-
- def __getitem__(self, key):
- if key == 0:
- return self.x
- elif key == 1:
- return self.y
- elif type(key) != int:
- raise TypeError("V indices must be integers")
- else:
- raise KeyError("V index ({}) out of range".format(key))
-
- def __iter__(self):
- yield self.x
- yield self.y
-
- @property
- def normal(self):
- return V(-self.y, self.x)
-
-def projection(point, line, vector):
- return V(*intersection(g_line(point, point + vector.normal), g_line(*line)))
-
-def error_surface(lines, a, b, c, d, hough, size, v1):
- import matplotlib.pyplot as plt
- from matplotlib import cm
- import time
- import pickle
- X = []
- Y = []
- Z = []
- s = 0.001
- k = 200
- for i in range(-k, k):
- X.append(range(-k, k))
- Y.append(2*k*[i])
-
- start = time.time()
- for x in range(0, 2*k):
- try:
- Z.append([distance(lines, get_grid(a + X[x][y] * s * v1, b + Y[x][y] * s * v1,
- c, d, hough, size),
- size) for y in range(0, 2* k)])
- except Exception:
- Z.append(Z[-1])
- o = ((time.time() - start) * (2 * k - (x + 1))) / (60 * (x + 1))
- print x + 1, "{0} h {1:2.2f} m".format(int(o) / 60, o % 60)
- s_file = open('surface' + str(k), 'w')
- pickle.dump((X, Y, Z), s_file)
- s_file.close()
- plt.imshow(Z, cmap=cm.gnuplot2, interpolation='bicubic',
- origin='upper', extent=(-k, k, -k, k), aspect='equal')
- plt.colorbar()
-
- plt.show()
-
-def find(lines, size, l1, l2, bounds, hough, do_something):
- a, b, c, d = [V(*a) for a in bounds]
+def job_4(x, y, w, z, im_l, v1, v2, h1, h2, dv, dh, size):
+ v1 = (v1[0] + x * dv, v1[1] + x)
+ v2 = (v2[0] + y * dv, v2[1] + y)
+ h1 = (h1[0] + w * dh, h1[1] + w)
+ h2 = (h2[0] + z * dh, h2[1] + z)
+ return (distance(im_l, get_grid([v1, v2], [h1, h2], size), size))
+
+def find(lines, size, l1, l2, bounds, hough, do_something, im_h):