Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/naurril/SUSTechPoints
Browse files Browse the repository at this point in the history
  • Loading branch information
naurril committed Mar 29, 2020
2 parents 9b0f3f7 + ab0c8df commit c9ee162
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 94 deletions.
2 changes: 1 addition & 1 deletion data/example/label/000950.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/example/label/000965.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/example/label/000970.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/example/label/000975.json

Large diffs are not rendered by default.

49 changes: 0 additions & 49 deletions operations.md

This file was deleted.

8 changes: 4 additions & 4 deletions public/js/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ var data = {
},

create_box_by_view_rect: function(x,y,w,h, camera, center){
var rotation_z = camera.rotation.z;
var rotation_z = camera.rotation.z + Math.PI/2;

var points = this.points;
var pos_array = points.geometry.getAttribute("position").array;
Expand Down Expand Up @@ -1461,9 +1461,9 @@ var data = {
-h,-h,h, -h,-h,-h,

//direction
0, 0, h+0.1, 0, h, h+0.1,
-h,h/2,h+0.1, 0, h, h+0.1,
h,h/2,h+0.1, 0, h, h+0.1,
0, 0, h+0.1, h, 0, h+0.1,
h/2, -h, h+0.1, h, 0, h+0.1,
h/2, h, h+0.1, h, 0, h+0.1,

//side direction
// h, h/2, h, h, h, 0,
Expand Down
12 changes: 7 additions & 5 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,13 @@ function update_subview_by_windowsize(box){
var view_height = Math.floor( window.innerHeight * view.height );

if (ii==1){
exp_camera_width = box.scale.x*1.5*view.zoom_ratio;
exp_camera_height = box.scale.y*1.5*view.zoom_ratio;
// width: y
// length: x
exp_camera_height = box.scale.x*1.5*view.zoom_ratio;
exp_camera_width = box.scale.y*1.5*view.zoom_ratio;

exp_camera_clip = box.scale.z+0.8;
} else if (ii==2){
} else if (ii==2){
exp_camera_width = box.scale.x*1.5*view.zoom_ratio;
exp_camera_height = box.scale.z*1.5*view.zoom_ratio;

Expand Down Expand Up @@ -892,7 +894,7 @@ function update_subview_by_bbox(box){
//
views[1].camera.rotation.x= r.x;
views[1].camera.rotation.y= r.y;
views[1].camera.rotation.z= r.z;
views[1].camera.rotation.z= r.z-Math.PI/2;

views[1].camera.position.x= p.x;
views[1].camera.position.y= p.y;
Expand Down Expand Up @@ -1311,7 +1313,7 @@ function change_transform_control_view(){
function add_bbox(obj_type){
// todo: move to data.world
var pos = get_mouse_location_in_world();
var rotation = {x:0, y:0, z:views[0].camera.rotation.z};
var rotation = {x:0, y:0, z:views[0].camera.rotation.z+Math.PI/2};

var obj_cfg = get_obj_cfg_by_type(obj_type);
var scale = {
Expand Down
28 changes: 14 additions & 14 deletions public/js/obj_cfg.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// size is the dimension of the object in x/y/z axis, with unit meter.
var obj_type_map = {
Car: {color: '#00ff00', size:[1.8, 4.5, 1.5]},
Van: {color: '#00ff00', size:[1.8, 4.5, 1.5]},
Bus: {color: '#ffff00', size:[3, 13, 3.5]},
Pedestrian: {color: '#ff0000', size:[0.5, 0.4, 1.7]},
Rider: {color: '#ff8800', size:[0.6, 1.6, 1.6]},
Cyclist: {color: '#ff8800', size:[0.6, 1.6, 1.6]},
Bicycle: {color: '#88ff00', size:[0.6, 1.6, 1.2]},
BicycleGroup: {color: '#88ff00', size:[0.6, 1.6, 1.2]},
Motor: {color: '#aaaa00', size:[0.6, 1.6, 1.2]},
Truck: {color: '#00ffff', size:[2.8, 10, 3]},
Tram: {color: '#00ffff', size:[2.8, 10, 3]},
Animal: {color: '#00aaff', size:[0.6, 1.6, 1.2]},
Misc: {color: '#008888', size:[1.8, 4.5, 1.5]},
Unknown: {color: '#008888', size:[1.8, 4.5, 1.5]},
Car: {color: '#00ff00', size:[4.5, 1.8, 1.5]},
Van: {color: '#00ff00', size:[4.5, 1.8, 1.5]},
Bus: {color: '#ffff00', size:[13, 3, 3.5]},
Pedestrian: {color: '#ff0000', size:[0.4, 0.5, 1.7]},
Rider: {color: '#ff8800', size:[1.6, 0.6, 1.6]},
Cyclist: {color: '#ff8800', size:[1.6, 0.6, 1.6]},
Bicycle: {color: '#88ff00', size:[1.6, 0.6, 1.2]},
BicycleGroup: {color: '#88ff00', size:[1.6, 0.6, 1.2]},
Motor: {color: '#aaaa00', size:[1.6, 0.6, 1.2]},
Truck: {color: '#00ffff', size:[10., 2.8, 3]},
Tram: {color: '#00ffff', size:[10., 2.8, 3]},
Animal: {color: '#00aaff', size:[1.6, 0.6, 1.2]},
Misc: {color: '#008888', size:[4.5, 1.8, 1.5]},
Unknown: {color: '#008888', size:[4.5, 1.8, 1.5]},
}


Expand Down
38 changes: 30 additions & 8 deletions public/js/side_view_op.js
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,12 @@ function on_z_auto_shrink(direction){

})
} else{
direction = {
x: direction.y,
y: -direction.x,
z: 0,
}

auto_shrink(extreme, direction)
}

Expand All @@ -851,9 +857,15 @@ function on_z_auto_shrink(direction){

function on_z_edge_changed(ratio, direction){

var delta = {
x: selected_box.scale.x * ratio.x * direction.x,
y: selected_box.scale.y * ratio.y * direction.y,
var delta = {
x: selected_box.scale.x * ratio.y * direction.y,
y: selected_box.scale.y * ratio.x * direction.x,
z: 0,
};

direction ={
x: direction.y,
y: -direction.x,
z: 0,
};

Expand Down Expand Up @@ -887,10 +899,14 @@ function on_z_direction_changed(theta, sticky){
}


//ratio.y vertical
//ratio.x horizental
// box.x vertical
// box.y horizental
function on_z_moved(ratio){
var delta = {
x: selected_box.scale.x*ratio.x,
y: selected_box.scale.y*ratio.y
var delta = {
x: selected_box.scale.x*ratio.y,
y: -selected_box.scale.y*ratio.x,
};


Expand All @@ -903,6 +919,12 @@ function on_z_moved(ratio){

function on_z_scaled(ratio){

ratio = {
x: ratio.y,
y: ratio.x,
z: 0,
};

for (var axis in ratio){
if (ratio[axis] != 0){
selected_box.scale[axis] *= 1+ratio[axis];
Expand All @@ -915,7 +937,7 @@ function on_z_scaled(ratio){
function on_z_wheel(wheel_direction){
on_wheel(views[1], wheel_direction);
update_subview_by_windowsize(selected_box);
z_view_handle.update_view_handle(views[1].viewport, {x: selected_box.scale.x, y:selected_box.scale.y});
z_view_handle.update_view_handle(views[1].viewport, {x: selected_box.scale.y, y:selected_box.scale.x});
}

function on_z_auto_rotate(){
Expand Down Expand Up @@ -1161,7 +1183,7 @@ var view_handles = {
},

update_view_handle: function(){
z_view_handle.update_view_handle(views[1].viewport, {x: selected_box.scale.x, y:selected_box.scale.y});
z_view_handle.update_view_handle(views[1].viewport, {x: selected_box.scale.y, y:selected_box.scale.x});
y_view_handle.update_view_handle(views[2].viewport, {x: selected_box.scale.x, y:selected_box.scale.z});
x_view_handle.update_view_handle(views[3].viewport, {x: selected_box.scale.y, y:selected_box.scale.z});
},
Expand Down
11 changes: 11 additions & 0 deletions public/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function psr_to_xyz(p,s,r){
var x=s.x/2;
var y=s.y/2;
var z=s.z/2;
/*
var local_coord = [
-x, y, -z, 1, x, y, -z, 1, //front-left-bottom, front-right-bottom
x, y, z, 1, -x, y, z, 1, //front-right-top, front-left-top
Expand All @@ -74,6 +75,16 @@ function psr_to_xyz(p,s,r){
x, -y, z, 1, -x, -y, z, 1,
];
*/

var local_coord = [
x, y, -z, 1, x, -y, -z, 1, //front-left-bottom, front-right-bottom
x, -y, z, 1, x, y, z, 1, //front-right-top, front-left-top

-x, y, -z, 1, -x, -y, -z, 1, //rear-left-bottom, rear-right-bottom
-x, -y, z, 1, -x, y, z, 1, //rear-right-top, rear-left-top

];

var world_coord = matmul(trans_matrix, local_coord, 4);
var w = world_coord;
Expand Down
5 changes: 5 additions & 0 deletions public/js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ function create_top_view(scene){
camera.position.y = 0;
//camera.up.set( 0, 1, 0);
//camera.lookAt( 0, 0, -3 );

camera.rotation.x=0;
camera.rotation.y=0;
camera.rotation.z=-Math.PI/2;;

view.camera = camera;

view.viewport={
Expand Down
25 changes: 15 additions & 10 deletions tools/trans_kitti_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
import math
import numpy as np

# label_path = '../public/data/kitti/label_2'
# my_label_path = '../public/data/kitti/label'
# calib_path = "/home/lie/diskd/data/kitti/3d-obj-det/training/calib"
label_path = './data/kitti/label_2'
my_label_path = './data/kitti/label'
calib_path = "./data/kitti/calib_2"

label_path = '/home/lie/disk640/data/kitti/label_2'
my_label_path = '/home/lie/disk640/data/kitti/sustechpoints_label'
calib_path = "/home/lie/disk640/data/kitti/data_object_calib/training/calib"
#label_path = '/home/lie/disk640/data/kitti/label_2'
#my_label_path = '/home/lie/disk640/data/kitti/sustechpoints_label'
#calib_path = "/home/lie/disk640/data/kitti/data_object_calib/training/calib"
#pc_path="/home/lie/disk640/data/kitti/velodyne"


Expand Down Expand Up @@ -97,15 +97,20 @@ def parse_one_obj(l):
#print(trans_pos)

obj["obj_type"] = words[0]
obj["psr"] = {"scale": {"z":float(words[8]), "x":float(words[9]), "y":float(words[10])},
obj["psr"] = {"scale":
{"z":float(words[8]), #height
"x":float(words[10]), #length
"y":float(words[9])}, #width
"position": {"x":trans_pos[0], "y":trans_pos[1], "z":trans_pos[2]+float(words[8])/2},
"rotation": {"x":0, "z":math.pi-float(words[14]), "y":0}}
"rotation": {"x":0,
"y":0,
"z": -math.pi/2 -float(words[14])}}
obj["obj_id"] = ""
return obj

objs = map(parse_one_obj, lines)
filtered_objs = [x for x in filter(lambda obj: obj["obj_type"]!='DontCare', objs)]
print(filtered_objs)
filtered_objs = [x for x in objs]#[x for x in filter(lambda obj: obj["obj_type"]!='DontCare', objs)]
#print(filtered_objs)

with open(os.path.join(my_label_path, frame + ".json"), 'w') as outfile:
json.dump(filtered_objs, outfile)
18 changes: 18 additions & 0 deletions tools/trans_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import json
import os
import math

root_dir = "./data/example/label"

for f in os.listdir(root_dir):
fpath = os.path.join(root_dir, f)
if os.path.splitext(f)[1] == ".json":
with open(fpath, "r") as fin:
objs = json.load(fin)
for o in objs:
o["psr"]["rotation"]["z"] = math.pi/2 + o["psr"]["rotation"]["z"]
o["psr"]["scale"]["y"], o["psr"]["scale"]["x"] = o["psr"]["scale"]["x"],o["psr"]["scale"]["y"]
print(fpath)
#print(objs)
with open(fpath, "w") as fout:
json.dump(objs, fout)

0 comments on commit c9ee162

Please sign in to comment.