/// <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 CreateObjectBoundsTest(bool saveResultToStorage) { var inputFile = InputTestFiles.FirstOrDefault(f => string.Equals(f.Name, TestImage)); bool removeResult = true; using (var stream = ImagingApi.DownloadFile(new DownloadFileRequest(inputFile.Path, this.TestStorage))) { var request = new CreateObjectBoundsRequest() { imageData = stream, storage = TestStorage, outPath = saveResultToStorage ? TempFolder + "/" + inputFile.Name : null, threshold = 10, includeLabel = true, includeScore = true, allowedLabels = "dog", }; using (var command = new CreateObjectDetectionTestCommand(request, ImagingApi, saveResultToStorage, removeResult)) { ExecuteTestCommand(command, "objectDetection_createobjectbounds_test", $"Input image: {inputFile.Name};", inputFile.Name, TempFolder, TestStorage); } } }
public CreateObjectDetectionTestCommand( CreateObjectBoundsRequest request, ImagingApi imagingApi, bool saveResultToStorage, bool removeResult) { this.request = request; this.imagingApi = imagingApi; this.saveResultToStorage = saveResultToStorage; this.removeResult = removeResult; }