/// <summary> /// Retrieve an image and its metadata from a camera. /// </summary> /// <returns>The image and its metadata</returns> public ImageBody GetImage() { DateTime now = BlobStorageHelper.GetImageUtcTime(); string nowString = BlobStorageHelper.FormatImageUtcTime(now); byte[] imageBytes = this.ImageSource.RequestImage(); if (imageBytes != null) { ByteString image = ByteString.CopyFrom(imageBytes); ByteString smallImage = Camera.ShrinkJpegTo300x300(imageBytes); ImageBody result = new ImageBody { CameraId = CameraId, Time = nowString, Type = "jpg", Image = image, SmallImageRGB = smallImage, SkipMlProcessing = this.SkipMLProcessing }; return(result); } else { return(null); } }
/// <summary> /// Retrieve an image and its metadata from a camera. /// </summary> /// <returns>The image and its metadata</returns> public ImageBody GetImage() { DateTime now = BlobStorageHelper.GetImageUtcTime(); string nowString = BlobStorageHelper.FormatImageUtcTime(now); ImageBody result = this.ImageSource.RequestImages(); if (result != null) { result.CameraId = CameraId; result.Time = nowString; result.Type = "jpg"; } return(result); }
/// <summary> /// Retrieve images from a camera. /// </summary> /// <returns>The large and small images</returns> ImageBody IImageSource.RequestImages() { // If we're not cycling then this.imageIndex is what we want. Otherwise // we need to cycle. int simulatedImageIndex = this.imageIndex; if (cycleId != null) { List <int> selectedCycle = cycles[cycleId.Value]; simulatedImageIndex = selectedCycle[this.imageIndex]; this.imageIndex++; this.imageIndex = this.imageIndex % selectedCycle.Count; } DateTime now = BlobStorageHelper.GetImageUtcTime(); string nowString = BlobStorageHelper.FormatImageUtcTime(now); string filename = simulatedImageNames[simulatedImageIndex]; string smallImageFilename = smallSimulatedImageNames[simulatedImageIndex]; if (simulatedImageIndex >= simulatedImageNames.Length) { simulatedImageIndex = 0; } byte[] content = File.ReadAllBytes(filename); byte[] smallContent = File.ReadAllBytes(smallImageFilename); Google.Protobuf.ByteString image = Google.Protobuf.ByteString.CopyFrom(content); Google.Protobuf.ByteString smallImage = Google.Protobuf.ByteString.CopyFrom(smallContent); ImageBody body = new ImageBody { Time = nowString, Type = "jpg", Image = image, SmallImage = smallImage }; return(body); }