ImageΒΆ
Properties:
Methods:
The Image class represents a single image from one of the Leap Motion cameras.
In addition to image data, the Image object provides a distortion map for correcting lens distortion.
Note that Image objects can be invalid, which means that they do not contain valid image data. Get valid Image objects from Frame::frames(). Test for validity with the Image::isValid() function.
Public Functions
- Since
- 2.1.0
Propertybool Equals(Image other)Image()
Provides the corrected camera ray intercepting the specified point on the image.
Given a point on the image, rectify() corrects for camera distortion and returns the true direction from the camera to the source of that image point within the Leap Motion field of view.
This direction vector has an x and y component [x, y, 0], with the third element always zero. Note that this vector uses the 2D camera coordinate system where the x-axis parallels the longer (typically horizontal) dimension and the y-axis parallels the shorter (vertical) dimension. The camera coordinate system does not correlate to the 3D Leap Motion coordinate system.
override string ToString()
Provides the point in the image corresponding to a ray projecting from the camera.
Given a ray projected from the camera in the specified direction, warp() corrects for camera distortion and returns the corresponding pixel coordinates in the image.
The ray direction is specified in relationship to the camera. The first vector element corresponds to the “horizontal” view angle; the second corresponds to the “vertical” view angle.
The warp() function returns pixel coordinates outside of the image bounds if you project a ray toward a point for which there is no recorded data.
warp() is typically not fast enough for realtime distortion correction. For better performance, use a shader program exectued on a GPU.
Finds the undistorted brightness for a pixel in a target image.
The brightness is scaled and undistorted using bilinear interpolation.
- Return
- A Vector containing the pixel coordinates [x, y, 0] (with z always zero).
- Parameters
- xy -
A Vector containing the target image pixel coordinates.
- targetWidth -
the width of the destination image.
- targetHeight -
the height of the destination image.
- stereoPerspective -
whether the xy parameter is a pixel in the left or the right stereo image.
int BytesPerPixel
The number of bytes per pixel.
Use this value along with Image::width() and Image:::height() to calculate the size of the data buffer.
- Since
- 2.2.0
byte[] Data
The image data.
The image data is a set of 8-bit intensity values. The buffer is image.Width * image.Height * image.BytesPerPixel bytes long.
- Since
- 2.1.0
float[] Distortion
The distortion calibration map for this image.
The calibration map is a 64x64 grid of points. Each point is defined by a pair of 32-bit floating point values. Each point in the map represents a ray projected into the camera. The value of a grid point defines the pixel in the image data containing the brightness value produced by the light entering along the corresponding ray. By interpolating between grid data points, you can find the brightness value for any projected ray. Grid values that fall outside the range [0..1] do not correspond to a value in the image data and those points should be ignored.
The calibration map can be used to render an undistorted image as well as to find the true angle from the camera to a feature in the raw image. The distortion map itself is designed to be used with GLSL shader programs. In other contexts, it may be more convenient to use the Image Rectify() and Warp() functions.
Distortion is caused by the lens geometry as well as imperfections in the lens and sensor window. The calibration map is created by the calibration process run for each device at the factory (and which can be rerun by the user).
Note, in a future release, there will be two distortion maps per image; one containing the horizontal values and the other containing the vertical values.
- Since
- 2.1.0
int DistortionHeight
The distortion map height.
Currently fixed at 64.
- Since
- 2.1.0
int DistortionWidth
The stride of the distortion map.
Since each point on the 64x64 element distortion map has two values in the buffer, the stride is 2 times the size of the grid. (Stride is currently fixed at 2 * 64 = 128).
- Since
- 2.1.0
Image.FormatType Format
The image format.
- Since
- 2.2.0
int Height
The image height.
- Since
- 2.1.0
Image Invalid
bool IsValid
Reports whether this Image instance contains valid data.
- Return
- true, if and only if the image is valid.
- Since
- 2.1.0
float RayOffsetX
The horizontal ray offset.
Used to convert between normalized coordinates in the range [0..1] and the ray slope range [-4..4].
- Since
- 2.1.0
float RayOffsetY
The vertical ray offset.
Used to convert between normalized coordinates in the range [0..1] and the ray slope range [-4..4].
- Since
- 2.1.0
float RayScaleX
The horizontal ray scale factor.
Used to convert between normalized coordinates in the range [0..1] and the ray slope range [-4..4].
- Since
- 2.1.0
float RayScaleY
The vertical ray scale factor.
Used to convert between normalized coordinates in the range [0..1] and the ray slope range [-4..4].
- Since
- 2.1.0
long SequenceId
The image sequence ID.
- Since
- 2.2.1
long Timestamp
Returns a timestamp indicating when this frame began being captured on the device.
- Since
- 2.2.7
int Width
The image width.
- Since
- 2.1.0
C# and Unity