Skip to content

Instantly share code, notes, and snippets.

@sakapon
Last active June 28, 2016 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakapon/54dc433f50dec38b25676a676d8cbdec to your computer and use it in GitHub Desktop.
Save sakapon/54dc433f50dec38b25676a676d8cbdec to your computer and use it in GitHub Desktop.
CognitiveSample / ComputerVisionWpf / Analyze image
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using Microsoft.ProjectOxford.Vision;
namespace ComputerVisionWpf
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
const string SubscriptionKey = "0123456789abcdef0123456789abcdef";
const string ImageUrl = "https://tempuri.org/temp.jpg";
VisionServiceClient client = new VisionServiceClient(SubscriptionKey);
async void AnalyzeImageAsync()
{
try
{
var result = await client.AnalyzeImageAsync(ImageUrl, (VisualFeature[])Enum.GetValues(typeof(VisualFeature)));
// 各情報を取り出します。
var captions = result.Description.Captions;
var isAdultContent = result.Adult.IsAdultContent;
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment