Human analysis Demo- Baidu API

This example is the use of Delphi 7 call Baidu human analysis API; first of all explain how to create a test application.

1, log on Baidu cloud official website https://cloud.baidu.com/ certainly need a Baidu account

2, into the management console, and then select goods and services - artificial intelligence - human analysis

 

 

 3. Create app to get the corresponding API Key Information /

 

4, human traffic statistics: API correspondence address https://cloud.baidu.com/doc/BODY/s/Pjwvxzafo

 

 

 Returns the number and had already rendered images (non-mandatory). I do not know, there is no 17 people.

 

 

There is a small episode when different image types; two bytes of memory stream picture type is generally defined as a word, but I wrote a direct dword, you can check for yourself, what is the difference;

When I was a normal load of photos, it seems there is no difference, jpg picture really is D8FF. But when rendering API call returns statistics in the flow of people will be more than two years, there have been 18D8FF, 4ED8FF.

Finally Dword read Word on it. You can test /

procedure TFrmMain.cxButton2Click(Sender: TObject);
var
  memImg: TMemoryStream;
  strImg: TStringStream;
  sUrl: string;
  lstParam: TStrings;
  ret: ISuperObject;

  buff: dWORD;
begin
  memImg := TMemoryStream.Create;
  strImg := TStringStream.Create('');
  lstParam := TStringList.Create;
  try
    if Image2.Picture.Graphic = nil then
    begin
      ShowMessage('图片为空, 请下加载图片');
      Exit;
    end;
    Image2.Picture.Graphic.SaveToStream(memImg);
    memImg.Position := 0;
    memImg.ReadBuffer(buff, 2);
    memImg.Position := 0;
    EncdDecd.EncodeStream(memImg, strImg);
    lstParam.Add(Format('image=%S', [strImg.DataString]));
    lstParam.Add(Format('show=true', []));
    sUrl := Format(sUrl_TrafficStat, [FToken]);
    ret := SO(UTF8Decode(IdHTTP1.Post(sUrl, lstParam)));
    cxMemo1.Text := ret.AsString;
    Image2.Picture.Bitmap.Assign(StringToBitmap(ret.S['image']));
  finally
    memImg.Free;
    strImg.Free;
    lstParam.Free;
  end;
end;

5, the gesture recognition: address corresponding to API https://cloud.baidu.com/doc/BODY/s/tjwvxz8jp

With one hand than the heart /

 

 Other people try to find out. The key point to identify the body, the body attribute recognition. Feeling is not very fitted, sometimes the returned data is also a problem (json string)

I do not know the problem is not the picture.

 Source (D7) .rar

Guess you like

Origin www.cnblogs.com/adsoft/p/11564023.html