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

Pages: [1] 2 3 ... 6
1
Python and Java API / Re: Extract the tie point positions (u and v)
« on: April 11, 2023, 01:41:19 AM »
Thanks that works great.

I have modified the code to write tie points to a csv file, including camera label and date/time:

Code: [Select]
import Metashape
from PyQt5.QtWidgets import QFileDialog
import os

def get_tie_points(camera1, camera2, chunk):

    if not camera1.transform:
        Metashape.app.messageBox("Not aligned camera selected.")
        return 0
    if not camera2.transform:
        Metashape.app.messageBox("Not aligned camera selected.")
        return 0
       
    projections = chunk.point_cloud.projections
    points = chunk.point_cloud.points
    tracks = chunk.point_cloud.tracks
    npoints = len(points)
    point_ids = [-1] * len(chunk.point_cloud.tracks)
    for point_id in range(0, npoints):
        point_ids[points[point_id].track_id] = point_id
    camera_matches_valid = dict()
   
    tie_points = dict()
    tie_points[camera1] = dict()
    tie_points[camera2] = dict()
       
    for camera in [camera1, camera2]:
        T = camera.transform.inv()
        calib = camera.sensor.calibration
        valid_matches = set()
        for proj in projections[camera]:
            track_id = proj.track_id
            point_id = point_ids[track_id]

            if point_id < 0:
                continue
            if not points[point_id].valid: #skipping invalid points
                continue
            valid_matches.add(point_id)
            tie_points[camera][point_id] = proj.coord
           
        camera_matches_valid[camera] = valid_matches
    valid = camera_matches_valid[camera1].intersection(camera_matches_valid[camera2])
   
    tie_point_output = list()
    for point_id in valid:
        tie_point_output.append((tie_points[camera1][point_id], tie_points[camera2][point_id]))
    if not len(tie_point_output):
        return None
    return tie_point_output

chunk = Metashape.app.document.chunk
project_path = Metashape.app.document.path
common_tiepoints = get_tie_points(chunk.cameras[0], chunk.cameras[1], chunk)

def save_tiepoints_to_csv(tiepoints):
    camera1 = chunk.cameras[0]
    camera2 = chunk.cameras[1]
    filename = f"{camera1.label}_{camera2.label}.csv"
    parent_dir = os.path.dirname(project_path)
    filepath = os.path.join(parent_dir, filename)
   
    if not filepath:
        return

    with open(filepath, 'w') as f:
        # write the tiepoints to the CSV file
        f.write('Camera1, DateTime1, x1, y1, Camera2, DateTime2, x2, y2\n')
        for tiepoint in tiepoints:
            x1, y1 = tiepoint[0]
            x2, y2 = tiepoint[1]
            camera1_datetime = chunk.cameras[0].photo.meta['Exif/DateTime']
            camera2_datetime = chunk.cameras[1].photo.meta['Exif/DateTime']
            f.write(f'{chunk.cameras[0].label},{camera1_datetime},{x1},{y1},{chunk.cameras[1].label},{camera2_datetime},{x2},{y2}\n')
                 
chunk = Metashape.app.document.chunk
common_tiepoints = get_tie_points(chunk.cameras[0], chunk.cameras[1], chunk)

if common_tiepoints:
    save_tiepoints_to_csv(common_tiepoints)
else:
    print("No common tiepoints found.")

I would also like to include the point ids and raw digital number/color for the grayscale band. Is that possible?

2
General / Re: export tie points as XYZ
« on: April 10, 2023, 12:48:54 PM »
Was this solved?

3
General / point colors and digital numbers
« on: April 10, 2023, 12:46:35 PM »
Hi there,

When exporting points, are the point colors the same as the raw digital numbers?

cheers,

Javier

4
Python and Java API / Re: Extract the tie point positions (u and v)
« on: April 05, 2023, 11:24:23 PM »
Thanks so much. Should I be selecting or being asked for a pair of cameras?

5
Python and Java API / Re: Extract the tie point positions (u and v)
« on: April 05, 2023, 02:48:48 AM »
Hi Alexey,

I get the following error:  an unindent does not match any outer indentation level (line 47).

Tried modifying the indentation but still no success.

cheers,

Javier

6
General / Export orthomosaic + DSM
« on: January 09, 2023, 09:03:09 AM »
Hi there,

Is there a way to exporting the ortho and DSM together as a 4-band raster?

cheers,

Javier

7
General / split dense point cloud
« on: June 05, 2022, 12:42:32 AM »
Hi there,

Why/when are the "split in blocks" and "clip to boundary shapes" greyed out when trying to export a dense point cloud?

cheers

8
General / Re: Metashape Professional and Coral Reef Measurement
« on: June 10, 2021, 10:17:09 AM »
Hi Simon,

Amazing work!  I am sure using UWIS GPS is improving processing performance for large projects but are you also finding significant accuracy improvements?

cheers,

Javier

9
General / Re: reset region using shapefile
« on: April 29, 2021, 01:01:08 AM »
Thanks Alexey.

I mean cropping the bounding box extent to a polygon shapefile extent OR cropping the sparse point cloud to the extent of the polygon shapefile.

10
General / reset region using shapefile
« on: April 28, 2021, 05:22:35 AM »
As far as I understand, the Reset Region option is currently based on the sparse cloud only. I am trying to align multiple surveys (different times) to the same region extent.

Is there away to select/crop points in the sparse point cloud OR reset the region using a shapefile? If not, is there any workaround?

cheers,

Javier   

11
General / Re: orthomosaic from sparse vs dense cloud
« on: January 21, 2021, 04:47:29 PM »
Thanks Alexey. See attached.

12
General / orthomosaic from sparse vs dense cloud
« on: January 20, 2021, 11:26:29 PM »
Hi there,

Im reconstructing a highly complex/very-high res vegetation scene from handheld photos.

Just wondering why the quality of the orthomosaic from the (cleaned) sparse point cloud (see attached sparse) is much better than that from depth maps or (cleaned) dense point cloud (see attached dense).

Is it just that the sparse mosaic is smoothed out and looks better but the dense mosaic is more accurate and has better dealt with distortions?

cheers,

Javier 

13
How much overlap/distance between 360 panoramas would you need for 3D reconstructions?

14
Feature Requests / Define planar projection in batch
« on: November 11, 2020, 09:52:29 AM »
is there a workaround to define a planar projection when running Build DEM / Build Orthomosaic in batch?

15
General / region orientation
« on: November 09, 2020, 10:55:57 AM »

Hi all,

Im trying align the orientation of the orthomosaic using markers with no success. I have captured a "3D" scale bar with 6 markers: 1 - 2 defines the vertical axis and 9 - 10 and 7 - 8 the horizontal axis (see attached picture).

I would like to build a DEM with the correct orientation and export the orthomosaic looking from the top.

Ive been trying to build the DEM using planar/markers but if I select horizontal 7-8 (or 8-7) then the orthomosaic is oriented vertically and if I select vertical 1-2 (or 2-1) I get an empty DEM.

Any suggestions?         

Pages: [1] 2 3 ... 6