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

Method set_resolution

rustcv/src/videoio/mod.rs:269–290  ·  view source on GitHub ↗

【新增】设置分辨率 这是一个同步阻塞调用,会等待后台完成硬件重启

(&mut self, width: u32, height: u32)

Source from the content-addressed store, hash-verified

267 }
268
269 /// 【新增】设置分辨率
270 /// 这是一个同步阻塞调用,会等待后台完成硬件重启
271 pub fn set_resolution(&mut self, width: u32, height: u32) -> Result<()> {
272 if !self.is_opened {
273 return Err(anyhow!("Camera not opened"));
274 }
275
276 // 发送指令
277 self.cmd_tx
278 .send(Command::SetResolution(width, height))
279 .map_err(|_| anyhow!("Background worker is dead"))?;
280
281 // 等待确认
282 let response = self
283 .res_rx
284 .recv()
285 .map_err(|_| anyhow!("Failed to receive response"))?;
286
287 match response {
288 Response::PropertySet => Ok(()), // 成功
289 Response::Error(e) => Err(anyhow!("Failed to set resolution: {}", e)),
290 _ => Err(anyhow!("Unexpected response")),
291 }
292 }
293

Callers 1

mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected