MCPcopy Create free account
hub / github.com/RustCV/RustCV / calculate_score

Function calculate_score

rustcv-backend-v4l2/src/device.rs:125–146  ·  view source on GitHub ↗
(config: &CameraConfig, w: u32, h: u32, fmt: PixelFormat)

Source from the content-addressed store, hash-verified

123}
124
125fn calculate_score(config: &CameraConfig, w: u32, h: u32, fmt: PixelFormat) -> i32 {
126 let mut score = 0;
127
128 // 1. 匹配分辨率
129 for (req_w, req_h, prio) in &config.resolution_req {
130 if w == *req_w && h == *req_h {
131 score += *prio as i32 * 10;
132 }
133 }
134
135 // 2. 匹配格式
136 for (req_fmt, prio) in &config.format_req {
137 if fmt == *req_fmt {
138 score += *prio as i32 * 10;
139 }
140 }
141
142 // 3. 分辨率越大基础分越高 (作为 Tie-breaker)
143 score += (w / 100) as i32;
144
145 score
146}

Callers 1

negotiate_formatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected