Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drone Image Processing using Open Drone Map (ODM) #227

Merged
merged 22 commits into from
Sep 23, 2024

Conversation

nrjadkry
Copy link
Collaborator

@nrjadkry nrjadkry commented Sep 19, 2024

Overview

This pull request introduces a comprehensive image processing pipeline that:

  • Downloads images from MinIO (S3-compatible storage).
  • Processes the images using NodeODM (via PyODM).
  • Uploads the processed results as a ZIP file back to MinIO.
  • Integrates the processing into a FastAPI application using background tasks.
  • Provides endpoints to initiate processing and check task status.

Key Features

DroneImageProcessor Class: Manages the entire processing workflow, including downloading images, processing with NodeODM, and uploading results.

S3 Integration: Uses existing functions in s3.py to download the images and upload the processed imagery back to MinIO

FastAPI Background Tasks: Implements background processing to keep the API responsive.

Task Status Tracking: Introduces a TaskManager to track the status of processing tasks.

API Endpoints:
POST process_imagery/{project_id}/{task_id}/ Initiates processing

@github-actions github-actions bot added the backend Related to backend code label Sep 19, 2024
@nrjadkry nrjadkry added the odm label Sep 19, 2024
@nrjadkry nrjadkry self-assigned this Sep 19, 2024
Copy link
Member

@spwoodcock spwoodcock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 🙌

This should function is it is, but I left some comments for optimisation if needed.

There are many areas we can optimise for sure, but it's good to get a first version working before over-optimising 😁

src/backend/app/projects/image_processing.py Outdated Show resolved Hide resolved
src/backend/app/projects/image_processing.py Outdated Show resolved Hide resolved
src/backend/app/projects/image_processing.py Outdated Show resolved Hide resolved
objects = list_objects_from_bucket(bucket_name, prefix)

# Process images concurrently
with ThreadPoolExecutor() as executor:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend asyncio over threading for this type of downloading onto a filesystem.

asyncio.gather would work nicely and be less blocking (using a single thread via coroutines).

Example from FMTM:

https://github.com/hotosm/fmtm/blob/35e7240cc78d62c288f0ea60aef0eb7bde8beaed/src/backend/app/central/central_crud.py#L560-L570

But not this would mean you need to update functions to async and use await

settings.S3_BUCKET_NAME, f"projects/{project_id}/dem.tif", dem_path
)
try:
get_file_from_bucket(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you rightly say below, once everything is working and we are happy, this definitely needs to be changed getting elevation data by querying the cloud optimised DEM. A DEM can be quite large, so downloading every time we process imagery is very inefficient

@nrjadkry nrjadkry merged commit 5733871 into develop Sep 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code odm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants