1717// along with mmSolver. If not, see <https://www.gnu.org/licenses/>.
1818// ====================================================================
1919//
20- //! Custom CLI argument parsing (no external dependencies) .
20+ //! CLI argument parsing without external dependencies.
2121
2222use crate :: parser;
2323
@@ -55,15 +55,15 @@ const ARG_PREFIX: &str = "--prefix";
5555const ARG_INTERMEDIATE_OUTPUT : & str = "--with-intermediate-output" ;
5656const ARG_NUKE_LENS : & str = "--nuke-lens" ;
5757
58- /// Solver type for focal length adjustment
58+ /// Solver type for focal length adjustment.
5959#[ derive( Debug , Clone , Copy , PartialEq , Eq , Default ) ]
6060pub enum SolverType {
61- /// Use provided focal length as-is (no adjustment)
61+ /// Use provided focal length as-is.
6262 #[ default]
6363 None ,
64- /// Small refinement around provided focal length (±10%)
64+ /// Small refinement around the provided focal length (±20%).
6565 Refine ,
66- /// Large search range for unknown focal length (10-200mm)
66+ /// Large search range for an unknown focal length (10-200mm).
6767 Unknown ,
6868}
6969
@@ -86,63 +86,30 @@ impl std::str::FromStr for SolverType {
8686/// Parsed command-line arguments.
8787#[ derive( Debug ) ]
8888pub struct CliArgs {
89- /// Path to UV markers file (.uv).
9089 pub uv_file : String ,
91-
92- /// Optional path to an `.mmcamera` file for camera defaults.
9390 pub mmcamera_file : Option < String > ,
94-
95- /// Optional path to an `.mmsettings` file for solver settings.
9691 pub solver_settings_file : Option < String > ,
97-
98- /// Focal length in millimeters.
9992 pub focal_length_mm : f64 ,
100-
101- /// Lens center X offset in millimeters.
10293 pub lens_center_x_mm : f64 ,
103-
104- /// Lens center Y offset in millimeters.
10594 pub lens_center_y_mm : f64 ,
106-
107- /// Image width in pixels.
10895 pub image_width : u32 ,
109-
110- /// Image height in pixels.
11196 pub image_height : u32 ,
112-
113- /// Film back width in millimeters.
11497 pub film_back_width_mm : f64 ,
115-
116- /// Film back height in millimeters.
11798 pub film_back_height_mm : f64 ,
118-
11999 /// Start frame (None = use UV file default).
120100 pub start_frame : Option < u32 > ,
121-
122101 /// End frame (None = use UV file default).
123102 pub end_frame : Option < u32 > ,
124-
125- /// Solver type for focal length adjustment.
126103 pub solver : SolverType ,
127-
128- /// Thread count (None = auto).
104+ /// Thread count (None = auto-detect).
129105 pub threads : Option < usize > ,
130-
131- /// Output directory for visualizations.
132106 pub output_dir : String ,
133-
134- /// Optional prefix for output filenames.
135107 pub prefix : Option < String > ,
136-
137- /// Quiet mode - suppress progress output.
108+ /// Suppress progress output.
138109 pub quiet : bool ,
139-
140110 /// Write intermediate results during solve.
141111 pub intermediate_output : bool ,
142-
143- /// Optional path to a Nuke .nk lens distortion file.
144112 pub nuke_lens_file : Option < String > ,
145-
146113}
147114
148115impl Default for CliArgs {
@@ -171,7 +138,6 @@ impl Default for CliArgs {
171138 }
172139}
173140
174- /// Print help message.
175141pub fn print_help ( ) {
176142 println ! (
177143 "mmSolver Camera Solver - Structure from Motion camera solver.
@@ -226,7 +192,6 @@ HELP:
226192 ) ;
227193}
228194
229- /// Print version information.
230195pub fn print_version ( ) {
231196 println ! ( "mmsfm {}" , env!( "CARGO_PKG_VERSION" ) ) ;
232197}
@@ -240,19 +205,13 @@ macro_rules! try_parse {
240205 } ;
241206}
242207
243- /// Result of argument parsing.
244208pub enum ParseResult {
245- /// Successfully parsed arguments.
246209 Args ( CliArgs ) ,
247- /// User requested help.
248210 Help ,
249- /// User requested version.
250211 Version ,
251- /// Parse error with message.
252212 Error ( String ) ,
253213}
254214
255- /// Parse command-line arguments.
256215pub fn parse_args ( ) -> ParseResult {
257216 let args: Vec < String > = std:: env:: args ( ) . collect ( ) ;
258217
@@ -452,7 +411,7 @@ pub fn parse_args() -> ParseResult {
452411 ParseResult :: Args ( cli)
453412}
454413
455- /// Tracks which CLI fields were explicitly provided by the user .
414+ /// Tracks which CLI fields were explicitly set, so mmcamera defaults don't override them .
456415#[ derive( Debug , Default ) ]
457416struct ExplicitFlags {
458417 focal_length : bool ,
@@ -466,8 +425,7 @@ struct ExplicitFlags {
466425 end_frame : bool ,
467426}
468427
469- /// Read an `.mmcamera` file and apply its values as defaults for any
470- /// fields that were not explicitly set on the command line.
428+ /// Apply defaults from an .mmcamera file for any fields not explicitly set on the command line.
471429fn apply_mmcamera_defaults (
472430 cli : & mut CliArgs ,
473431 mmcamera_path : & str ,
0 commit comments