def test_find_circles(self): rrld = ReadRobotLineData() points = rrld.get_points(os.path.abspath("embedding_darwin_-{}".format(4))) points = [(p[0]*100, p[1]*100) for p in points] ccd = CenterCircleDetection(points) ccd.find_circles()
def test_minimum_span_tree_from_point_cloud(self): rrld = ReadRobotLineData() points = rrld.get_points(os.path.abspath("embedding_darwin_-{}".format(4))) points = [(int(e[0]), int(e[1])) for e in points] points = list(set(points)) ccd = CenterCircleDetection(points) result = ccd.calculate_minimum_span_tree() plt.plot([e[0] for e in points], [e[1] for e in points], 'ro') for edge in result: x1, y1 = points[edge[0]] x2, y2 = points[edge[1]] plt.plot([x1, x2], [y1, y2], 'g-') plt.show()
if sgrid.get(sx + 1, None) is not None: if sgrid[sx + 1].get(sy, 0) > 2: counter += 1 if sgrid.get(sx - 1, None) is not None: if sgrid[sx - 1].get(sy - 1, 0) > 2: counter += 1 if sgrid.get(sx, None) is not None: if sgrid[sx].get(sy - 1, 0) > 2: counter += 1 if sgrid.get(sx + 1, None) is not None: if sgrid[sx + 1].get(sy - 1, 0) > 2: counter += 1 return counter rrld = ReadRobotLineData() points = rrld.get_points(os.path.abspath("embedding_darwin_-{}".format(18))) grid = {} for point in points: x = int(point[0] / 50) y = int(point[1] / 50) if x not in grid: grid[x] = {} if y not in grid[x]: grid[x][y] = 0 grid[x][y] += 1 # print grid[x][y] for x in grid.keys():
return linemapping def plot_line_assignment(self, line_assignment): lins = itertools.cycle(["r-", "y-", "g-", "m-", "b-", "c-"]) cols = itertools.cycle(["ro", "yo", "go", "mo", "bo", "co"]) for key, values in self.linemapping.items(): print "K", key = eval(key) plt.plot([key[0], key[2]], [key[1], key[3]], lins.next()) plt.plot([e[0] for e in values], [e[1] for e in values], cols.next()) plt.xlim([0, 200]) plt.ylim([0, 100]) plt.show() rrld = ReadRobotLineData() points = rrld.get_points("data_darwin/embedding_darwin_-36") points, data = rrld.get_image(points) # Receives input data points # data, points = giveit() # points = [(x*random.random(), 2*random.random()) for x in range(40)] + [(4*random.random(), y*random.random()) for y in range(80)] print "Point sTatistics" xmax = max([e[0] for e in points]) xmin = min([e[0] for e in points]) ymax = max([e[1] for e in points]) ymin = min([e[1] for e in points])