谷歌休息api反向图像搜索

时间:2018-01-21 20:23:22

标签: image rest api search

我正在尝试使用Google REST API进行反向图像搜索,并在本地存储图像。我正在使用新的 - 未弃用的 - REST API。我可以进行文本搜索并获得结果。我无法使用本地图像进行搜索。我可以对图像进行反向图像搜索并获得结果。有什么建议吗?

我的https字符串是:

https://www.googleapis.com/customsearch/v1?key=A******&cx=0****&q=file:///home/givonz/donald-trump-voicemail-feature.jpg

另外,试过这个https字符串,它也不起作用:

https://www.googleapis.com/customsearch/v1?key=A******&cx=0****&searchType=image&q=file:///home/givonz/donald-trump-voicemail-feature.jpg

此文本字符串搜索有效:

https://www.googleapis.com/customsearch/v1?key=A******&cx=0****&q=Some+String

2 个答案:

答案 0 :(得分:0)

该服务似乎已被弃用,不再作为API提供;它总是需要一个链接(URL)。网上有一些服务似乎提供了这项功能。尽管Bing似乎没有这样做,但似乎并没有。雅虎进行反向搜索,但是,我找不到API。 “Incandescent”确实提供此服务和API。

答案 1 :(得分:0)

这应该有效。确保在标题中传递密钥。

var path = @"YOUR_IMAGE_PATH";
var url = "https://api.cognitive.microsoft.com/bing/v7.0/images/details?modules=similarimages";
using (var client = new HttpClient())
using (Stream imageFileStream = File.OpenRead(path))
{
   var content = new MultipartFormDataContent();
   var strContent = new StreamContent(imageFileStream);
   strContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { FileName = "anynameworks" };
   content.Add(strContent);

   var message = await client.PostAsync(url, content);
   return await message.Content.ReadAsStringAsync();
}
相关问题