Alessio Grancini
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -176,6 +176,39 @@ def generate_image_url(image):
|
|
176 |
b64_str = base64.b64encode(encoded_buffer).decode("utf-8")
|
177 |
return "data:image/png;base64," + b64_str
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
def get_3d_position(center, depth, camera_matrix):
|
180 |
"""Project 2D center into 3D space using depth and camera matrix."""
|
181 |
cx, cy = center
|
|
|
176 |
b64_str = base64.b64encode(encoded_buffer).decode("utf-8")
|
177 |
return "data:image/png;base64," + b64_str
|
178 |
|
179 |
+
|
180 |
+
def generate_plot_url(objs_pcd):
|
181 |
+
"""Generate a shareable URL for a Plotly 3D scatter plot of point clouds."""
|
182 |
+
fig = go.Figure()
|
183 |
+
|
184 |
+
for data, clr in objs_pcd:
|
185 |
+
points = np.asarray(data.points)
|
186 |
+
point_range = range(0, points.shape[0], 1)
|
187 |
+
|
188 |
+
fig.add_trace(go.Scatter3d(
|
189 |
+
x=points[point_range, 0],
|
190 |
+
y=points[point_range, 1],
|
191 |
+
z=points[point_range, 2]*100,
|
192 |
+
mode='markers',
|
193 |
+
marker=dict(
|
194 |
+
size=1,
|
195 |
+
color='rgb'+str(clr),
|
196 |
+
opacity=1
|
197 |
+
)
|
198 |
+
))
|
199 |
+
|
200 |
+
fig.update_layout(
|
201 |
+
scene=dict(
|
202 |
+
xaxis_title='X',
|
203 |
+
yaxis_title='Y',
|
204 |
+
zaxis_title='Z'
|
205 |
+
)
|
206 |
+
)
|
207 |
+
|
208 |
+
plot_html = fig.to_html(include_plotlyjs='cdn', full_html=False)
|
209 |
+
b64_str = base64.b64encode(plot_html.encode("utf-8")).decode("utf-8")
|
210 |
+
return "data:text/html;base64," + b64_str
|
211 |
+
|
212 |
def get_3d_position(center, depth, camera_matrix):
|
213 |
"""Project 2D center into 3D space using depth and camera matrix."""
|
214 |
cx, cy = center
|