百度云—使用机器人视觉SDK调用百度API方法教程
发布时间:2019-11-16 06:07:43 所属栏目:运营 来源:站长网
导读:副标题#e# 本文将分为两部分:机器人视觉应用的建立和如何使用机器人视觉SDK调用百度API两方面为您一一介绍。 一、机器人视觉应用的建立 使用百度AI平台的在线API之前,首先需要在百度云控制台中建立机器人视觉的应用。 步骤一: 请先前往百度AI开放平台下
C#: using System; using System.Collections.Generic; using System.Net.Http; namespace com.baidu.ai { public static class AccessToken { // 调用getAccessToken()获取的 access_token建议根据expires_in 时间 设置缓存 // 返回token示例 public static String TOKEN = "24.adda70c11b9786206253ddb70affdc46.2592000.1493524354.282335-1234567"; // 百度云中开通对应服务应用的 API Key 建议开通应用的时候多选服务 private static String clientId = "百度云应用的AK"; // 百度云中开通对应服务应用的 Secret Key private static String clientSecret = "百度云应用的SK"; public static String getAccessToken() { String authHost = "https://aip.baidubce.com/oauth/2.0/token"; HttpClient client = new HttpClient(); List<KeyValuePair<String, String>> paraList = new List<KeyValuePair<string, string>>(); paraList.Add(new KeyValuePair<string, string>("grant_type", "client_credentials")); paraList.Add(new KeyValuePair<string, string>("client_id", clientId)); paraList.Add(new KeyValuePair<string, string>("client_secret", clientSecret)); HttpResponseMessage response = client.PostAsync(authHost, new FormUrlEncodedContent(paraList)).Result; String result = response.Content.ReadAsStringAsync().Result; Console.WriteLine(result); return result; } } } (编辑:惠州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |