Commit 6a4b6d4a authored by bernie wang's avatar bernie wang
Browse files

implemented export bounding boxes

parent 8a97ac68
......@@ -640,19 +640,26 @@ function labelMode( event ) {
}
function OutputBox(box) {
var v1 = box.geometry.vertices[0];
var v2 = box.geometry.vertices[1];
var v3 = box.geometry.vertices[2];
var center = getCenter(v1, v2);
this.center = new THREE.Vector2(center.x, center.z);
this.width = distance2D(v1, v3);
this.length = distance2D(v2, v3);
this.angle = box.angle;
}
function save() {
textContents = [];
var numHighlighted = 0
for (var i=0;i<pointcloud.geometry.vertices.length;i++) {
var point = pointcloud.geometry.vertices[i];
var highlighted = pointsWithSpheres.has(i) ? 1 : 0;
numHighlighted += highlighted;
string = "%f,%f,%f,%d\n".format(point.x, point.y, point.z, highlighted);
textContents.push(string);
}
console.log('Number of highlighted points: ' + numHighlighted.toString());
var blob = new Blob(textContents, {type: "text/plain;charset=utf-8"});
saveAs(blob, "labelled.csv");
var outputBoxes = []
for (var i = 0; i < boundingBoxes.length; i++) {
outputBoxes.push(new OutputBox(boundingBoxes[i]));
}
var output = {"bounding boxes": outputBoxes};
var stringifiedOutput = JSON.stringify(output);
var file = new File([stringifiedOutput], "test.json", {type: "/json;charset=utf-8"});
saveAs(file);
}
function save_image() {
......
{"bounding boxes":[{"center":{"x":-2.460099658806106,"y":16.573311112450146},"width":2.0198708730130184,"length":3.521826193945069,"angle":0},{"center":{"x":5.567595920171727,"y":12.947900424874463},"width":1.7091207648632398,"length":4.45407530259526,"angle":0},{"center":{"x":5.282741256816085,"y":20.794324167480163},"width":1.9680784397395783,"length":3.8843664835588108,"angle":0},{"center":{"x":-2.998989621482947,"y":-18.52950881611828},"width":1.4501647736860184,"length":3.4182457433840785,"angle":0.23043466900411913},{"center":{"x":4.148401245804875,"y":-21.43933159547536},"width":2.7449544936902046,"length":4.764828538884392,"angle":0.05376808947938398}]}
\ No newline at end of file
{"bounding boxes":[{"center":{"x":-2.6593211730135797,"y":-17.05596349062231},"width":null,"length":null,"angle":0.18434773519087222},{"center":{"x":4.136662402357912,"y":-19.58486615409207},"width":4.527216096694613,"length":null,"angle":5.065978588037079e-12},{"center":{"x":-2.1079292062948927,"y":18.44441542723763},"width":null,"length":11.222237182612629,"angle":0.026042254245489477},{"center":{"x":5.196686040842421,"y":22.465391567117322},"width":4.088674839355419,"length":12.563076629557298,"angle":0.026042254245489477}]}
\ 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