27-05-2021, 07:45 PM
Detecting Logos On Images Using Google Cloud Vision API
![[صورة: starbucks2-9180061.png?resize=768%2C620&ssl=1]](https://i1.wp.com/blogs.embarcadero.com/wp-content/uploads/2021/05/starbucks2-9180061.png?resize=768%2C620&ssl=1)
![[صورة: starbucks2-9180061.png?resize=768%2C620&ssl=1]](https://i1.wp.com/blogs.embarcadero.com/wp-content/uploads/2021/05/starbucks2-9180061.png?resize=768%2C620&ssl=1)
كود :
POST https://vision.googleapis.com/v1/images:annotate
{
"requests": [
{
"features": [
{
"type": "LOGO_DETECTION"
}],
"image": {
"source": {
"imageUri": "https://images.pexels.com/photos/791942/pexels-photo-791942.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
}}}]}
procedure TForm1.Button1Click(Sender: TObject);
var
APIkey: String;
begin
FDMemTable1.Active := False;
RESTClient1.ResetToDefaults;
RESTClient1.Accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
RESTClient1.AcceptCharset := 'UTF-8, *;q=0.8';
RESTClient1.BaseURL := 'https://vision.googleapis.com';
RESTClient1.HandleRedirects := True;
RESTClient1.RaiseExceptionOn500 := False;
//APIkey := 'put here your Google API key';
RESTRequest1.Resource := Format('v1/images:annotate?key=%s', [APIkey]);
RESTRequest1.Client := RESTClient1;
RESTRequest1.Response := RESTResponse1;
RESTRequest1.SynchronizedEvents := False;
RESTResponse1.ContentType := 'application/json';
RESTRequest1.Params[0].Value := Format(
'{"requests": [{"features": [{"maxResults": %s,"type": "LOGO_DETECTION"}],"image": {'+
'"source": {"imageUri": "%s"}}}]}', [Edit2.text, Edit1.text]);
RESTResponse1.RootElement := 'responses[0].logoAnnotations';
RESTRequest1.Execute;
memo2.Lines := RESTResponse1.Headers;
memo3.Lines.text := RESTResponse1.Content;
end;