niljub / pic2stl

pic2stl is a Python package that converts images to 3D STL models.
MIT License
2 stars 0 forks source link

add_base = True get a result ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (142164,) + inhomogeneous part. #6

Open sugizo opened 2 months ago

sugizo commented 2 months ago

code

!curl -LC - https://raw.githubusercontent.com/cpederkoff/stl-to-voxel/master/data/stanford_bunny.png -o stanford_bunny.png
file_name = 'stanford_bun
image_to_stl(f'{file_name}.png', f'{file_name}_0.stl', extrusion_height = 3, add_base = True)

result

ValueError                                Traceback (most recent call last)
[<ipython-input-26-d81244cec2d9>](https://localhost:8080/#) in <cell line: 1>()
----> 1 image_to_stl(f'{file_name}.png', f'{file_name}_0.stl', extrusion_height = 3, add_base = True)

[/usr/local/lib/python3.10/dist-packages/pic2stl/pic2stl.py](https://localhost:8080/#) in image_to_stl(image_path, output_path, extrusion_height, add_base, base_thickness, invert_image)
     84     # Create the mesh
     85     vertices = np.array(vertices)
---> 86     faces = np.array(faces)
     87     output_mesh = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))
     88     for i, f in enumerate(faces):

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (142164,) + inhomogeneous part.

n.b.

thanks and best regards

niljub commented 2 months ago

I'm having difficulty replicating the error on my end. Could you please share the file you used so I can investigate further?