* Prefer directories canonically named `images`, and among those the one * nearest the COLMAP model directory (images may sit beside the bins). Falls * back to the directory holding the most images for non-conventional layouts.
(dir: string, modelDir?: string)
| 166 | * back to the directory holding the most images for non-conventional layouts. |
| 167 | */ |
| 168 | function getImagesDirScore(dir: string, modelDir?: string): number { |
| 169 | let score = 0; |
| 170 | if (isImagesNamedDir(dir)) { |
| 171 | score += 1000; |
| 172 | } |
| 173 | if (modelDir !== undefined) { |
| 174 | const parent = getParentDir(dir); |
| 175 | if (dir === modelDir) { |
| 176 | score += 200; // images sit in the same directory as the bins |
| 177 | } else if (parent === modelDir) { |
| 178 | score += 300; // an images/ directory directly under the model dir |
| 179 | } else if (modelDir !== '' && dir.startsWith(`${modelDir}/`)) { |
| 180 | score += 250; // nested somewhere under the model dir |
| 181 | } else { |
| 182 | const modelParent = getParentDir(modelDir); |
| 183 | if (modelParent !== '' && (dir === modelParent || dir.startsWith(`${modelParent}/`))) { |
| 184 | score += 150; // a sibling subtree of the model dir (e.g. corrected/images vs colmap/) |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | return score; |
| 189 | } |
| 190 | |
| 191 | export interface ResolveImagesDirOptions { |
| 192 | /** Directory of the COLMAP model, used to prefer a nearby images directory. */ |
no test coverage detected