直接上代码
服务端代码如下
private static readonly Baidu.Aip.ImageClassify.ImageClassify client = new Baidu.Aip.ImageClassify.ImageClassify(ApiConfig.APIKey, ApiConfig.SecretKey);
///
/// 植物识别
///
///
public PlantModel PlantDetect(string filesrc)
{
var image = File.ReadAllBytes(filesrc);
var result = client.PlantDetect(image);
return GetPlant(result);
}
///
/// 植物识别
///
///
///
public JsonResult PlantDetect(string serverId = "")
{
string filename = System.Web.HttpContext.Current.Server.MapPath("/Static/img/demoplant.jpg");
if (!string.IsNullOrWhiteSpace(serverId))
{
filename = GetFileName(serverId);
}
var data = imageClassify.PlantDetect(filename);
return Json(