Skip to content

dummy.png doesn't exists #447

@datonefaridze

Description

@datonefaridze

Hello, i am trying to bake the mesh

def bake_obj(in_path, out_path):
    ms = ml.MeshSet()
    ms.load_new_mesh(in_path)

    # Bake texture colors into per-vertex colors (noop if already per-vertex)
    ms.compute_color_from_texture_per_vertex()

    # Scale the mesh
    S = 10.0   # <- use 4.0 for 4x
    ms.apply_filter(
        'compute_matrix_from_scaling_or_normalization',
        axisx=float(S),            # with uniformflag=True, X value is used for all axes
        uniformflag=True,          # same scale on X/Y/Z
        scalecenter='barycenter',  # scale around mesh centroid
        freeze=True                # actually write into vertex positions
    )
    ms.apply_filter('meshing_poly_to_tri')

    # ---- CLEANUP ----
    ms.apply_filter('meshing_remove_duplicate_faces')
    ms.apply_filter('meshing_remove_duplicate_vertices')
    P = getattr(ml, "PercentageValue", None) or getattr(ml, "Percentage", None)
    ms.apply_filter('meshing_merge_close_vertices', threshold=P(10))  # ≈0.1% of bbox diagonal
    ms.apply_filter('meshing_remove_unreferenced_vertices')
    ms.apply_filter('meshing_remove_null_faces')  # zero-area

    # ---- REPAIR TOPOLOGY ----
    # 1) Fix edges that are shared by >2 faces
    ms.apply_filter('meshing_repair_non_manifold_edges', method='Split Vertices')  # or 'Remove Faces'
    # 2) Fix non-manifold vertices (cone-at-apex, etc.)
    ms.apply_filter('meshing_repair_non_manifold_vertices', vertdispratio=0.0)
    # 3) Seal small openings
    ms.apply_filter('meshing_close_holes', maxholesize=100)

    # Get geometric measures
    measures = ms.get_geometric_measures()  # returns a dict
    print("mesh_volume:", measures.get('mesh_volume'))
    print("surface_area:", measures.get('surface_area'))

    # Get current mesh data with original (non-quantized) colors
    m = ms.current_mesh()
    V = m.vertex_matrix()       # (N,3)
    F = m.face_matrix()         # (M,3)
    C = m.vertex_color_matrix() # (N,4) floats in [0,1] RGBA

    # Build a new mesh with same geometry and original vertex colors
    m_output = ml.Mesh(vertex_matrix=V, face_matrix=F, v_color_matrix=C)
    ms_output = ml.MeshSet()
    ms_output.add_mesh(m_output, "output")

    # Save with vertex colors, without MTL file
    ms_output.save_current_mesh(out_path, save_vertex_color=True, save_wedge_texcoord=False)
    print("wrote", out_path)

but i am getting this error:

---------------------------------------------------------------------------
PyMeshLabException                        Traceback (most recent call last)
Cell In[1], line 64
     62 in_path  = "/home/dato/src/my_projects/Business/customToys/triposg_webapp/output.obj"
     63 out_path = '/home/dato/src/my_projects/Business/customToys/triposg_webapp/test.obj'
---> 64 bake_obj(in_path, out_path)

Cell In[1], line 10, in bake_obj(in_path, out_path)
      7 ms.load_new_mesh(in_path)
      9 # Bake texture colors into per-vertex colors (noop if already per-vertex)
---> 10 ms.compute_color_from_texture_per_vertex()
     12 # Scale the mesh
     13 S = 10.0   # <- use 4.0 for 4x

File ~/anaconda3/envs/ML/lib/python3.10/site-packages/pymeshlab/__init__.py:41, in bind_function.<locals>.filter_function(self, **kwargs)
     40 def filter_function(self, **kwargs):  # Have to add self since this will become a method
---> 41     res_dict = self.apply_filter(name, **kwargs)
     42     if bool(res_dict):  # return the dictionary only if it is not empty
     43         return res_dict

PyMeshLabException: Failed to apply filter: compute_color_from_texture_per_vertex
Details: Source texture "/home/dato/src/my_projects/Business/customToys/triposg_webapp/dummy.png" doesn't exists

my mtl file:

# Blender 4.0.2 MTL File: 'None'
# www.blender.org

newmtl BODY
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
d 1.000000
illum 2
Pr 1.000000
Pm 0.000000
Ps 0.000000
Pc 0.000000
Pcr 0.030000
aniso 0.000000
anisor 0.000000
map_Kd BODY_DIFUSE.jpg

newmtl DRESS
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
d 1.000000
illum 2
Pr 1.000000
Pm 0.000000
Ps 0.000000
Pc 0.000000
Pcr 0.030000
aniso 0.000000
anisor 0.000000
map_Kd DRESS_DIFUSE.jpg

newmtl HEAD
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
d 1.000000
illum 2
Pr 1.000000
Pm 0.000000
Ps 0.000000
Pc 0.000000
Pcr 0.030000
aniso 0.000000
anisor 0.000000
map_Kd HEAD_DIFUSE.jpg

newmtl NEEDLE
Ks 0.500000 0.500000 0.500000
Ke 0.413707 0.445065 0.700000
Ni 1.500000
d 1.000000
illum 2
Pr 1.000000
Pm 0.000000
Ps 0.000000
Pc 0.000000
Pcr 0.030000
aniso 0.000000
anisor 0.000000
map_Kd NEEDLE_DIFUSE.jpg

newmtl SILK_LINE_MATERIAL
Kd 0.403407 0.790855 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.500000 0.500000 0.500000
Ni 1.500000
d 1.000000
illum 2
Pr 1.000000
Pm 0.000000
Ps 0.000000
Pc 0.000000
Pcr 0.030000
aniso 0.000000
anisor 0.000000

newmtl shadow
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
illum 2
Pr 1.000000
Pm 0.000000
Ps 0.000000
Pc 0.000000
Pcr 0.030000
aniso 0.000000
anisor 0.000000
map_Kd shadow_difuse.jpg
map_d shadow_difuse.jpg

i am not referencing dummy.png, so can u please help me with this? i have ubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions