Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 62410d28 authored by bernie wang's avatar bernie wang
Browse files

added all untracked files after merge

parent 0dcda207
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
File added
from flask import Flask, render_template, request, jsonify
from bounding_box import BoundingBox
from pointcloud import PointCloud
from tracker import Tracker
from predict_label import predict_label
import numpy as np
import json
app = Flask(__name__, static_url_path='/static')
@app.route("/")
def root():
return render_template("index.html")
@app.route("/initTracker", methods=["POST"])
def init_tracker():
json_request = request.get_json()
pointcloud = PointCloud.parse_json(json_request["pointcloud"])
tracker = Tracker(pointcloud)
print(str(tracker))
return "success"
@app.route("/trackBoundingBoxes", methods=['POST'])
def trackBoundingBox():
json_request = request.get_json()
pointcloud = PointCloud.parse_json(json_request["pointcloud"], json_request["intensities"])
filtered_indices = tracker.filter_pointcloud(pointcloud)
next_bounding_boxes = tracker.predict_bounding_boxes(pointcloud)
# print(filtered_indices)
print(next_bounding_boxes)
return str([filtered_indices, next_bounding_boxes])
@app.route("/updateBoundingBoxes", methods=['POST'])
def updateBoundingBoxes():
print(request.get_json())
json_request = request.get_json()
bounding_boxes = BoundingBox.parse_json(json_request["bounding_boxes"])
tracker.set_bounding_boxes(bounding_boxes)
return str(bounding_boxes)
@app.route("/predictLabel", methods=['POST'])
def predictLabel():
json_request = request.get_json()
json_data = json.dumps(json_request)
filename = json_request['filename'].split('.')[0]
return str(predict_label(json_data, filename))
if __name__ == "__main__":
tracker = Tracker()
app.run()
import numpy as np
class BoundingBox():
def __init__(self, center, width, length, angle, object_id):
self.x = center['x']
self.y = center['y']
self.width = width
self.length = length
self.angle = angle
self.object_id = object_id
@staticmethod
def parse_json(json):
return [BoundingBox(json_obj['center'],
json_obj['width'],
json_obj['length'],
json_obj['angle'],
json_obj['object_id'])
for json_obj in json]
def filter_points(self, pointcloud, bounding_factor=.1):
l, w, theta = self.length, self.width, self.angle
center = np.array([[self.x, self.y]])
rotated_points = pointcloud.rigid_transform(theta, center)
x, y = rotated_points[:, 0], rotated_points[:, 1]
indices_within_width = np.where(np.abs(x) <= w / 2 * (1 + bounding_factor))[0]
indices_within_length = np.where(np.abs(y) <= l / 2 * (1 + bounding_factor))[0]
bounded_indices = np.intersect1d(indices_within_width, indices_within_length)
return bounded_indices
# def filter_points2(self, pointcloud):
# l, w, theta = self.length, self.width, self.angle
# cx, cy = self.x, self.y
# m = np.tan(theta)
# if np.isclose(theta, np.pi / 2) or np.isclose(theta, np.pi * 3 / 2):
# filter_fn = lambda point : (point[0] <= cx + bounding_factor * w and
# point[0] >= cx - bounding_factor * w)
# # filter_fn_y = lambda point : (point[1] <= cy + bounding_factor * l and
# # point[1] >= cy - bounding_factor * l)
# else:
# upper_x = cx + l / 2 * np.cos(theta) + w / 2 * np.cos(np.pi / 2 + theta)
# upper_y = cy + l / 2 * np.sin(theta) + w / 2 * np.sin(np.pi / 2 + theta)
# b_upper = upper_y - m * upper_x
# lower_x = cx - l / 2 * np.cos(theta) - w / 2 * np.cos(np.pi / 2 + theta)
# lower_y = cy - l / 2 * np.sin(theta) - w / 2 * np.sin(np.pi / 2 + theta)
# b_lower = lower_y - m * lower_x
# filter_fn = lambda point : (point[1] >= m * point[0] + b_lower - w * bounding_factor and
# point[1] <= m * point[0] + b_upper + w * bounding_factor)
# filtered_pointcloud = filter(filter_fn, pointcloud.points)
# return list(filtered_pointcloud)
{"frames":[{"add_box_count":6,"resize_count":0,"translate_count":0,"rotate_count":0,"delete_count":0,"label_count":0,"rotate_camera_count":5,"filename":"0000000006.bin","bounding_boxes":[{"center":{"x":13.792100071358922,"y":-3.4149453410512436},"width":2.6765878394369524,"length":3.7787128137151473,"angle":-0.20377898289719254,"object_id":"car"},{"center":{"x":7.085325162738445,"y":2.5411436591706646},"width":0.702202091821645,"length":0.4388761149316252,"angle":0.10188949145839223,"object_id":"car"},{"center":{"x":-1.0271226512898233,"y":-8.09512299422978},"width":3.586225324113517,"length":2.367605680717997,"angle":0,"object_id":"car"},{"center":{"x":-5.083388943390494,"y":-4.125901280815247},"width":3.6210441144258056,"length":1.7408861826256716,"angle":0,"object_id":"car"},{"center":{"x":-10.532363792806184,"y":0.10445483360289831},"width":4.352217231894789,"length":1.845339122377025,"angle":0,"object_id":"car"},{"center":{"x":-26.08230909643617,"y":-7.981316024389361},"width":8.342553349072649,"length":3.119980015280138,"angle":0,"object_id":"car"}],"time_elapsed":30.969,"_3D_time_elapsed":2.568,"camera_angle":0}]}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment