Skip to main content

A handy tool for dealing with region of interest (ROI) on the image reconstruction (Metashape & Pix4D) outputs, mainly in agriculture applications

Project description

EasyIDP (Easy Intermediate Data Processor), A handy tool for dealing with region of interest (ROI) on the image reconstruction (Metashape & Pix4D) outputs, mainly in agriculture applications. It provides the following functions:

  1. Backward Projection ROI to original images (Backward Projector).
  2. Crop ROI on GeoTiff Maps (DOM & DSM) and Point Cloud (ROI Cropper).
  3. Save cropped results to corresponding files (ROI Saver).

This project tried to use packges based on pure-python, instead of installing some heavy packages (Open3D, OpenCV) and hard to install packages (GDAL dependices) for one or two individual functions. This may cause efficiency loss and differences in coding habit.

Documentation

Please check Official Documents for full documentations. And please also use the Github Discussion when you meet any problems.

Quick Start Examples (Processing)

You can install the packages by PyPi:

pip install easyidp

And import the packages in your python code:

import easyidp as idp

Before doing the following example, please understand the basic pipeline for image 3D reconstruction by Pix4D or Metashape. And know how to export the DOM, DSM (*.tiff), and Point cloud (*.ply). Also require some basic knowledge about GIS shapefile format (*.shp).

Please note, if you see this sentence, it means the following examples are not suppported yet.

1. Read ROI
roi = idp.ROI("xxxx.shp")  # lon and lat 2D info
  
# get z values from DSM
roi.get_z_from_dsm("xxxx_dsm.tiff")  # add height 3D info

The 2D roi can be used to crop the DOM, DSM, and point cloud (2.crop by ROI). While the 3D roi can be used for Backward projection (4. Backward projection)

2. Crop by ROI

Read the DOM and DSM Geotiff Maps

dom = idp.GeoTiff("xxx_dom.tif")
dsm = idp.GeoTiff("xxx_dsm.tif")

Read point cloud data

ply = idp.PointCloud("xxx_pcd.ply")

crop the region of interest from ROI:

dom_parts = roi.crop(dom)
dsm_parts = roi.crop(dsm)
pcd_parts = roi.crop(ply)

If you want to save these crops to given folder:

dom_parts = roi.crop(dom, save_folder="./crop_dom")
dsm_parts = roi.crop(dsm, save_folder="./crop_dsm")
pcd_parts = roi.crop(ply, save_folder="./crop_pcd")
3. Read Reconstruction projects

Add the reconstruction projects to processing pools (different flight time for the same field):

proj = idp.ProjectPool()
proj.add_pix4d(["date1.p4d", "date2.p4d", ...])
proj.add_metashape(["date1.psx", "date2.psx", ...])

Then you can specify each chunk by:

p1 = proj[0]
# or
p1 = proj["chunk_or_project_name"]
4. Backward Projection
>>> img_dict = roi.back2raw(chunk1)

Then check the results:

# find the raw image name list
>>> img_dict.keys()   
dict_keys(['DJI_0177.JPG', 'DJI_0178.JPG', 'DJI_0179.JPG', 'DJI_0180.JPG', ... ]

# the roi pixel coordinate on that image
>>> img_dict['DJI_0177.JPG'] 
array([[ 779,  902],
       [1043,  846],
       [1099, 1110],
       [ 834, 1166],
       [ 779,  902]])

Save backward projected images

img_dict = roi.back2raw(chunk1, save_folder="folder/to/put/results/")

References

Please cite this paper if this project helps you:

@Article{wang_easyidp_2021,
AUTHOR = {Wang, Haozhou and Duan, Yulin and Shi, Yun and Kato, Yoichiro and Ninomiya, Seish and Guo, Wei},
TITLE = {EasyIDP: A Python Package for Intermediate Data Processing in UAV-Based Plant Phenotyping},
JOURNAL = {Remote Sensing},
VOLUME = {13},
YEAR = {2021},
NUMBER = {13},
ARTICLE-NUMBER = {2622},
URL = {https://www.mdpi.com/2072-4292/13/13/2622},
ISSN = {2072-4292},
DOI = {10.3390/rs13132622}
}

We also thanks the benefits from the following open source projects:

This project was partially funded by:

  • the JST AIP Acceleration Research “Studies of CPS platform to raise big-data-driven AI agriculture”;
  • the SICORP Program JPMJSC16H2;
  • CREST Programs JPMJCR16O2 and JPMJCR16O1;
  • the International Science & Technology Innovation Program of Chinese Academy of Agricultural Sciences (CAASTIP);
  • the National Natural Science Foundation of China U19A2061.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easyidp-2.0.0.dev2.tar.gz (81.6 kB view hashes)

Uploaded Source

Built Distribution

easyidp-2.0.0.dev2-py3-none-any.whl (88.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page