Skip to content

Latest commit

 

History

History
102 lines (81 loc) · 4.71 KB

README.md

File metadata and controls

102 lines (81 loc) · 4.71 KB

cargo version docs.rs version

nokhwa

Nokhwa(녹화): Korean word meaning "to record".

A Simple-to-use, cross-platform Rust Webcam Capture Library

Using nokhwa

Nokhwa can be added to your crate by adding it to your Cargo.toml:

[dependencies.nokhwa]
version = "0.10.0"
# Use the native input backends, enable WGPU integration
features = ["input-native", "output-wgpu"]

Most likely, you will only use functionality provided by the Camera struct. If you need lower-level access, you may instead opt to use the raw capture backends found at nokhwa::backends::capture::*.

Example

// 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());

A command line app made with nokhwa can be found in the examples folder.

API Support

The table below lists current Nokhwa API support.

  • The Backend column signifies the backend.
  • The Input column signifies reading frames from the camera
  • The Query column signifies system device list support
  • The Query-Device column signifies reading device capabilities
  • The Platform column signifies what Platform this is availible on.
Backend Input Query Query-Device Platform
Video4Linux(input-native) Linux
MSMF(input-native) Windows
AVFoundation(input-native) Mac
OpenCV(input-opencv)^ Linux, Windows, Mac
WASM(input-wasm) Browser(Web)

✅: Working, 🔮 : Experimental, ❌ : Not Supported, 🚧: Planned/WIP

^ = May be bugged. Also supports IP Cameras.

Feature

The default feature includes nothing. Anything starting with input-* is a feature that enables the specific backend.

input-* features:

  • input-native: Uses either V4L2(Linux), MSMF(Windows), or AVFoundation(Mac OS)
  • input-opencv: Enables the opencv backend. (cross-platform)
  • input-jscam: Enables the use of the JSCamera struct,