easyidp.metashape.read_chunk_zip#

easyidp.metashape.read_chunk_zip(project_folder, project_name, chunk_id, skip_disabled=False, return_label_only=False, raw_img_folder=None)#

parse xml in the given chunk.zip file.

Parameters:
  • project_folder (str) –

  • project_name (str) –

  • chunk_id (int or str) – the chunk id start from 0 of chunk.zip

  • skip_disabled (bool) – return None if chunk enabled is False in metashape project

  • return_label_only (bool) – Only parse chunk.label, by default False

Return type:

chunk_dict or None

Notes

If one project path look likes: /root/to/metashape/test_proj.psx, then the input parameter should be:

  • project_folder = "/root/to/metashape/"

  • project_name = "test_proj"

Example for xml_str:

<chunk version="1.2.0" label="170525" enabled="true">
<sensors next_id="1">
    <sensor id="0" label="FC550, DJI MFT 15mm F1.7 ASPH (15mm)" type="frame">
    ...  -> _decode_sensor_tag()
    </sensor>
    ...  -> for loop in this function
</sensors>

<cameras next_id="266" next_group_id="0">
    <camera id="0" sensor_id="0" label="DJI_0151">
    ... -> _decode_camera_tag()
    </camera>
    ...  -> for loop in this function
</cameras>

<frames next_id="1">
    <frame id="0" path="0/frame.zip"/>
</frames>

<reference>GEOGCS["WGS 84",DATUM["World Geodetic System 1984",], ..., AUTHORITY["EPSG","4326"]]</reference>

<transform>
    ...  -> _decode_chunk_transform_tag()
<transform>

<region>
    <center>-8.1800672545192263e+00 -2.6103071594817338e+00 -1.0706980639382815e+01</center>
    <size>3.3381093645095824e+01 2.3577857828140260e+01 7.2410767078399658e+00</size>
    <R>-9.8317886026354417e-01 ...  9.9841729020145376e-01</R>   // 9 numbers
</region>

Example

Data prepare

>>> import easyidp as idp
>>> test_data = idp.data.TestData()

>>> project_folder = test_data.metashape.lotus_psx.parents[0]
PosixPath('/Users/<user>/Library/Application Support/easyidp.data/data_for_tests/metashape')
>>> project_name = 'Lotus'

Then parse the chunk:

>>> idp.metashape.read_chunk_zip(project_folder, project_name, chunk_id=0)
{
    'label': 'Chunk 1',

    'enabled': True,

    'transform': <easyidp.reconstruct.ChunkTransform object at 0x7fe2b81bf370>,

    'sensors': <easyidp.Container> with 1 items
               [0]     FC550, DJI MFT 15mm F1.7 ASPH (15mm)
               <easyidp.reconstruct.Sensor object at 0x7fe2a873a040>,

    'photos': <easyidp.Container> with 151 items
              [0]     DJI_0422
              <easyidp.reconstruct.Photo object at 0x7fe2a873a9a0>
              [1]     DJI_0423
              <easyidp.reconstruct.Photo object at 0x7fe2a873a130>
              ...
              [149]   DJI_0571
              <easyidp.reconstruct.Photo object at 0x7fe298e82820>
              [150]   DJI_0572
              <easyidp.reconstruct.Photo object at 0x7fe298e82850>,

    'crs': <Geographic 2D CRS: EPSG:4326>
           Name: WGS 84
           Axis Info [ellipsoidal]:
           - Lat[north]: Geodetic latitude (degree)
           - Lon[east]: Geodetic longitude (degree)
           Area of Use:
           - name: World.
           - bounds: (-180.0, -90.0, 180.0, 90.0)
           Datum: World Geodetic System 1984 ensemble
           - Ellipsoid: WGS 84
           - Prime Meridian: Greenwich
}