Using Cameras
Ultra Low Latency Camera Streaming
NatDevice provides an extensive API for using hardware cameras, encapsulated in the CameraDevice
class.
Finding a Camera
We begin by finding a camera with a device query.
Make sure to add a using NatML.Devices
statement at the top of your script.
Starting the Preview
Camera devices work by streaming the camera preview to a user-provided delegate function:
The delegate function accepts a CameraImage
which contains a view to the pixel buffer provided by the native camera system, along with EXIF metadata about the image:
The provided delegate is not guaranteed to be invoked on the Unity main thread, so refrain from using Unity APIs within this method.
Streaming to Texture
The most common use case when using a camera device is to display the camera preview. For this, we will need to stream incoming camera images into a Texture
. To do so, NatDevice provides the TextureOutput
:
Make sure to add a using NatML.Devices.Outputs
statement at the top of your script.
Capturing Photos
Camera devices allow for capturing high-resolution photos:
The provided delegate is invoked with a photo CameraImage
:
Stopping the Preview
The camera preview can be stopped when it is no longer needed.
Last updated