Skip to content

Commit

Permalink
draw traj more eye-catching
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 5, 2024
1 parent 870eb6c commit 9956c04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion gradio_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def vis_camera(RT_list, rescale_T=1, index=0):
for i, RT in enumerate(RT_list):
R = RT[:,:3]
T = RT[:,-1]/rescale_T
cone = calc_cam_cone_pts_3d(R, T, fov_deg)
cone = calc_cam_cone_pts_3d(R, T, fov_deg,scale=1)
if index==i:
cone_list.append((cone, (0, "yellow"), f"view_{i}"))
else:
Expand All @@ -32,6 +32,7 @@ def vis_camera(RT_list, rescale_T=1, index=0):
(x1, x2) = (cone[edge[0], 0], cone[edge[1], 0])
(y1, y2) = (cone[edge[0], 1], cone[edge[1], 1])
(z1, z2) = (cone[edge[0], 2], cone[edge[1], 2])
#print(f'{[x1,x2,y1,y2,z1,z2]}')
fig.add_trace(go.Scatter3d(
x=[x1, x2], y=[y1, y2], z=[z1, z2], mode='lines',
line=dict(color=clr, width=3),
Expand Down
14 changes: 9 additions & 5 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ def save_results(video, fps=10,traj="[]",draw_traj_dot=False,cameras=[],draw_cam
#draw.ellipse((0,0,255,255),fill=(255,0,0), outline=(255,0,0))
if draw_traj_dot:
traj_list=json.loads(traj)
traj_point=traj_list[len(traj_list)-1]
if len(traj_list)>i:
traj_point=traj_list[i]

#print(traj_point)
size=3
draw.ellipse((traj_point[0]/4-size,traj_point[1]/4-size,traj_point[0]/4+size,traj_point[1]/4+size),fill=(255,0,0), outline=(255,0,0))

for j in range(grid.shape[0]):
traj_point=traj_list[len(traj_list)-1]
if len(traj_list)>j:
traj_point=traj_list[j]
if i==j:
draw.ellipse((traj_point[0]/4-size,traj_point[1]/4-size,traj_point[0]/4+size,traj_point[1]/4+size),fill=(255,0,0), outline=(255,0,0))
else:
draw.ellipse((traj_point[0]/4-size,traj_point[1]/4-size,traj_point[0]/4+size,traj_point[1]/4+size),fill=(255,255,255), outline=(255,255,255))

if draw_traj_dot:
fig = vis_camera(cameras,1,i)
camimg=Image.open(BytesIO(fig.to_image('png',256,256)))
Expand Down

0 comments on commit 9956c04

Please sign in to comment.