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)¶
解析给定``chunk.zip``文件中的XML。
- 参数:
project_folder (str)
project_name (str)
chunk_id (int or str) -- chunk.zip中块ID从0开始
skip_disabled (bool) -- 如果metashape项目中的块未启用,则返回None
return_label_only (bool) -- 仅解析chunk.label,默认值为False
- 返回类型:
chunk_dict or None
备注
如果一个项目路径看起来像:
/root/to/metashape/test_proj.psx,那么输入参数应该是:project_folder = "/root/to/metashape/"project_name = "test_proj"
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>
示例
数据准备
>>> 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'
然后解析块:
>>> 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 }