/// <summary> /// Detect objects on an image from a cloud storage. /// </summary> public void DetectObjectsImageFromStorage() { Console.WriteLine("Detect object on the image from cloud storage"); UploadSampleImageToCloud(); string method = "ssd"; int threshold = 50; bool includeLabel = true; bool includeScore = true; string allowedLabels = "cat"; string blockedLabels = "dog"; string folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var request = new GetObjectBoundsRequest(SampleImageFileName, method, threshold, includeLabel, includeScore, allowedLabels, blockedLabels, folder, storage); Console.WriteLine($"Call ObjectBoundsRequest with params: method:{method}, threshold:{threshold}, include label: {includeLabel}, includeScore: {includeScore}"); DetectedObjectList detectedObjectList = this.ImagingApi.GetObjectBounds(request); Console.WriteLine("Objects detected: " + detectedObjectList.DetectedObjects.Count); Console.WriteLine(); }
/// <summary> /// detected object on an image that is passed in a request stream. /// </summary> public void DetectedObjectsImageFromRequestBody() { Console.WriteLine("Detect objects on an image. Image data is passed in a request stream"); using (FileStream inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { string method = "ssd"; int threshold = 50; bool includeLabel = true; bool includeScore = true; string allowedLabels = "cat"; string blockedLabels = "dog"; string outPath = null; string storage = null; // We are using default Cloud Storage var request = new CreateObjectBoundsRequest(inputImageStream, method, threshold, includeLabel, includeScore, allowedLabels, blockedLabels, outPath, storage); Console.WriteLine($"Call CreateObjectBoundsRequest with params: method:{method}, threshold:{threshold}, include label: {includeLabel}, includeScore: {includeScore}"); DetectedObjectList detectedObjectList = this.ImagingApi.CreateObjectBounds(request); Console.WriteLine("Objects detected: " + detectedObjectList.DetectedObjects.Count); } Console.WriteLine(); }
public void InvokeRequest() { if (saveResultToStorage) { // remove output file from the storage (if exists) if (imagingApi.ObjectExists(new ObjectExistsRequest(request.outPath, request.storage)).Exists.Value) { imagingApi.DeleteFile(new DeleteFileRequest(request.outPath, request.storage)); } } request.imageData.Position = 0; response = imagingApi.CreateObjectBounds(request); }
public void InvokeRequest() { Prepare(); response = imagingApi.GetObjectBounds(request); }