Process an MVS scene and update EXIF data for all images. Args: mvs_path: Path to the MVS interface file images_path: Path to the directory containing image files dry_run: If True, only print what would be done
(mvs_path, images_path, dry_run=False)
| 141 | |
| 142 | |
| 143 | def process_mvs_scene(mvs_path, images_path, dry_run=False): |
| 144 | """ |
| 145 | Process an MVS scene and update EXIF data for all images. |
| 146 | |
| 147 | Args: |
| 148 | mvs_path: Path to the MVS interface file |
| 149 | images_path: Path to the directory containing image files |
| 150 | dry_run: If True, only print what would be done |
| 151 | """ |
| 152 | print(f"Loading MVS scene from: {mvs_path}") |
| 153 | mvs = loadMVSInterface(mvs_path) |
| 154 | |
| 155 | if not mvs: |
| 156 | print("Error: Could not load MVS scene") |
| 157 | return False |
| 158 | |
| 159 | print(f"Loaded MVS scene with {len(mvs['platforms'])} platforms and {len(mvs['images'])} images") |
| 160 | |
| 161 | updated_count = 0 |
| 162 | error_count = 0 |
| 163 | |
| 164 | # Process each image in the scene |
| 165 | for image_idx, image_info in enumerate(mvs['images']): |
| 166 | image_name = image_info['name'] |
| 167 | platform_id = image_info['platform_id'] |
| 168 | camera_id = image_info['camera_id'] |
| 169 | |
| 170 | # Get platform and camera information |
| 171 | if platform_id >= len(mvs['platforms']): |
| 172 | print(f"Warning: Invalid platform ID {platform_id} for image {image_name}") |
| 173 | error_count += 1 |
| 174 | continue |
| 175 | |
| 176 | platform = mvs['platforms'][platform_id] |
| 177 | if camera_id >= len(platform['cameras']): |
| 178 | print(f"Warning: Invalid camera ID {camera_id} for image {image_name}") |
| 179 | error_count += 1 |
| 180 | continue |
| 181 | |
| 182 | camera = platform['cameras'][camera_id] |
| 183 | |
| 184 | # Extract camera parameters |
| 185 | K = camera['K'] # Intrinsic matrix |
| 186 | fx = K[0][0] |
| 187 | fy = K[1][1] |
| 188 | width = camera.get('width', 0) |
| 189 | height = camera.get('height', 0) |
| 190 | |
| 191 | if width == 0 or height == 0: |
| 192 | print(f"Warning: No image dimensions for camera {camera_id} in platform {platform_id}") |
| 193 | error_count += 1 |
| 194 | continue |
| 195 | |
| 196 | # Calculate 35mm equivalent focal length |
| 197 | focal_length_35mm = calculate_35mm_focal_length(fx, fy, width, height) |
| 198 | |
| 199 | # Generate camera model name |
| 200 | platform_name = platform.get('name', f'Platform_{platform_id}') |
no test coverage detected