26 个版本
| 0.10.4 | 2023 年 5 月 14 日 | 
|---|---|
| 0.10.3 | 2022 年 12 月 28 日 | 
| 0.10.0-rc.2 | 2022 年 11 月 17 日 | 
| 0.9.4 | 2021 年 12 月 17 日 | 
| 0.3.2 | 2021 年 7 月 10 日 | 
#4 in 多媒体
2,312 每月下载次数
在 11 个 Crates (10 直接) 中使用
450KB
 9K  SLoC
nokhwa
Nokhwa(녹화): 韩语单词,意为“记录”。
一个简单易用的跨平台 Rust 摄像头捕获库
使用 nokhwa
您可以通过将 nokhwa 添加到您的 Cargo.toml 中将其添加到您的 crate 中
[dependencies.nokhwa]
version = "0.10.0"
# Use the native input backends, enable WGPU integration
features = ["input-native", "output-wgpu"]
您可能只会使用由 Camera 结构体提供的功能。如果您需要更底层的访问,您可以选择使用在 nokhwa::backends::capture::* 中找到的原始捕获后端。
示例
// first camera in system
let index = CameraIndex::index(0); 
// request the absolute highest resolution CameraFormat that can be decoded to RGB.
let requested = RequestedFormat::<RgbFormat>::new(RequestedFormatType::AbsoluteHighestFrameRate);
// make the camera
let mut camera = Camera::new(index, requested).unwrap();
// get a frame
let frame = camera.frame().unwrap();
println!("Captured Single Frame of {}", frame.buffer().len());
// decode into an ImageBuffer
let decoded = frame.decode_image::<RgbFormat>().unwrap();
println!("Decoded Frame of {}", decoded.len());
在 examples 文件夹中可以找到使用 nokhwa 制成的命令行应用程序。
API 支持
下表列出了当前 Nokhwa API 的支持情况。
- Backend列表示后端。
- Input列表示从摄像头读取帧。
- Query列表示系统设备列表支持。
- Query-*列表示读取设备功能。
- Platform列表示该平台上有何可用。
| 后端 | 输入 | 查询 | 查询-设备 | 平台 | 
|---|---|---|---|---|
| Video4Linux( input-native) | ✅ | ✅ | ✅ | Linux | 
| MSMF( input-native) | ✅ | ✅ | ✅ | Windows | 
| AVFoundation( input-native) | ✅ | ✅ | ✅ | Mac | 
| OpenCV( input-opencv)^ | ✅ | ❌ | ❌ | Linux, Windows, Mac | 
| WASM( input-wasm) | ✅ | ✅ | ✅ | 浏览器(Web) | 
✅: 正常工作,🔮 : 实验,❌ : 不支持,🚧: 计划/进行中
^ = 可能存在错误。也支持 IP 摄像头。
功能
默认功能不包含任何内容。以 input-* 开头的任何内容都是一个功能,该功能可以启用特定的后端。
input-* 功能
- input-native:使用V4L2(Linux)、MSMF(Windows)或AVFoundation(Mac OS)
- input-opencv:启用- opencv后端。(跨平台)
- input-jscam:启用使用- JSCamera结构体,它使用浏览器API。(Web)
相反,任何以output-*开头的都控制着某个功能,该功能控制着某物的输出(通常是来自摄像头的帧)
output-*功能
- output-wgpu:启用API,可以直接将帧复制到- wgpu纹理中。
- output-threaded:启用基于线程/回调的摄像头。
其他功能
- decoding:启用- mozjpeg解码。默认启用。
- docs-only:文档功能。在docs.rs构建中启用。
- docs-nolink:构建文档时不包含任何链接。在docs.rs构建中启用。
- test-fail-warning:在警告时失败。在CI中启用。
您可以选择使用,以减少膨胀。
问题
如果您正在创建问题,请确保
- 尚未创建
- 附加您所做的事情、您的环境、复现步骤和回溯。谢谢!
贡献
欢迎贡献!
- 请使用rustfmt格式化所有代码,并遵循clippy的lints(除非有必要不这样做)
- 请限制使用unsafe
- 除非另有规定,所有贡献都受Apache 2.0许可证的约束
最低服务Rust版本
nokhwa可能在较旧的rustc版本上构建,但对于最新的稳定Rust没有保证。
赞助商
- $40/月赞助商
- $5/月赞助商
请考虑捐赠!这有助于我让父母看起来不像失败者!
依赖项
~2–39MB
~548K SLoC