public void CreateVisualObjectBoundsTest(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 CreateVisualObjectBoundsRequest()
                {
                    imageData     = stream,
                    storage       = TestStorage,
                    outPath       = saveResultToStorage ? TempFolder + "/" + inputFile.Name : null,
                    threshold     = 20,
                    includeLabel  = true,
                    includeScore  = true,
                    color         = "blue",
                    allowedLabels = "dog",
                };

                using (var command = new CreateVisualObjectDetectionTestCommand(request, ImagingApi,
                                                                                saveResultToStorage, removeResult))
                {
                    ExecuteTestCommand(command, "objectDetection_createvisualobjectbounds_test", $"Input image: {inputFile.Name};", inputFile.Name,
                                       TempFolder, TestStorage);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Visualize detected object on an image that is passed in a request stream.
        /// </summary>
        public void VisualizeDetectedObjectsImageFromRequestBody()
        {
            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 color         = null;
                string outPath       = null;
                string storage       = null; // We are using default Cloud Storage

                var request = new CreateVisualObjectBoundsRequest(inputImageStream, method, threshold, includeLabel, includeScore, allowedLabels, blockedLabels, color, outPath, storage);

                Console.WriteLine($"Call CreateVisualObjectBoundsRequest with params: method:{method}, threshold:{threshold}, include label: {includeLabel}, include score: {includeScore}");

                using (Stream updatedImage = this.ImagingApi.CreateVisualObjectBounds(request))
                {
                    SaveUpdatedSampleImageToOutput(updatedImage, true, SaveImageFormat);
                }
            }

            Console.WriteLine();
        }
Exemplo n.º 3
0
 public CreateVisualObjectDetectionTestCommand(
     CreateVisualObjectBoundsRequest request,
     ImagingApi imagingApi,
     bool saveResultToStorage,
     bool removeResult)
 {
     this.request             = request;
     this.imagingApi          = imagingApi;
     this.saveResultToStorage = saveResultToStorage;
     this.removeResult        = removeResult;
 }