Monday, October 6, 2025

 The idea behind offloading drone video sensing analytics is that commodity LLMs available online can step in to do even regular counting tasks that otherwise would have required custom model or image processing techniques and analytics. For example, to count the number of unoccupied spots in a point-of-time frame from an aerial drone video, can now be requested as follows:

import requests

import base64

import os

# Read and encode image as base64

image_path = "parking2.jpg"

perplexity_api_key = os.getenv("PERPLEXITY_API_KEY")

try:

    with open(image_path, "rb") as image_file:

        base64_image = base64.b64encode(image_file.read()).decode("utf-8")

    image_data_uri = f"data:image/jpg;base64,{base64_image}" # Ensure correct MIME type

except FileNotFoundError:

    print("Error: Image file not found.")

    exit()

# API request payload

url = "https://api.perplexity.ai/chat/completions"

headers = {

    "Authorization": f"Bearer {perplexity_api_key}",

    "accept": "application/json",

    "content-type": "application/json"

}

payload = {

    "model": "sonar-pro",

    "messages": [

        {

            "role": "user",

            "content": [

                {"type": "text", "text": "How many unoccupied parking spots are there in this image?"},

                {"type": "image_url", "image_url": {"url": image_data_uri}}

            ]

        }

    ],

    "stream": False

}

try:

    response = requests.post(url, headers=headers, json=payload)

    response.raise_for_status() # Raise an exception for bad status codes

    result = response.json()

    print(result)

    print(result["choices"][0]["message"]["content"]

except requests.exceptions.RequestException as e:

    print(f"API Request failed: {e}")

With input as:

And with results as:

There are 2 unoccupied parking spots visible in the parking lot at the upper right of the image. All other parking spots are occupied by cars.

And with the full json response as:

{'id': 'ca0ca941-5daa-4308-a80b-8db31fc86ab0', 'model': 'sonar-pro', 'created': 1757643820, 'usage': {'prompt_tokens': 1240, 'completion_tokens': 31, 'total_tokens': 1271, 'search_context_size': 'low', 'cost': {'input_tokens_cost': 0.004, 'output_tokens_cost': 0.0, 'request_cost': 0.006, 'total_cost': 0.01}}, 'citations': ['https://www.youtube.com/watch?v=MeSeuzBhq2E', 'https://www.youtube.com/watch?v=caKnQlCMIYI', 'https://blog.roboflow.com/build-a-parking-lot-monitoring-system/', 'https://cseweb.ucsd.edu/classes/wi07/cse190-a/reports/ntrue.pdf', 'https://www.kaggle.com/datasets/iasadpanwhar/parking-lot-detection-counter', 'https://www.shutterstock.com/search/vacant-car-parking-space', 'https://parkinglogix.com/multi-lots/', 'https://www.istockphoto.com/photos/empty-parking-space', 'https://www.arcgis.com/home/item.html?id=5b8e047f11324775832550c6bab19d2b', 'https://www.shutterstock.com/search/empty-parking-slot'], 'search_results': [{'title': 'Parking Space detection using OpenCV Python', 'url': 'https://www.youtube.com/watch?v=MeSeuzBhq2E', 'date': '2022-11-20', 'last_updated': '2025-08-22', 'snippet': 'This project finds outs the count of empty and occupied parking spaces in a car parking lot using digital image processing techniques from ...'}, {'title': 'Parking Space Counter using OpenCV Python', 'url': 'https://www.youtube.com/watch?v=caKnQlCMIYI', 'date': '2021-12-26', 'last_updated': '2025-07-31', 'snippet': 'In this tutorial, we are going to create a Parking Space Counter. We will find how many total cars are present and how many spaces are ...'}, {'title': 'How to Build a Parking Lot Monitoring System with ...', 'url': 'https://blog.roboflow.com/build-a-parking-lot-monitoring-system/', 'date': '2024-01-17', 'last_updated': '2025-09-11', 'snippet': "We'll go through the steps of creating a system that allows users to identify the number of empty and occupied spots in a parking space, and visualize where ..."}, {'title': 'Vacant Parking Space Detection in Static Images', 'url': 'https://cseweb.ucsd.edu/classes/wi07/cse190-a/reports/ntrue.pdf', 'date': None, 'last_updated': '2025-04-27', 'snippet': 'by N True · Cited by 133 — Current parking space vacancy detection systems use simple trip sensors at the entry and exit points of parking lots. Unfortunately, this type of system ...'}, {'title': 'Parking_Lot_Detection_Counter', 'url': 'https://www.kaggle.com/datasets/iasadpanwhar/parking-lot-detection-counter', 'date': None, 'last_updated': None, 'snippet': 'This dataset is designed for the task of detecting and counting empty and occupied parking spots in a parking area. It includes images, a mask image, a video, ...'}, {'title': 'Vacant Car Parking Space royalty-free images', 'url': 'https://www.shutterstock.com/search/vacant-car-parking-space', 'date': None, 'last_updated': '2024-10-06', 'snippet': 'Find 8+ Thousand Vacant Car Parking Space stock images in HD and millions of other royalty-free stock photos, 3D objects, illustrations and vectors in the ...'}, {'title': 'Parking Counter System | Multi-Lots', 'url': 'https://parkinglogix.com/multi-lots/', 'date': '2023-03-15', 'last_updated': '2025-09-09', 'snippet': 'With our parking space counter systems, you can keep track of how many spots are left in multiple lots from a single interface.'}, {'title': 'Empty Parking Space Pictures, Images and Stock Photos', 'url': 'https://www.istockphoto.com/photos/empty-parking-space', 'date': '2020-10-13', 'last_updated': '2025-04-30', 'snippet': 'Browse 5,900+ empty parking space stock photos and images available, or search for parking lot or stolen car to find more great stock photos and pictures.'}, {'title': 'Parking Spot Detection - USA - Overview', 'url': 'https://www.arcgis.com/home/item.html?id=5b8e047f11324775832550c6bab19d2b', 'date': None, 'last_updated': None, 'snippet': 'This deep learning model is used to detect and classify parking spots in high resolution drone or aerial imagery.'}, {'title': 'Empty Parking Slot royalty-free images', 'url': 'https://www.shutterstock.com/search/empty-parking-slot', 'date': None, 'last_updated': '2024-10-19', 'snippet': 'Find 6+ Thousand Empty Parking Slot stock images in HD and millions of other royalty-free stock photos, 3D objects, illustrations and vectors in the ...'}], 'object': 'chat.completion', 'choices': [{'index': 0, 'finish_reason': 'stop', 'message': {'role': 'assistant', 'content': 'There are 2 unoccupied parking spots visible in the parking lot at the upper right of the image. All other parking spots are occupied by cars.'}, 'delta': {'role': 'assistant', 'content': ''}}]}


No comments:

Post a Comment