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:
- Backward Projection ROI to original images (
Backward Projector
). - Crop ROI on GeoTiff Maps (DOM & DSM) and Point Cloud (
ROI Cropper
). - 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:
- package main (for users)
- numpy: https://numpy.org/
- matplotlib:https://matplotlib.org/
- pillow: https://github.com/python-pillow/Pillow
- pyproj: https://github.com/pyproj4/pyproj
- tifffile: https://github.com/cgohlke/tifffile
- imagecodecs: https://github.com/cgohlke/imagecodecs
- shapely: https://github.com/shapely/shapely
- laspy/lasrs/lasio: https://github.com/laspy/laspy
- plyfile: https://github.com/dranjan/python-plyfile
- pyshp: https://github.com/GeospatialPython/pyshp
- tabulate: https://github.com/astanin/python-tabulate
- tqdm: https://github.com/tqdm/tqdm
- gdown: https://github.com/wkentaro/gdown
- package documentation (for developers)
- sphinx: https://github.com/sphinx-doc/sphinx
- nbsphinx: https://github.com/spatialaudio/nbsphinx
- sphinx-gallery: https://github.com/sphinx-gallery/sphinx-gallery
- sphinx-inline-tabs: https://github.com/pradyunsg/sphinx-inline-tabs
- sphinx-intl: https://github.com/sphinx-doc/sphinx-intl
- sphinx-rtc-theme: https://github.com/readthedocs/sphinx_rtd_theme
- furo: https://github.com/pradyunsg/furo
- package testing and releasing (for developers)
- pytest: https://github.com/pytest-dev/pytest
- packaging: https://github.com/pypa/packaging
- wheel: https://github.com/pypa/wheel
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for easyidp-2.0.0.dev3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 729e9ea27c19317dfc3f2d126bbec4620a8b9f0728c814b5f148eaf02dd28d57 |
|
MD5 | 4b3aed5ede205509427285188003b899 |
|
BLAKE2b-256 | 25f1fbc17f8a9025379da81cdbd982792be82d36c65a5992785fc7657f23264b |