/// <summary> /// Sends a URL to Cognitive Services and generates a bounding rectangle representing the area of interest. /// </summary> /// <param name="imageUrl">The URL of the image for which to generate the area of interest.</param> /// <returns>Awaitable AreaOfInterest result.</returns> private async Task <AreaOfInterestResult> GenerateImageAreaOfInterestAsync(string imageUrl) { // ----------------------------------------------------------------------- // KEY SAMPLE CODE STARTS HERE // ----------------------------------------------------------------------- // // Create Cognitive Services Vision API Service client. // using (var client = new ComputerVisionClient(Credentials) { Endpoint = Endpoint }) { Log("ComputerVisionClient is created"); // // Generate the area of interest for the given URL. // Log("Calling ComputerVisionClient.GetAreaOfInterestAsync()..."); return(await client.GetAreaOfInterestAsync(imageUrl)); } // ----------------------------------------------------------------------- // KEY SAMPLE CODE ENDS HERE // ----------------------------------------------------------------------- }
// Analyze a remote image private static async Task GetAreaOfInterestFromUrlAsync(ComputerVisionClient computerVision, string imageUrl) { if (!Uri.IsWellFormedUriString(imageUrl, UriKind.Absolute)) { Console.WriteLine("\nInvalid remote image url:\n{0} \n", imageUrl); return; } AreaOfInterestResult analysis = await computerVision.GetAreaOfInterestAsync(imageUrl); Console.WriteLine(imageUrl); DisplayAreaOfInterest(analysis); }
private Task <AreaOfInterestResult> ComputerVisionGetAreaOfInterestByUrlAsync(string imageUrl) { return(_computerVisionClient.GetAreaOfInterestAsync(imageUrl)); }