{"id":20722462,"url":"https://github.com/toomanybees/rust-openni2","last_synced_at":"2025-04-23T15:47:02.387Z","repository":{"id":57649495,"uuid":"96239352","full_name":"TooManyBees/rust-openni2","owner":"TooManyBees","description":"OpenNI 2 interface for Rust","archived":false,"fork":false,"pushed_at":"2025-01-11T20:05:50.000Z","size":79,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T17:37:59.526Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TooManyBees.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-04T17:11:00.000Z","updated_at":"2025-01-11T20:05:53.000Z","dependencies_parsed_at":"2022-09-26T20:30:54.025Z","dependency_job_id":null,"html_url":"https://github.com/TooManyBees/rust-openni2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TooManyBees%2Frust-openni2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TooManyBees%2Frust-openni2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TooManyBees%2Frust-openni2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TooManyBees%2Frust-openni2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TooManyBees","download_url":"https://codeload.github.com/TooManyBees/rust-openni2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250463713,"owners_count":21434847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T03:35:56.669Z","updated_at":"2025-04-23T15:47:02.366Z","avatar_url":"https://github.com/TooManyBees.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenNI2 for Rust\n\nIn-development Rust wrapper for [OpenNI2](https://github.com/occipital/OpenNI2).\nOpenNI2 is useful for working with multi-sensor cameras that can simultaneously\nserve color and depth streams, particularly sensors developed by PrimeSense\n(a founding member of the OpenNI software project) such as the Xbox Kinect,\nand ASUS Xtion.\n\n# App example\n\n```rust\nextern crate openni2;\nuse std::{thread, time};\nuse openni2::{Status, Device, Stream, SensorType, OniDepthPixel};\nfn callback(stream: \u0026Stream\u003cOniDepthPixel\u003e) {\n    // This function is only invoked when a frame *is* available to read\n    let frame = stream.read_frame().expect(\"Frame not available to read!\");\n    let px = frame.pixels();\n    let closest = px.iter()\n        .enumerate()\n        .fold((0u16, 0u16, ::std::u16::MAX), |closest, (n, \u0026depth)| {\n            let (x, y) = (n as u16 % frame.width(), n as u16 / frame.width());\n            if depth \u003c closest.2 \u0026\u0026 depth != 0 {\n                (x, y, depth)\n            } else {\n                closest\n            }\n    });\n    println!(\"[{:-6} {:-6} {:-6}]\", closest.0, closest.1, closest.2);\n}\nfn main() -\u003e Result\u003c(), Status\u003e {\n    // Initialize the library\n    openni2::init()?;\n    // Open the first device we find, or abort early\n    let device = Device::open_default()?;\n    // Get a handle for opening a stream from its depth sensor. If the device\n    // didn't have a depth sensor, it would return `Err` and abort the program.\n    let stream = device.create_stream(SensorType::DEPTH)?;\n    // Register a callback that will be called, with the stream as its first\n    // argument, whenever a new frame is ready. When the listener falls out of\n    // scope, the callback will be unregistered.\n    let _listener = stream.listener(callback)?;\n    // Start the stream, then let the callback run until we kill the program\n    // ourselves.\n    stream.start()?;\n    let heartbeat = time::Duration::from_millis(250);\n    loop {\n        thread::sleep(heartbeat);\n    }\n}\n```\n\n# Examples\n\n[`examples/data_dump.rs`](examples/data_dump.rs) demonstrates interrogating\ndevices and streams about their properties, as well as blocking for new frames.\n\n[`examples/closest_point.rs`](examples/closest_point.rs) demonstrates event-based\ncallbacks, and finding the closest point in a depth map.\n\n[`examples/device_callbacks.rs`](examples/device_callbacks.rs) demonstrates device callbacks that detect newly connected/disconnected devices\n\n[`examples/simple_viewer.rs`](examples/simple_viewer.rs) is a video stream viewer with keyboard controls.\n* `1` views the color and depth streams overlayed\n* `2` views the color stream\n* `3` views the depth stream\n* `m` toggles video stream mirroring\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoomanybees%2Frust-openni2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoomanybees%2Frust-openni2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoomanybees%2Frust-openni2/lists"}