Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - danimlk

Pages: [1]
1
General / Drawing boxes on the images create defects in the 3d mesh!
« on: October 06, 2021, 03:46:01 PM »
Hi all,

To create a 3D mesh for an object. We are capturing the images by rotating the camera around the object and then using those images to create a 3D mesh. The images are aligned and the mesh looks fine.

Now we need to add a signal in the images and capture it in the 3D Mesh. To add signal we are using an object detection model that detects a particular object in all the images and draw a small box on the center of the object as shown in the attached image. Hence the targeted objects are captured in every image and a box is drawn on it.

Once we use the images on which the signal i.e. the box is added. The mesh quality degrades and there are bumps on the areas where the box was drawn in the 2D images. We need to identify the issue and find a way to fix it in order to create a smooth mesh.

Thanks

2
Hello danimlk,

For buildModel operation which uses depth maps data as a source, I suggest to add the following lines for the vertex colors calculation:

Code: [Select]
colorizeModel = Metashape.Tasks.ColorizeModel()
colorizeModel.source_data =Metashape.DataSource.ImagesData
colorizeModel.apply(chunk)

Hi Alexey,

Thank for replying, I've added this to my script and it works now. The final output now has the color information.

Thanks for the help!  :)

3
Python and Java API / Exported Model does not have RGB color values
« on: June 11, 2021, 11:44:18 AM »
Hi Everyone,


I am trying to use the Metashape Python API to generate 3D Meshes using raw images. However, whenever I try to export the models they do not contain any color information. I have tried exporting them as OBJ and PLY files, however, both do not seem to contain the RGB color data in the final output. When I load the files into a viewer the model does not have any color information.

Here is the code I am using to generate the Meshes, feel free to point out if any part is missing:

Code: [Select]
    # create new project
doc = Metashape.Document()
doc.save(path = '/home/ubuntu/metashape/project')

# chunk to add photos
if len(doc.chunks):
    chunk = doc.chunk
else:
    chunk = doc.addChunk()


# loading images
image_list = os.listdir(photos_dir)
photo_list = list()
for photo in image_list:
    if photo.rsplit(".", 1)[1].lower() in ["jpg", "jpeg", "tif", "tiff"]:
        photo_list.append("/".join([photos_dir, photo]))

# add photos to chunk
chunk.addPhotos(photo_list)

# align photos 0- highest 1-high 2- medium
chunk.matchPhotos(downscale=0, generic_preselection=True, reference_preselection=False)


# align cameras
chunk.alignCameras()

# build DepthMaps 1- ultra high 2- high
chunk.buildDepthMaps(downscale=1, filter_mode=Metashape.AggressiveFiltering)


# build model
#face count/2 equals no. of vertices.
chunk.buildModel(surface_type=Metashape.Arbitrary, interpolation=Metashape.EnabledInterpolation,source_data=Metashape.DepthMapsData,face_count=Metashape.CustomFaceCount,face_count_custom=16000000,vertex_colors=True)
chunk.buildUV(mapping_mode=Metashape.GenericMapping)

# Add Texture
chunk.buildTexture(blending_mode=Metashape.MosaicBlending, texture_size=4096, fill_holes=True)

# export
chunk.exportModel(export_model_path, format =Metashape.ModelFormat.ModelFormatOBJ)
#chunk.exportModel(export_pointcloud_path, format =Metashape.ModelFormat.ModelFormatPLY)
print ('Processing complete')


Have also tried exporting the model right after the buildModel step but that too does not contain colors.


I have installed the python library using this command
Code: [Select]
python3 -m pip install <file_name>.whl and I have tried the following versions:

  • Metashape-1.7.3
  • Metashape-1.6.6

Both seem to be causing the same issue.

For reference, I have followed similar steps to create Meshes on the Windows Desktop version and the exported meshes turnout just fine.


System Info:
OS: Ubuntu 18.04
Python: 3.6


Looking forward to your help! :)


Regards

Pages: [1]