Skip to main content

Calculate real-world coordinates from camera images

Project description

Photogrammetry Target Locator

This tool calculates the real-world geographic coordinates (latitude, longitude, altitude) of a target point identified in a camera image, based on the camera's position, orientation, and intrinsic parameters.

Features

  • Camera position and orientation input
  • Camera intrinsic parameter configuration with FOV angles
  • Target pixel coordinate specification
  • Terrain elevation data from USGS Elevation Point Query Service (EPQS)
  • WGS84 coordinate system
  • Configurable via JSON

Installation

  1. Clone this repository
  2. Install the required dependencies:
pip install -r requirements.txt

Usage

  1. Configure your camera and target parameters in config.json
  2. Run the program:
python main.py

Alternatively, you can specify a different configuration file:

python main.py path/to/your/config.json

Configuration

The configuration file (config.json) contains the following parameters:

  • Camera Position:
    • Latitude, longitude, altitude
    • Heading (0-360 degrees, clockwise from North)
  • Camera Orientation: Roll, pitch, yaw (in degrees)
  • Camera Intrinsics:
    • Field of view (horizontal and vertical angles in degrees)
    • Principal point (optional, defaults to image center)
    • Sensor size (width and height in pixels)
  • Target: Pixel coordinates in the image

Example configuration:

{
  "camera": {
    "position": {
      "latitude": 37.7749,
      "longitude": -122.4194,
      "altitude": 100.0,
      "heading": 45.0
    },
    "orientation": {
      "roll": 0.0,
      "pitch": -120.0,
      "yaw": 0.0
    },
    "intrinsics": {
      "field_of_view": {
        "horizontal_degrees": 65.5,
        "vertical_degrees": 46.4
      },
      "sensor_size": {
        "width": 1920,
        "height": 1080
      }
    }
  },
  "target": {
    "pixel_coordinates": {
      "x": 1200,
      "y": 700
    }
  }
}

Position vs. Orientation

The difference between heading and yaw:

  • Heading: The compass direction the camera platform is facing (0-360° clockwise from North)
  • Yaw: The rotation of the camera relative to the platform's heading

For example, if your drone is flying north (heading = 0°) but the camera is rotated 45° to the right, you would set heading = 0° and yaw = 45°. The effective camera direction would be northeast.

Terrain Elevation

The program uses the USGS Elevation Point Query Service (EPQS) to provide accurate elevation data, which offers several advantages:

  • Real-time data: Retrieves elevation data on demand
  • No local files: No need to download and manage large DEM files
  • Up-to-date information: Access to the most current elevation data
  • Wide coverage: Covers the United States and many international locations

The system automatically handles:

  • API request caching to improve performance
  • Rate limiting to avoid service throttling
  • Multiple retries for intermittent connectivity issues
  • Graceful fallback to a default height of 0.0 meters if the service is unavailable

About USGS Elevation Point Query Service (EPQS)

The USGS EPQS provides elevation data for any point in the United States and many international locations. The service:

  • Is free to use (with reasonable rate limits)
  • Provides data from multiple elevation datasets
  • Returns elevations in meters or feet
  • Has a REST API that's easy to work with

Output

The program outputs the calculated target coordinates to the console and saves them to a JSON file with the same name as the input configuration file, but with _result.json appended.

Example output:

Target coordinates:
  Latitude:  37.77375463 degrees
  Longitude: -122.42089574 degrees
  Altitude:  105.32 meters

Results saved to config_result.json

The altitude value reflects the accurate terrain height at the target location based on USGS elevation data.

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

photogrammetry_target_locator-0.1.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

photogrammetry_target_locator-0.1.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file photogrammetry_target_locator-0.1.2.tar.gz.

File metadata

File hashes

Hashes for photogrammetry_target_locator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 284063ef2972dd83ba6dfc98fd5420334eadeedc9bf7f4d9e68b0b7c0e4cfccb
MD5 6c8ea5ad83cc1fbb0d49f1276a78d337
BLAKE2b-256 7d3ed971be6b9de5dda1d6533de5a71990a9b5356c29021f192de28f77a87da0

See more details on using hashes here.

File details

Details for the file photogrammetry_target_locator-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for photogrammetry_target_locator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f249e9d1c7abce77a96e2f96ec464ba0c4f885ebc451c72c0e44777a6f939aa0
MD5 987652ab66eebae33f4dce34c3301079
BLAKE2b-256 0c9805a2488df55754d37ab89ff021bd117c364812470e9d7854d7c8b41b6bd9

See more details on using hashes here.

Supported by

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