Rofxord:如何更改终结点并与API Azure认知服务连接?

时间:2019-02-17 09:57:14

标签: r azure api azure-cognitive-services rjson

我尝试使用Roxford软件包连接Azure认知服务。我错误地归因于错误的端点(将牛津项目纳入Azure服务之后,存在多个特定于区域的端点)。

我从Azure认知服务项目中的个人帐户中获得了密钥:

enter image description here

library(Roxford)
library(plyr)
library(rjson)
facekey <- "xxx"  #look it up on your subscription site
getFaceResponseURL("http://getwallpapers.com/wallpaper/full/5/6/4/1147292-new-women-faces-wallpaper-2880x1800-for-phone.jpg",key= facekey)
#I got error
# {"error":{"code":"Unspecified","message":"Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key."}}

如何将端点更改为:“ https://westcentralus.api.cognitive.microsoft.com/face/v1.0” ???

1 个答案:

答案 0 :(得分:1)

如果您的Roxford库位于此处:https://github.com/flovv/Roxford/blob/master/R/videoAnalysis_LIB.R#L182

然后,您可以在调用方法时添加区域。认知服务键专用于Azure区域,因此使用时应使用相同的区域。如果您忘记了生成密钥时选择的区域,它将写入Azure门户的概述中。

然后,当您使用getFaceResponseUrl时:

getFaceResponseURL <- function(img.url, key, region="westus")

通过区域:

getFaceResponseURL("http://getwallpapers.com/wallpaper/full/5/6/4/1147292-new-women-faces-wallpaper-2880x1800-for-phone.jpg", key=facekey, region="theAzureRegionOfYourKey")