Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
naurril committed Apr 1, 2020
2 parents c9ee162 + 8f4b038 commit 734f9a0
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 168 deletions.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@

<div id="object-context-menu">
<div class="menu-item menu-seperator"></div>
<!-- div class="menu-item" id="cm-interpolate">
<div class="menu-item" id="cm-interpolate">
<div class="menu-item-icon"><span class="ui-icon ui-icon-document"></span></div>
<div class="menu-item-text">Transfer to All</div>
</div -->
<div class="menu-item-text">Interpolate it</div>
</div>
<div class="menu-item" id="cm-delete">
<div class="menu-item-icon"><span class="ui-icon ui-icon-key"></span></div>
<div class="menu-item-text">Delete</div>
Expand Down
182 changes: 20 additions & 162 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@

import os
import sys
import scene_reader

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# sys.path.append(BASE_DIR)
# sys.path.append(os.path.join(BASE_DIR, '../pointnet'))
# import predict

sys.path.append(BASE_DIR)
sys.path.append(os.path.join(BASE_DIR, '../DeepAnnotate'))
import predict

sys.path.append(os.path.join(BASE_DIR, '../tracking'))
import trajectory_predict

extract_object_exe = "~/code/pcltest/build/extract_object"
registration_exe = "~/code/go_icp_pcl/build/test_go_icp"
Expand Down Expand Up @@ -50,31 +55,29 @@ def save(self, scene, frame):
f.write(rawbody)

return "ok"
@cherrypy.expose
@cherrypy.tools.json_out()
def interpolate(self, scene, frame, obj_id):
interpolate_num = trajectory_predict.predict(scene, obj_id, frame, None)
return interpolate_num


# data N*3 numpy array
@cherrypy.expose
@cherrypy.tools.json_out()
def predict_rotation(self):
# cl = cherrypy.request.headers['Content-Length']
# rawbody = cherrypy.request.body.read(int(cl))
cl = cherrypy.request.headers['Content-Length']
rawbody = cherrypy.request.body.read(int(cl))

# data = json.loads(rawbody)
data = json.loads(rawbody)

# return {"angle": predict.predict(data["points"])}
return {}
return {"angle": predict.predict(data["points"])}
#return {}

@cherrypy.expose
@cherrypy.tools.json_out()
def load_annotation(self, scene, frame):
filename = "./data/"+scene +"/label/"+ frame + ".json"
if (os.path.isfile(filename)):
with open(filename,"r") as f:
ann=json.load(f)
#print(ann)
return ann
else:
return []
return scene_reader.read_annotations(scene, frame)

@cherrypy.expose
@cherrypy.tools.json_out()
Expand Down Expand Up @@ -112,152 +115,7 @@ def auto_adjust(self, scene, ref_frame, object_id, adj_frame):
@cherrypy.expose
@cherrypy.tools.json_out()
def datameta(self):
data = []

scenes = os.listdir("./data")
print(scenes)
scenes.sort()

for s in scenes:
scene = {
"scene": s,
"frames": []
}

if os.path.exists(os.path.join("./data", s, "disable")):
print(s, "disabled")
continue

data.append(scene)

frames = os.listdir("./data/"+s+"/pcd")
#print(s, frames)
frames.sort()

scene["pcd_ext"]="pcd"
for f in frames:
#if os.path.isfile("./data/"+s+"/pcd/"+f):
filename, fileext = os.path.splitext(f)
scene["frames"].append(filename)
scene["pcd_ext"] = fileext

point_transform_matrix=[]

if os.path.isfile("./data/"+s+"/point_transform.txt"):
with open("./data/"+s+"/point_transform.txt") as f:
point_transform_matrix=f.read()
point_transform_matrix = point_transform_matrix.split(",")

def strip_str(x):
return x.strip()



# calib_file = "./data/"+s+"/calib.txt"
# if os.path.isfile(calib_file):
# calib["image"] = {}
# with open(calib_file) as f:
# lines = f.readlines()
# calib["image"]["extrinsic"] = map(strip_str, lines[0].strip().split(","))
# calib["image"]["intrinsic"] = lines[1].strip().split(",")

# calibleft={}
# calib_file = "./data/"+s+"/calib_left.txt"
# if os.path.isfile(calib_file):
# calib["left"] = {}
# with open(calib_file) as f:
# lines = f.readlines()
# calib["left"]["extrinsic"] = map(strip_str, lines[0].strip().split(","))
# calib["left"]["intrinsic"] = lines[1].strip().split(",")

# calibright={}
# calib_file = "./data/"+s+"/calib_right.txt"
# if os.path.isfile(calib_file):
# calib["right"] = {}
# with open(calib_file) as f:
# lines = f.readlines()
# calib["right"]["extrinsic"] = map(strip_str, lines[0].strip().split(","))
# calib["right"]["intrinsic"] = lines[1].strip().split(",")
calib={}
if os.path.exists("./data/"+s+"/calib"):
calibs = os.listdir("./data/"+s+"/calib")
for c in calibs:
calib_file = "./data/"+s+"/calib/" + c
calib_name, _ = os.path.splitext(c)
if os.path.isfile(calib_file):
#print(calib_file)
with open(calib_file) as f:
cal = json.load(f)
calib[calib_name] = cal

# camera names
image = []
image_ext = ""
cam_path = "./data/"+s+"/image"
if os.path.exists(cam_path):
if os.path.exists(cam_path):
cams = os.listdir(cam_path)
for c in cams:
cam_file = "./data/"+s+"/image/" + c
if os.path.isdir(cam_file):

if image:
image.append(c)
else:
image = [c]

if image_ext == "":
#detect image file ext
files = os.listdir(cam_file)
if len(files)>=2:
_,image_ext = os.path.splitext(files[0])

if image_ext == "":
image_ext = ".jpg"
scene["image_ext"] = image_ext


if not os.path.isdir("./data/"+s+"/bbox.xyz"):
scene["boxtype"] = "psr"
if point_transform_matrix:
scene["point_transform_matrix"] = point_transform_matrix
if calib:
scene["calib"] = calib
if image:
scene["image"] = image
else:
scene["boxtype"] = "xyz"
if point_transform_matrix:
scene["point_transform_matrix"] = point_transform_matrix
if calib:
scene["calib"] = calib
if image:
scene["image"] = image


#print(data)
return data
# return [
# {
# "scene":"liuxian1",
# "frames": [
# "000242","000441"
# ],
# "boxtype":"xyz",
# "point_transform_matrix": [
# 1, 0, 0,
# 0, 0, 1,
# 0, -1, 0,
# ]
# },
# {
# "scene":"liuxian2",
# "frames": [
# "test"
# ],
# "boxtype":"psr",
# },
# ]
return scene_reader.get_all_scenes()

@cherrypy.expose
@cherrypy.tools.json_out()
Expand Down
2 changes: 1 addition & 1 deletion public/js/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ function update_image_box_projection(box){
y: ctx.canvas.height/crop_area[3],
}

draw_box_on_image(ctx, box, imgfinal, trans_ratio, false);
draw_box_on_image(ctx, box, imgfinal, trans_ratio, true);
}
}
}
Expand Down
32 changes: 32 additions & 0 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ function install_context_menu(){
remove_selected_box();
header.mark_changed_flag();
};

document.getElementById("cm-interpolate").onclick = function(event){
interpolate_selected_object();
header.mark_changed_flag();
};


}

Expand Down Expand Up @@ -1974,5 +1980,31 @@ function add_global_obj_type(){
}


function interpolate_selected_object(){

let scene = data.world.file_info.scene;
let frame = data.world.file_info.frame;
let obj_id = selected_box.obj_track_id;


var xhr = new XMLHttpRequest();
// we defined the xhr

xhr.onreadystatechange = function () {
if (this.readyState != 4)
return;

if (this.status == 200) {
var ret = JSON.parse(this.responseText);
console.log(ret);
}

};

xhr.open('GET', "/interpolate?scene="+scene+"&frame="+frame+"&obj_id="+obj_id, true);
xhr.send();


}

export {selected_box, params, on_box_changed, select_bbox, scene, floatLabelManager, on_load_world_finished, operation_state, transform_bbox, translate_box, update_subview_by_windowsize}
4 changes: 2 additions & 2 deletions public/js/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function save_annotation(done){
var bbox_annotations=[];
console.log(data.world.boxes.length, "boxes");
data.world.boxes.forEach(function(b){
var vertices = psr_to_xyz(b.position, b.scale, b.rotation);
//var vertices = psr_to_xyz(b.position, b.scale, b.rotation);

var b = {
psr: {
Expand All @@ -33,7 +33,7 @@ function save_annotation(done){

obj_type: b.obj_type,
obj_id: b.obj_track_id,
vertices: vertices,
//vertices: vertices,
};

bbox_annotations.push(b);
Expand Down
Loading

0 comments on commit 734f9a0

Please sign in to comment.