Merge pull request #11 from PatrickFarley/pafarley-snippets

Pafarley snippets
This commit is contained in:
Patrick Farley 2019-09-24 10:18:19 -07:00 коммит произвёл GitHub
Родитель c5290c89d9 0f174e9a6e
Коммит 356878e407
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -5,6 +5,7 @@
// Photos storage
public const string PhotoFolder = "VisualProvision";
// <snippet_serviceprincipal>
/*
* Service principal
*
@ -14,21 +15,22 @@
*/
public const string ClientId = "INSERT YOUR CLIENTID HERE";
public const string TenantId = "INSERT YOUR TENANTID HERE";
// </snippet_serviceprincipal>
// App Center (Feel free to change the following IDs with your App Center IDs).
public const string AppCenterAndroid = "c8fbe0d5-f676-40b9-927d-19f70365f7de";
public const string AppCenterIos = "a43c421b-70ac-4742-905a-24dc760696de";
// <snippet_cusvis_keys>
// Custom Vision
// URL example: https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Prediction/{GUID}/image
// We are providing public endpoint in a free tier to showcase how the app works, feel free to replace these values with your own cognitive services.
public const string CustomVisionPredictionUrl = "https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Prediction/41deb215-1c77-4679-81dd-5025c3998dbf/image";
public const string CustomVisionPredictionKey = "47c6b38bf1e245449f01405c144b9aef";
public const string CustomVisionPredictionUrl = "INSERT YOUR COMPUTER VISION API URL HERE FOR MAGNETS RECOGNITION";
public const string CustomVisionPredictionKey = "INSERT YOUR COMPUTER VISION PREDICTION KEY HERE FOR MAGNETS RECOGNITION";
// </snippet_cusvis_keys>
// <snippet_comvis_keys>
// Computer Vision
// Endpoint example: https://westus.api.cognitive.microsoft.com/
// We are providing public endpoint in a free tier to showcase how the app works, feel free to replace these values with your own cognitive services.
public const string ComputerVisionEndpoint = "https://westus.api.cognitive.microsoft.com";
public const string ComputerVisionKey = "1579a0d8658044ad9d3d75a94935699a";
public const string ComputerVisionEndpoint = "INSERT COMPUTER VISION ENDPOINT HERE FOR HANDWRITING";
public const string ComputerVisionKey = "INSERT YOUR COMPUTER VISION KEY HERE FOR HANDWRITING";
// </snippet_comvis_keys>
}
}

Просмотреть файл

@ -9,6 +9,7 @@ namespace VisualProvision.Services.Recognition
{
public class CustomVisionService
{
// <snippet_prediction>
public async Task<PredictionResult> PredictImageContentsAsync(Stream imageStream, CancellationToken cancellationToken)
{
var client = new HttpClient();
@ -26,6 +27,7 @@ namespace VisualProvision.Services.Recognition
var resultJson = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<PredictionResult>(resultJson);
}
// </snippet_prediction>
private byte[] StreamToByteArray(Stream input)
{

Просмотреть файл

@ -1,5 +1,6 @@
namespace VisualProvision.Services.Recognition
{
// <snippet_prediction_class>
public class Prediction
{
public double Probability { get; set; }
@ -10,4 +11,5 @@
public BoundingBox BoundingBox { get; set; }
}
// </snippet_prediction_class>
}

Просмотреть файл

@ -15,6 +15,7 @@ namespace VisualProvision.Services.Recognition
private const int MaxUploadImageSizeBytes = MaxUploadImageSizeMB * 1024 * 1000;
private const double PrecisionThreshold = 0.5;
// <snippet_constants>
private const string TAG_ACTIVE_DIRECTORY = "ACTIVE_DIRECTORY";
private const string TAG_APP_SERVICE = "APP_SERVICE";
private const string TAG_NOTIFICATION_HUBS = "NOTIFICATION_HUBS";
@ -31,6 +32,7 @@ namespace VisualProvision.Services.Recognition
private const string TAG_REDIS_CACHE = "REDIS_CACHE";
private const string TAG_APP_INSIGHTS = "APPLICATION_INSIGHTS";
private const string TAG_AZURE_FUNCTIONS = "AZURE_FUNCTIONS";
// </snippet_constants>
public async Task<IEnumerable<AzureResource>> GetResourcesAsync(MediaFile image)
{