public MainWindow()
        {
            InitializeComponent();
            var url             = "https://brazilsouth.api.cognitive.microsoft.com";
            var token           = Environment.GetEnvironmentVariable("AZURE-COGNITIVESERVICES-TOKEN", EnvironmentVariableTarget.User);
            var predictionToken = Environment.GetEnvironmentVariable("AZURE-CUSTOMVISION-PREDICTION-TOKEN", EnvironmentVariableTarget.User);

            token           = "bf5c88d9a9a84747a2d4bd0170bb4f7c";
            predictionToken = "7222807f92cc4776aa6da5c888ec06f5";

            _visionClient            = new VisionClient(token, url);
            _customVisionClient      = new CustomVisionClient(predictionToken);
            _localCustomVisionClient = new LocalCustomVisionClient();
            _currentProjectId        = _projectIdBolacha;
        }
Beispiel #2
0
 // Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.
 void Start()
 {
     rb            = GetComponent <Rigidbody> ();
     myEV3         = new EV3WifiOrSimulation();
     myVision      = new VisionClient();
     startPosition = rb.transform.position;
     startRotation = rb.rotation;
     targetObject  = GameObject.Find("Ball");
     // bBot and ball dimensions are used to position the Bot behind the ball before shooring and to determine marker height.
     botLength  = rb.transform.localScale.z;
     botHeight  = rb.transform.localScale.y;
     ballRadius = GameObject.Find("Ball").transform.localScale.x / 2.0f;
     rb.transform.localScale = new Vector3(15.0f, 12.5f, 26.0f);
     lineRenderer            = GetComponent <LineRenderer> ();
     goalPosition            = GameObject.Find("GoalLeft").transform.position;
     // Small correction to put target just behind the goal line
     behindGoalPosition = goalPosition + new Vector3(Math.Sign(goalPosition.x) * 10.0f, 0.0f, 0.0f);
 }
        public async void Simple()
        {
            var secrets          = new SecretsProvider().Get();
            var iamTokenClient   = new IamTokenClient();
            var privateKeyStream = new MemoryStream(Encoding.UTF8.GetBytes(secrets.AuthorizationKeyPrivateKey));
            var iamToken         = await iamTokenClient.Get(
                secrets.ServiceAccountId,
                secrets.AuthorizationKeyId,
                privateKeyStream
                );

            var client = new VisionClient();
            var image  = File.OpenRead("Vision/image.png");
            var result = await client.RecognizeText(
                secrets.FolderId,
                iamToken,
                image,
                new[]
            {
                "ru", "en"
            }
                );

            var words = result.Single()
                        .Results.Single()
                        .TextDetection
                        .Pages.Single()
                        .Blocks.Single()
                        .Lines.Single()
                        .Words;

            words.Select(x => x.Text)
            .ShouldBe(
                new[]
            {
                "Какой-то", "текст"
            }
                );
            output.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
        }