zoukankan      html  css  js  c++  java
  • 图像识别,借助百度云,上传图片实现逻辑

    procedure APIAddImage(FileName: string);
    begin
    try
    ResponseStream := TStringStream.Create('');
    SourceStream := TStringStream.Create('');
    try
    URL := 'https://aip.baidubce.com/rest/2.0/image-classify/v1/realtime_search/similar/add?access_token=' + AccessToken;
    imagepath := fImageList[i];
    image := Base64E(imagepath);
    brief := FileName;
    tags := Tag1 + ',' + Tag2;
    SourceStream.WriteString('image=' + httpencode(image) + '&brief=' + httpencode(brief) + '&tags=' + httpencode(tags));
    HttpClient.Request.CustomHeaders.Values['Content-Type'] := 'application/x-www-form-urlencoded';
    HttpClient.Post(URL, SourceStream, ResponseStream);
    JO := SO(ResponseStream.DataString);
    if (JO['error_code'] = nil) or (JO.S['error_code'] = '216681') then
    begin
    log_id := JO.S['log_id'];
    cont_sign := JO.S['cont_sign'];
    InsertImageData(JO.S['log_id'], JO.S['cont_sign']);
    ImagesStr := ResponseStream.DataString;
    end
    else
    begin
    Logs(JO.S['log_id'] + '$' + JO.S['error_code'] + '&' + JO.S['cont_sign'] + '&' + JO.S['error_msg']);
    ImagesStr := ResponseStream.DataString;
    end;
    except
    on e: Exception do
    begin
    Logs('error--' + URL + '--' + imagepath);
    ShowMessage(e.Message);
    end;
    end;
    finally
    ResponseStream.Free;
    SourceStream.Free;
    end;
    end;

  • 相关阅读:
    pyspark使用及原理
    谷歌地图聚合点使用(GoogleMaps MarkerCluster)
    struts2升级到2.5的配置
    二进制反码补码
    进制转换
    JAVA基础第一章
    TypeError: unhashable type: 'list' 如何解决?
    剪辑模板
    Mysql三天入门(三) 数据库设计的三范式
    Mysql三天入门(三) DBA命令
  • 原文地址:https://www.cnblogs.com/zyb2016/p/12572552.html
Copyright © 2011-2022 走看看