public ActionResult GetImage([FromRoute] Image.ImageSource source, [FromRoute] Image.ImageType type, [FromRoute] string value) { var sourceType = Image.GetImageTypeFromSourceAndType(source, type) ?? ImageEntityType.None; if (sourceType == ImageEntityType.None) { return(NotFound("The requested resource does not exist.")); } if (sourceType == ImageEntityType.Static) { return(GetStaticImage(value)); } if (!int.TryParse(value, out int id)) { return(NotFound("The requested resource does not exist.")); } string path = Image.GetImagePath(sourceType, id); if (string.IsNullOrEmpty(path)) { return(NotFound("The requested resource does not exist.")); } return(File(System.IO.File.OpenRead(path), Mime.GetMimeMapping(path))); }
/** * Dispatched when a image request cannot be fulfilled. * * Provides the requested frame id and image type of the request that failed, * as well as the reason for the failure, and in the case of an insufficient * buffer, the required size of the image buffer. * * @since 3.0 */ public ImageRequestFailedEventArgs(Int64 frameId, Image.ImageType imageType, Image.RequestFailureReason reason, string message, Int64 requiredBufferSize ) : base(LeapEvent.EVENT_IMAGE_REQUEST_FAILED) { this.frameId = frameId; this.imageType = imageType; this.reason = reason; this.message = message; this.requiredBufferSize = requiredBufferSize; }
public Image RequestImages(Int64 frameId, Image.ImageType imageType, byte[] buffer) { ImageData imageData = new ImageData(); if (imageType == Image.ImageType.DEFAULT) { imageData.type = eLeapImageType.eLeapImageType_Default; } else { imageData.type = eLeapImageType.eLeapImageType_Raw; } imageData.frame_id = frameId; imageData.pixelBuffer = buffer; return(RequestImages(imageData)); }
public Image RequestImages(Int64 frameId, Image.ImageType imageType) { ImageData imageData; int bufferSize = 0; if (imageType == Image.ImageType.DEFAULT) { imageData = _imageDataCache.CheckOut(); imageData.type = eLeapImageType.eLeapImageType_Default; bufferSize = (int)_standardImageBufferSize; } else { imageData = _imageRawDataCache.CheckOut(); imageData.type = eLeapImageType.eLeapImageType_Raw; bufferSize = (int)_standardRawBufferSize; } if (imageData.pixelBuffer == null || imageData.pixelBuffer.Length != bufferSize) { imageData.pixelBuffer = new byte[bufferSize]; } imageData.frame_id = frameId; return(RequestImages(imageData)); }
/** * Requests an image from the service. The pixels of the image are written to the specified byte array. * * If the specified byte array is too small, an ImageRequestFailed event is dispatched. The arguments of this event * include the required buffer size. For the publically available Leap device, the buffer size must be: * width * height * bytes-per-pixel * #cameras, i.e: 640 * 240 * 1 * 2 = 307,200 bytes. * * The Image object returned by this function contains a reference to the supplied buffer. When the service sets * the IsComplete property to true when the buffer is filled in. An ImageReady event is also dispatched. * * @param frameId The Id value of the tracking frame. * @param type The type of image desired. A member of the Image.ImageType enumeration. * @param imageBuffer A byte array large enough to hold the requested image pair. * @returns An incomplete Image object that will contain the image data when the request is fulfilled. * If the request call itself fails, an invalid image is returned. * @since 3.0 */ public Image RequestImages(Int64 frameId, Image.ImageType type, byte[] imageBuffer) { return(_connection.RequestImages(frameId, type, imageBuffer)); }
/** * Requests an image pair from the service. * * Image data is stacked in a single byte array, with the left camera image first, followed by the right camera image. * Two types of image are supported. ImageType.TYPE_DEFAULT is the normal, IR format image. * ImageType.RAW is the unmodified, raw sensor pixels. The format of this image type depends on the device. For * the publically available Leap Motion devices, the raw image type is also IR and is identical to the default image type * except when in robust mode. In robust mode, the default image type is processed to subtract the unilluminated background; * the raw image is not. * * Images are not sent automatically. You must request each image. This function returns an Image * object. However, that object does not contain image data until its IsComplete property * becomes true. * * Image requests will fail if the request is made after the image has been disposed by the service. The service only * keeps images for a few frames, so applications that use images must make the image request as soon as possible * after a tracking frame is received. * * The controller dispatches an ImageReady event when a requested image is recevied from the service * and is ready for use. The controller dispatches an ImageRequestFailed event if the request does not succeed. * * Image requests can fail for the following reasons: * * * The requested image is no longer available. * * The frame id does not match an actual tracking frame. * * Images are disabled by the client's configuration settings. * * The buffer supplied for the image was too small. * * An internal service error occurs. * * In addition, if the returned image is invalid, then the request call itself failed. Typically this * will occur when the connection itself is not running. Such errors are reported in a LogEvent event. * * @param frameId The Id value of the tracking frame. * @param type The type of image desired. A member of the Image.ImageType enumeration. * @returns An incomplete Image object that will contain the image data when the request is fulfilled. * If the request call itself fails, an invalid image is returned. * @since 3.0 */ public Image RequestImages(Int64 frameId, Image.ImageType type) { return(_connection.RequestImages(frameId, type)); }
public ImageRequestFailedEventArgs(Int64 frameId, Image.ImageType imageType) : base(LeapEvent.EVENT_IMAGE_REQUEST_FAILED) { this.frameId = frameId; this.imageType = imageType; }
/** * Requests an image pair from the service. * * Image data is stacked in a single byte array, with the left camera image first, followed by the right camera image. * Two types of image are supported. ImageType.TYPE_DEFAULT is the normal, IR format image. * ImageType.RAW is the unmodified, raw sensor pixels. The format of this image type depends on the device. For * the publically available Leap Motion devices, the raw image type is also IR and is identical to the default image type * except when in robust mode. In robust mode, the default image type is processed to subtract the unilluminated background; * the raw image is not. * * Images are not sent automatically. You must request each image. This function returns an Image * object. However, that object does not contain image data until its IsComplete property * becomes true. * * Image requests will fail if the request is made after the image has been disposed by the service. The service only * keeps images for a few frames, so applications that use images must make the image request as soon as possible * after a tracking frame is received. * * The controller dispatches an ImageReady event when a requested image is recevied from the service * and is ready for use. The controller dispatches an ImageRequestFailed event if the request does not succeed. * * Image requests can fail for the following reasons: * * * The requested image is no longer available. * * The frame id does not match an actual tracking frame. * * Images are disabled by the client's configuration settings. * * The buffer supplied for the image was too small. * * An internal service error occurs. * * In addition, if the returned image is invalid, then the request call itself failed. Typically this * will occur when the connection itself is not running. Such errors are reported in a LogEvent event. * * @param frameId The Id value of the tracking frame. * @param type The type of image desired. A member of the Image.ImageType enumeration. * @returns An incomplete Image object that will contain the image data when the request is fulfilled. * If the request call itself fails, an invalid image is returned. * @since 3.0 */ public Image RequestImages(Int64 frameId, Image.ImageType type) { //return _connection.RequestImages(frameId, type); return(null); }
// same problem as above public new Image RequestImages(Int64 frameID, Image.ImageType type, byte[] imageBuffer) { return(_localController.RequestImages(frameID, type, imageBuffer)); }
// is an invalid image, maybe need to handle it at some point public new Image RequestImages(Int64 frameID, Image.ImageType type) { return(_localController.RequestImages(frameID, type)); }
// same problem as above public new Image RequestImages(Int64 frameID, Image.ImageType type, byte[] imageBuffer) { return(new Image()); }
// is an invalid image, maybe need to handle it at some point public new Image RequestImages(Int64 frameID, Image.ImageType type) { return(new Image()); }