This is the GRPC based SDK for the Edgify Agent
Installation instructions:
- Install Grpc and Protobuf with:
- dotnet add package Protobuf
- dotnet add package Grpc
- Add the source files to your solution
Sdk API:
- The sdk contains these API calls:
- GetPrediction - capture an image via the camera and run a prediction (returns a prediction object)
- CreateGroundTruth - save the sample (the response of GetPrediction) and attach a label and source to it
- DeleteSample - deletes a sample based on it's Uuid (originally provided in the response of GetPrediction)
- StartCustomerTransaction - used to inform Edgify upon customer starting a session
- EndCustomerTransaction - used to inform Edgify upon customer ending a session
Sdk files:
- Prediction.cs, PredictionGrpc.cs, Analytics.cs, AnalyticsGrpc.cs, Samples.cs, SamplesGrpc.cs - these are all auto generated by the GRPC framework
- Edgify.cs - the edgify SDK, a wrapper for the GRPC auto generated files
Example files:
- Example.cs - Sample code of how to call the various methods of the Edgify SDK - THIS IS NOT A SUGGESTED USAGE FLOW
Usage example:
using System;
using Edgify;
namespace Example
{
class SyncExample
{
static void Main()
{
// connection phase
var sdk = new EdgifySdk("127.0.0.1", 50051);
sdk.Connect();
// take a prediction
var prediction = sdk.GetPrediction();
// Autobuy flag
if (prediction.Certain == true)
{
Console.WriteLine("using Autobuy");
}
Console.WriteLine("Uuid: " + prediction.Uuid);
Console.WriteLine("Predictions: " + prediction.Predictions);
// after the transaction create the ground truth
string label = "banana";
string source = "RegularMenuSelection";
sdk.CreateGroundTruth(prediction, label, source);
// if you need to delete a sample
sdk.DeleteSample(prediction.Uuid);
// inform edgify on transaction start
sdk.StartCustomerTransaction();
// inform edgify on transaction end
sdk.EndCustomerTransaction();
// when you done with the sdk (usually on dispose)
sdk.Disconnect();
}
}
class ASyncExample
{
static async void MainAsync()
{
// connection phase
var sdk = new EdgifySdk("127.0.0.1", 50051);
sdk.Connect();
// take a prediction
var prediction = await sdk.GetPredictionAsync();
// Autobuy flag
if (prediction.Certain == true)
{
Console.WriteLine("using Autobuy");
}
Console.WriteLine("Uuid: " + prediction.Uuid);
Console.WriteLine("Predictions: " + prediction.Predictions);
// after the transaction create the ground truth
string label = "banana";
string source = "RegularMenuSelection";
await sdk.CreateGroundTruthAsync(prediction, label, source);
// if you need to delete a sample
await sdk.DeleteSampleAsync(prediction.Uuid);
// inform edgify on transaction start
sdk.StartCustomerTransactionAsync();
// inform edgify on transaction end
sdk.EndCustomerTransactionAsync();
// when you done with the sdk (usually on dispose)
sdk.Disconnect();
}
}
}