|
import open3d as o3d |
|
import streamlit as st |
|
|
|
|
|
st.title("Jewelry 3D Model Viewer") |
|
st.write("Upload an OBJ file to visualize the 3D model of jewelry.") |
|
|
|
|
|
uploaded_file = st.file_uploader("Choose an OBJ file", type="obj") |
|
|
|
if uploaded_file is not None: |
|
|
|
with open("uploaded_model.obj", "wb") as f: |
|
f.write(uploaded_file.getbuffer()) |
|
|
|
|
|
mesh = o3d.io.read_triangle_mesh("uploaded_model.obj") |
|
mesh.compute_vertex_normals() |
|
|
|
|
|
vertices = mesh.vertices |
|
triangles = mesh.triangles |
|
vertex_colors = mesh.vertex_colors |
|
|
|
st.write("### 3D Model Preview") |
|
st.write("Mesh Vertices: ", len(vertices)) |
|
st.write("Mesh Triangles: ", len(triangles)) |
|
|
|
|
|
st.write("You can download Open3D and use it to visualize the mesh locally.") |
|
|
|
|
|
st.write(mesh) |
|
|
|
else: |
|
st.write("Please upload an OBJ file to visualize the jewelry model.") |