NatDevice is a cross-platform media device API. NatDevice simplifies your camera and microphone workflows.
First, find an available device:
// Find a rear-facing cameravar criterion = MediaDeviceQuery.Criteria.RearFacing;var query = new MediaDeviceQuery(criterion);var device = query.currentDevice as CameraDevice;
// Find a microphonevar criterion = MediaDeviceQuery.Criteria.AudioDevice;var query = new MediaDeviceQuery(criterion);var device = query.currentDevice as AudioDevice;
Then start streaming media data from the device:
// Start streaming the camera previewvar previewTexture = await device.StartRunning();// The device will stream the preview to the `Texture2D` above
// Start streaming audio sample buffersdevice.StartRunning(OnSampleBuffer);// The device will stream audio to the delegate belowvoid OnSampleBuffer (float sampleBuffer, long timestamp) => DoStuff();
From here, you can utilize tons of functionality provided by media devices to build your interactive applications.
NatDevice is a lightweight API that provides extensive functionality for using media devices. Features include:
Stream the camera preview and microphone audio with very little latency.
Support for high resolution camera previews, at full HD and higher where supported.
Support for specifying microphone sample rate and channel count.
Extensive camera control including hi-res photo capture, flash, focus, exposure, white balance, torch, zoom, and orientation support.
Support for microphones with echo cancellation for karaoke and voice call apps.
Integration with OpenCV, for using computer vision algorithms with the camera.
VR support, compatible with GearVR and Google Cardboard.
Make sure to explore the full documentation to get a complete understanding of what the API offers.