Cross Platform Rust Library for Powerful Webcam/Camera Capture
Find a file
2025-10-28 19:59:43 +03:00
.github chore: bring example up to date with code 2022-11-25 14:00:13 +01:00
.run Prune more unnecessary stuff 2024-07-24 12:19:27 +01:00
examples Get RGB conversion example working 2024-07-29 11:05:54 +01:00
nokhwa-bindings-linux Update nokhwa-bindings-linux/Cargo.toml 2025-10-28 18:24:02 +03:00
nokhwa-bindings-macos Update nokhwa-bindings-macos/Cargo.toml 2025-10-28 19:59:27 +03:00
nokhwa-bindings-windows Update nokhwa-bindings-windows/Cargo.toml 2025-10-28 18:24:29 +03:00
nokhwa-core Update nokhwa-core/Cargo.toml 2025-10-28 18:24:56 +03:00
src Get RGB conversion example working 2024-07-29 11:05:54 +01:00
.gitignore Get RGB conversion example working 2024-07-29 11:05:54 +01:00
Cargo.toml Update Cargo.toml 2025-10-28 19:59:43 +03:00
CHANGELOG.md More 2024-07-17 09:47:41 +03:00
LICENSE update LICENSE 2021-10-07 08:35:15 +09:00
make-npm.sh adjust copyright notices 2022-06-22 18:26:35 +09:00
publish.sh convience script 2022-12-19 16:02:37 +09:00
README.md Prune more unnecessary stuff 2024-07-24 12:19:27 +01:00
UPDATE_CHECKLIST.md add finishing touches for 0.3.0 release 2021-07-02 18:11:02 +09:00

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 or use input-jscam in a wasm context
features = ["input-native"]

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
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-jscam: Enables the use of the JSCamera struct, which uses browser APIs. (Web)

Conversely, anything that starts with output-* controls a feature that controls the output of something (usually a frame from the camera)

output-* features:

  • output-threaded: Enable the threaded/callback based camera.

Other features:

  • docs-only: Documentation feature. Enabled for docs.rs builds.
  • docs-nolink: Build documentation without linking to any libraries. Enabled for docs.rs builds.
  • test-fail-warning: Fails on warning. Enabled in CI.

You many want to pick and choose to reduce bloat.

Issues

If you are making an issue, please make sure that

  • It has not been made yet
  • Attach what you were doing, your environment, steps to reproduce, and backtrace. Thank you!

Contributing

Contributions are welcome!

  • Please rustfmt all your code and adhere to the clippy lints (unless necessary not to do so)
  • Please limit use of unsafe
  • All contributions are under the Apache 2.0 license unless otherwise specified

Minimum Service Rust Version

nokhwa may build on older versions of rustc, but there is no guarantee except for the latest stable rust.

Sponsors

Please consider donating! It helps me not look like a failure to my parents!