# How to Control Camera Optimization Iterations in the LingBot‑MAP Demo

> Control camera optimization iterations in the LingBot-MAP demo by setting a command-line flag for refinement passes during inference. Optimize your camera poses.

- Repository: [Robbyant/lingbot-map](https://github.com/Robbyant/lingbot-map)
- Tags: how-to-guide
- Published: 2026-07-25

---

**The demo script exposes a command‑line flag that sets how many refinement passes are performed on the estimated camera poses during inference.**

The LingBot‑MAP repository provides tools for geometric camera tracking and mapping in robotics applications. When running inference through the demo interface, you can tune **camera optimization iterations** to trade off between pose accuracy and processing speed. This parameter directly controls how many refinement passes the solver applies to camera poses and intrinsic parameters during the mapping pipeline.

## The `--camera-num-iterations` Parameter

The primary interface for controlling optimization depth is the `--camera-num-iterations` argument. This integer value determines the number of iterative refinement steps applied to camera parameters during inference.

- **Type**: `int`
- **Default**: `4`
- **Description**: Number of optimization iterations applied to camera parameters (pose and intrinsics) during demo execution

According to the source code, increasing this value can improve pose quality, though it comes at the cost of additional compute time.

## Source Code Implementation

The parameter is implemented in the benchmarking utilities and consumed by the main demo entry point.

### Argument Definition

In [`scripts/benchmark_gct_memory.py`](https://github.com/Robbyant/lingbot-map/blob/main/scripts/benchmark_gct_memory.py), the argument is defined at lines 65–68. This implementation allows both the benchmarking suite and the demo script to accept the iteration count via command line.

### Demo Integration

The [`demo.py`](https://github.com/Robbyant/lingbot-map/blob/main/demo.py) entry point forwards this argument to the underlying model inference code. When specified, the value overrides the default optimization schedule, ensuring the solver runs for the exact number of iterations requested.

## Usage Examples

You can specify custom iteration counts when invoking the demo from the command line.

Run with the default 4 iterations:

```bash
python demo.py --model_path model.pt --image_folder ./images

```

Run with increased refinement (10 iterations):

```bash
python demo.py --model_path model.pt --image_folder ./images --camera-num-iterations 10

```

Run with reduced iterations for faster processing:

```bash
python demo.py --model_path model.pt --image_folder ./images --camera-num-iterations 2

```

## Performance Considerations

Adjusting **camera optimization iterations** directly impacts the speed-accuracy trade-off in the LingBot‑MAP pipeline. While the default value of `4` provides sufficient accuracy for most scenarios, challenging sequences with rapid motion or low texture may benefit from values of `6` or higher. Conversely, reducing the count to `2` can accelerate processing for real-time applications or large-scale batch processing, though this may degrade pose estimation accuracy.

## Summary

- The `--camera-num-iterations` flag controls how many refinement passes are applied to camera poses during inference.
- The default value is `4`, defined in [`scripts/benchmark_gct_memory.py`](https://github.com/Robbyant/lingbot-map/blob/main/scripts/benchmark_gct_memory.py) at lines 65–68.
- Higher values improve pose estimation quality at the cost of increased computational overhead.
- The parameter is passed directly to [`demo.py`](https://github.com/Robbyant/lingbot-map/blob/main/demo.py) and forwarded to the underlying optimization routines.

## Frequently Asked Questions

### What is the default value for camera optimization iterations?

The default value is `4` iterations. This setting provides a balance between computational efficiency and pose estimation accuracy suitable for most standard benchmarking scenarios in the LingBot‑MAP framework.

### Where is the `--camera-num-iterations` parameter defined?

The argument is defined in [`scripts/benchmark_gct_memory.py`](https://github.com/Robbyant/lingbot-map/blob/main/scripts/benchmark_gct_memory.py) between lines 65 and 68. This file contains the argument parser configuration that both the benchmarking utilities and the demo script utilize.

### How does increasing the iteration count affect demo performance?

Higher iteration counts improve the precision of estimated camera poses and intrinsics by allowing the optimizer to converge further. However, each additional iteration increases computational cost linearly, which may introduce latency in time-critical applications or when processing large image datasets.

### Can I use this parameter with standard demo.py execution?

Yes. Although the argument is defined in the benchmarking utility file, [`demo.py`](https://github.com/Robbyant/lingbot-map/blob/main/demo.py) accepts and forwards `--camera-num-iterations` to the model inference code. You can pass it directly to the demo command without modifying the source code.