コード例 #1
0
        public async void Simple()
        {
            var secrets          = new SecretsProvider().Get();
            var client           = new IamTokenClient();
            var privateKeyStream = new MemoryStream(Encoding.UTF8.GetBytes(secrets.AuthorizationKeyPrivateKey));
            var iamToken         = await client.Get(
                secrets.ServiceAccountId,
                secrets.AuthorizationKeyId,
                privateKeyStream
                );

            output.WriteLine(iamToken);
        }
コード例 #2
0
        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));
        }