ImageEn, unit iexGoogleApi

TIEGoogleVision.RequestTypes

TIEGoogleVision.RequestTypes


Declaration

property RequestTypes: TIEGRequestTypes;


Description

Specify what Google Vision detection operations to call.

Value Google Feature Description
iegrWebDetection WEB_DETECTION Run web detection
iegrSafeSearchDetection SAFE_SEARCH_DETECTION Run Safe Search to detect potentially unsafe or undesirable content
iegrLabelDetection LABEL_DETECTION Run label detection
iegrObjectLocalization OBJECT_LOCALIZATION Run localizer for object detection
iegrFaceDetection FACE_DETECTION Run face detection
iegrLandmarkDetection LANDMARK_DETECTION Run landmark detection
iegrLogoDetection LOGO_DETECTION Run logo detection
iegrTextDetection TEXT_DETECTION Run text detection / optical character recognition (OCR). Text detection is optimized for areas of text within a larger image; if the image is a document, use iegrDocumentTextDetection, instead
iegrDocumentTextDetection DOCUMENT_TEXT_DETECTION Run dense text document OCR. Takes precedence over iegrTextDetection (Unhandled)
iegrCropHintsDetection CROP_HINTS Run crop hints
iegrProductSearch PRODUCT_SEARCH Run Product Search (Unhandled)
iegrImageProperties IMAGE_PROPERTIES Compute a set of image properties, such as the image's dominant colors

Note: After changing the RequestTypes you must call ProcessImage again to update your results.

Default: [iegrFaceDetection, iegrLandmarkDetection, iegrLogoDetection, iegrLabelDetection,
          iegrTextDetection, iegrSafeSearchDetection, iegrCropHintsDetection, iegrWebDetection,
          iegrObjectLocalization]


Example

Cursor := crHourglass;
lblSubmitting.Visible := True;
GVision := TIEGoogleVision.Create( MY_API_KEY );
try
  // Use recommended delivery size (for faster processing)
  GVision.SendImageWidth  := 640;
  GVision.SendImageHeight := 480;

  GVision.RequestTypes := [iegrWebDetection, iegrSafeSearchDetection, iegrLandmarkDetection];
  GVision.ProcessImage( edtFilename.Text );

  lbxResults.Clear();

  if Length( GVision.WebDetection.bestGuessLabels ) > 0 then
  lbxResults.Items.Add( 'This image is likely to be: ' + GVision.WebDetection.bestGuessLabels[0].webLabel );

  if GVision.HasLandmarkAnnotations then
  begin
    lbxResults.Items.Add( 'This image is the landmark: ' + GVision.LandmarkAnnotations[0].description );
    lbxResults.Items.Add( 'Latitude: '  + LatLongToStr( GVision.LandmarkAnnotations[0].latitude, True ));
    lbxResults.Items.Add( 'Longitude: ' + LatLongToStr( GVision.LandmarkAnnotations[0].longitude, False ));
  end;

  lbxResults.Items.Add( format( 'Found %d matching images on the web', [ GVision.WebDetection.fullMatchingImages.Count ]));
  lbxResults.Items.AddStrings( GVision.WebDetection.fullMatchingImages );

  lbxResults.Items.Add( format( 'Found %d pages on the web containing this image', [ GVision.WebDetection.pagesWithMatchingImages.Count ]));
  lbxResults.Items.AddStrings( GVision.WebDetection.pagesWithMatchingImages );

  if GVision.SafeSearchAnnotation.adult in [ieglLikely, ieglVeryLikely] then
  lbxResults.Items.Add( 'Likely to be an ADULT image' );

  if GVision.SafeSearchAnnotation.violence in [ieglLikely, ieglVeryLikely] then
  lbxResults.Items.Add( 'Likely to be an VIOLENT image' );

  if GVision.SafeSearchAnnotation.violence in [ieglLikely, ieglVeryLikely] then
  lbxResults.Items.Add( 'Likely to be an VIOLENT image' );
finally
  Cursor := crDefault;
  lblSubmitting.Visible := False;
  GVision.Free;
end;


See Also

 ProcessImage