The following explains the workflow of a drone video sensing application: the code orchestrates an end-to-end pipeline for processing drone-captured videos and transforming them into searchable, semantically rich insights using Azure's AI capabilities.
It starts by using Azure Video Indexer to:
• Authenticate via API keys and retrieve an access token.
• Upload a video either from a local file or from a URL.
• Trigger indexing to extract metadata like keyframes, themes, and highlights.
• Optionally, it can reindex a video and monitor the indexing status.
Once indexed, the workflow:
• Parses insights to extract meaningful segments.
• Creates a custom project around those segments.
• Renders a new video that highlights specific themes and keyframes.
• Downloads the rendered output for further processing.
With OpenCV, it:
• Downloads the video into memory.
• Extracts frames one by one.
• Each frame is optionally saved locally or uploaded as an image blob to Azure Storage, structured by frame number and path conventions.
For every uploaded frame:
• Generates vector embeddings using the Azure AI Vision vectorization API.
• Performs semantic analysis to extract:
o Tags
o Captions
o Detected objects
o Smart crops
o Dense captions
o Text reading
o People detection
• The results are packaged into structured descriptions.
If enabled:
• It dives into dense captions from the image analysis.
• Extracts bounding boxes for individual objects.
• Clips regions of the image based on those boxes.
• Vectorizes the clipped image.
• Re-analyzes it semantically.
• Uploads object-level insights as new searchable entities.
Finally, every analyzed frame (and optionally, detected objects) is:
• Packed as a document with its ID, vector, bounding box, and description.
• Uploaded to Azure AI Search, making the insights retrievable via semantic queries.
This code is modular, retry-safe, and production-oriented, with detailed logging and fallback mechanisms. Overall,
def indexing_workflow(source_video_url, account_id = None):
if not account_id:
account_id = settings.video_indexer_default_account_id
video_url = index_and_download_video(account_id = account_id, video_url = source_video_url)
if not video_url:
return
extract_and_upload_frames(video_url)
vector_descriptions = vectorize_extracted_frames(video_url)
client = get_search_client()
frame_number = 0
source_sas_url = get_image_blob_url(video_sas_url, frame_number)
for vector, description in vector_descriptions:
form_and_upload_document(client, account_id, frame_number, vector, description, source_sas_url, deep = False)
frame_number += 1
No comments:
Post a Comment