我尝试使用Roxford包连接Azure Cognitive Service。由于错误的端点,我得到了错误(在将牛津项目纳入Azure服务之后,有几个特定于区域的端点)。
我从Azure Cognitive Service项目的个人帐户中获取了密钥:
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”???
如果你的Roxford
lib就在这里:https://github.com/flovv/Roxford/blob/master/R/videoAnalysis_LIB.R#L182
然后,您可以在调用方法时添加区域。 Cognitive Services密钥专用于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")