Rust

About bevywebcamfacial

Plugin for Bevy game engine. Captures webcam image, finds face and provides all available data (face rectangle coordinates, face probability) to Bevy game engine via events for further use in Bevy game engine.

Features

Plans

Supported Platforms

Available for use in Bevy:

Plugin config

Needs several parameters when including in .add_plugins: rust .add_plugins(WebcamFacialPlugin { config_webcam_device: "/dev/video0".to_string(), config_webcam_width: 640, config_webcam_height: 480, config_webcam_framerate: 33, config_webcam_autostart: true, config_filter_type: SmoothingFilterType::LowPass(0.1), config_filter_length: 10, }) Parameters: * Path to webcamera device ex."/dev/video0" * Width of frame: 640 * Width of frame: 480 * Frames per second: 33 * Start capturing and sending events instantly after plugin activation: true/false (can be enabled/disabled anytime at runtime via ResMut<WebcamFacialController>) * Smoothing filter for coordinates (currently: MeanMedian, LowPass(f32), NoFilter) * From how much frames take data for smoothing 5-10 optimal (more frames - more smooth movement but slow response)

Resources:

Enable/disable webcam capture and recognition from Bevy via mutable resource ResMut<WebcamFacialController> rust pub struct WebcamFacialController { ... pub control: bool, ... }

Event with captured data

rust <Event>WebcamFacialDataEvent

Data struct returned via Event

rust pub struct WebcamFacialData { pub center_x: f32, pub center_y: f32, pub x: f32, pub y: f32, pub width: f32, pub height: f32, pub score: f32, } Coordinates are mapped as floating point number in range of -50.0 .. 50.0, camera resolution doesn't matter * [centerx) Face center point x coordinate * (centery) Face center point y coordinate * (x) Face rectangle frame x coordinate * (y) Face rectangle frame y coordinate * (width) Face rectangle frame width * (height) Face rectangle frame height * (score) Probability of a detected object being a true face 0-30..

Some ideas and use cases of data comming from plugin:

Examples

Three examples are provided in [examples] folder: (under construction) - [x] [objectmover](examples/objectmover.rs) - simplest example to move object using raw unfiltered/noisy data - [x] [cameracontrol](examples/cameracontrol.rs) - control bevy camera view using filtered data - [ ] [necktrainer](examples/necktrainer.rs) - train you neck :) most complex example with filtered data + bone animation and skin

Unchecked - not finished

Versions

| bevy | bevywebcamfacial | | ---:| ---:| | 0.11 | 0.1.3 | | 0.11 | 0.1.2 | | 0.11 | 0.1.1 |

Bevy tracking

Reference Material

The following were used for coding of plugin:

Additional interesting sources for future research:

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.