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.0.tar.gz (12.8 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.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for photogrammetry_target_locator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 68cb7b9d37453e733251dcdafcdb225d4ea41b3843a720f0f744ae91f36c146d
MD5 88dbfab2816217a8847afa64622b612e
BLAKE2b-256 8c28169bb2d4570ab472019bc261591d0f2b26120cf45e30235999e3e50e2857

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for photogrammetry_target_locator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64f0d7d4928af222a391245d332a5526fd680eadf0d0f496363a98700ad31537
MD5 c8e6afe92331c7a2db73c11cfed77cc8
BLAKE2b-256 a77ccd1d82f369ee2d4fad8627c00d6d9b3ea8bb10cd1fd9583fdc206b2a5c73

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