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 - assafge

Pages: [1]
1
Camera Calibration / align to reference targets
« on: August 13, 2024, 04:30:18 PM »
I'm trying to scan interiors, I've placed a calibration target on my window, took a lot of images - and the result is not aligned to my arbitrary coordinate system.

Code: [Select]
chunk.addPhotos(filenames=color_images)
accuracy = Metashape.Vector((0.001, 0.001, 0.001))
chunk.detectMarkers(target_type=Metashape.CircularTarget12bit, tolerance=50)
for marker in chunk.markers:
  if marker.label in yaml_data:
    marker.reference.location = Metashape.Vector(yaml_data[marker.label])
    marker.reference.enabled = True
    marker.reference.accuracy = accuracy
chunk.matchPhotos(downscale=0, generic_preselection=True, reference_preselection=True)
chunk.alignCameras(adaptive_fitting=True, reset_alignment=True)

and I'm checking the result using:
Code: [Select]
for m in chunk.markers:
    print(f'{m.label}: reference:({m.reference.location.x:.4f}, {m.reference.location.y:.4f}, {m.reference.location.z:.4f}), location:({m.position.x:.4f}, {m.position.y:.4f}, {m.position.z:.4f})')

which prints:
target 159: ref :(0.0000, 0.0000, 0.0000), loc:(0.3900, 0.4396, -2.7118)
target 160: ref :(0.0000, 0.0863, 0.0000), loc:(-0.0759, 0.4119, -2.7516)
target 161: ref :(0.0852, 0.0000, 0.0000), loc:(0.3779, 0.8753, -2.8706)

2
Hello all,
 have a pipeline of images alignment and coded markers detection, and the reference portion of the markers doesn't effect my axis.
Iv'e tried to optimize cameras, I've even added the markers detection before alignment, but the chunk's crs doesn't changed.

image1: the axis in the bottom right, the targets are aligned on my desired X axis
image2: target coordinates

3
Python and Java API / Re: PointCloud.renderPreview() geolocation?
« on: January 14, 2024, 11:08:37 AM »
Alexey, thanks for respond and the code, but it is a camera view, I would like to render some sort of ortho photo, but using point cloud instead of mosaicing pieces of images.

4
Python and Java API / Re: PointCloud.renderPreview() geolocation?
« on: January 11, 2024, 03:11:29 PM »
Hello Alexey,
I'm using renderPreview because I want a sort of ortho-photo, without the mosaicing of bits of images, I prefer an image with "holes". since it's not a virtual camera perspective, I thought that exported image is within the chunk.region. I've also exported the point cloud to pc3 file, and the points bounding box is not related to the rendered image.

In [1]: import numpy as np
   ...: import open3d as o3d

In [2]: pcd = o3d.io.read_point_cloud('/tmp/pc.pcd')

In [3]: out_arr = np.asarray(pcd.points)

In [4]: out_arr.min(axis=0)
Out[4]: array([2.49449300e+06, 6.96994850e+06, 3.73682281e+02])

In [5]: out_arr.min(axis=0)[0]
Out[5]: 2494493.0

5
Python and Java API / Re: PointCloud.renderPreview() geolocation?
« on: January 11, 2024, 02:00:29 PM »
the bottom left and the actual size that the preview image is representing, width for example.

6
Python and Java API / PointCloud.renderPreview() geolocation?
« on: January 11, 2024, 09:50:12 AM »
Hello,
I'm using the python API to create a preview image of the point cloud, and I can't figure out how to pin a point in the result image to geolocation. I thought that the result area of the image is the chunk.region, but the bottom left point does not seems to collide with the region's origin. how can I calculate the bounding box of the result image in my project crs (espg)?

Code: [Select]
center = chunk.center
shape = chunk.region.size
region_rect = [center[:2] - shape[:2]/2, center[:2] + shape[:2]/2,
                         center[:2] + np.array(shape[0], -shape[1])/2, center[:2] + np.array(-shape[0], shape[1])/2]
region_proj = np.array([chunk.crs.project(
    chunk.transform.matrix.mulp(Metashape.Vector(pt.tolist() + [z_mean])) for pt in region_rect])
bl = region_proj.min(axis=0)[:2]
chunk.buildDepthMaps(downscale=1)
chunk.buildPointCloud()
preview_im = chunk.point_cloud.renderPreview(width=int(shape[0]/res), height=int(shape[1]/res))
preview_im.save(str(out_pc_im.with_name('preview_point_cloud_metashape.png')))

Pages: [1]