PIXELBANKv9.1.0
Menu

You are given multiple observations (2D point measurements) of 3D points from different cameras, and need to compute the total bundle adjustment cost.

The total cost is the sum of squared reprojection errors across all observations:

C=βˆ‘i,jβˆ₯Ο€(RjXi+tj)βˆ’xijβˆ₯2C = \sum_{i,j} \|\pi(R_j X_i + t_j) - x_{ij}\|^2

Where:

  • XiX_i is the i-th 3D point
  • Rj,tjR_j, t_j are the j-th camera's rotation and translation
  • xijx_{ij} is the observation of point i in camera j

This is the objective function that bundle adjustment minimizes.

Example:

Input:
observations = [(0, 0, [0, 0])]
points = [[0, 0, 10]]
cameras = [[0, 0, 0]]
focal = 1
Output:
0.0
Reasoning:

Single observation: camera 0 sees point 0 at (0, 0)

  1. Get point: [0, 0, 10]
  2. Get camera translation: [0, 0, 0]
  3. Transform: [0+0, 0+0, 10+0] = [0, 0, 10]
  4. Project: u = 1Γ—0/10 = 0, v = 1Γ—0/10 = 0
  5. Error: (0-0)Β² + (0-0)Β² = 0

Total cost = 0.0

Constraints:

  • observations: list of (camera_idx, point_idx, [u, v]) tuples
  • points: list of [X, Y, Z] for each 3D point
  • cameras: list of [tx, ty, tz] translation for each camera
  • focal: focal length
  • Assume identity rotation for all cameras
  • Return total cost rounded to 4 decimal places
πŸ”’

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Total Bundle Cost - Medium | PixelBank