// on recherche le rectangle contenant le symbole
double? left = null, right = null, top = null, bottom = null;

foreach (var path in paths)
{
    foreach (var point in path)
    {
        if (left == null)
        {
            left = point.X;
            right = point.X;
            top = point.Y;
            bottom = point.Y;
        }

        if (point.X < left.Value)
        {
            left = point.X;
        }
        else if (point.X > right.Value)
        {
            right = point.X;
        }

        if (point.Y < top.Value)
        {
            top = point.Y;
        }
        else if (point.Y > bottom.Value)
        {
            bottom = point.Y;
        }
    }
}

Rect boundSymbol = new Rect(left.Value, top.Value, right.Value - left.Value, bottom.Value - top.Value);

double marginHorizontal = (boundSize - boundSymbol.Width) / 2;
double marginVertical = (boundSize - boundSymbol.Height) / 2;

foreach (var path in paths)
{
	...
	foreach (var point in path)
	{
		...
		var x = point.X + marginHorizontal;
		var y = point.Y + marginVertical;
		...
	}
}

foreach (var path in paths)
{
    var normalizedPath = new List<Point>();
    // tous les traits normalisées se trouvent ici
    normalizedPaths.Add(normalizedPath);

    foreach (var point in path)
    {
        var normalizedPoint = new Point();

        var x = point.X + marginHorizontal;
        var y = point.Y + marginVertical;

	// les points x,y sont maintenant compris entre 0 et 1
        normalizedPoint.X = ((x - boundSymbol.Left) / boundSize);
        normalizedPoint.Y = ((y - boundSymbol.Top) / boundSize);

        normalizedPath.Add(normalizedPoint);
    }
}

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Windows.AI.MachineLearning;
using Windows.Media;
using Windows.Storage;

namespace Synergiz.AI.Callygraphy.Tools
{
    public sealed class OnnxModelInput
    {
        public VideoFrame Data { get; set; }
    }

    public sealed class ModelOutput
    {
        public TensorString ClassLabel = TensorString.Create(new long[] { 1, 1 });
        public IList<IDictionary<string, float>> Loss = new List<IDictionary<string, float>>();
    }

    public sealed class OnnxModel
    {
        private LearningModel _learningModel = null;
        private LearningModelSession _session;

        public static async Task<OnnxModel> CreateOnnxModel(StorageFile file)
        {
            LearningModel learningModel = null;

            try
            {
                learningModel = await LearningModel.LoadFromStorageFileAsync(file);
            }
            catch (Exception e)
            {
                var exceptionStr = e.ToString();
                System.Console.WriteLine(exceptionStr);
                throw e;
            }
            return new OnnxModel()
            {
                _learningModel = learningModel,
                _session = new LearningModelSession(learningModel)
            };
        }

        public async Task<ModelOutput> EvaluateAsync(OnnxModelInput input)
        {
            var output = new ModelOutput();
            var binding = new LearningModelBinding(_session);
            binding.Bind("data", input.Data);
            binding.Bind("classLabel", output.ClassLabel);
            binding.Bind("loss", output.Loss);
            LearningModelEvaluationResult evalResult = await _session.EvaluateAsync(binding, "0");

            return output;
        }
    }
}

var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Callygraphy-14.onnx"));
var predictionModel = await OnnxModel.CreateOnnxModel(file);
// frame est de type VideoFrame c'est à dire un objet en provenance d'une vidéo ou d'une //caméra. Une image est facilement transformable en VideoFrame via //VideoFrame.CreateWithSoftwareBitmap(bitmap)
var output = await predictionModel.EvaluateAsync(new OnnxModelInput() { Data = frame });
// traitement du résultat
var vector = output.ClassLabel.GetAsVectorView();
var tagName = vector[0];
var probability = output.Loss[0][product];
Debug.WriteLine("Product=" + tagName + " Loss=" + probability);