{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Rekognition.DetectLabels
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Detects instances of real-world entities within an image (JPEG or PNG)
-- provided as input. This includes objects like flower, tree, and table;
-- events like wedding, graduation, and birthday party; and concepts like
-- landscape, evening, and nature.
--
-- For an example, see Analyzing images stored in an Amazon S3 bucket in
-- the Amazon Rekognition Developer Guide.
--
-- You pass the input image as base64-encoded image bytes or as a reference
-- to an image in an Amazon S3 bucket. If you use the AWS CLI to call
-- Amazon Rekognition operations, passing image bytes is not supported. The
-- image must be either a PNG or JPEG formatted file.
--
-- __Optional Parameters__
--
-- You can specify one or both of the @GENERAL_LABELS@ and
-- @IMAGE_PROPERTIES@ feature types when calling the DetectLabels API.
-- Including @GENERAL_LABELS@ will ensure the response includes the labels
-- detected in the input image, while including @IMAGE_PROPERTIES @will
-- ensure the response includes information about the image quality and
-- color.
--
-- When using @GENERAL_LABELS@ and\/or @IMAGE_PROPERTIES@ you can provide
-- filtering criteria to the Settings parameter. You can filter with sets
-- of individual labels or with label categories. You can specify inclusive
-- filters, exclusive filters, or a combination of inclusive and exclusive
-- filters. For more information on filtering see
-- <https://docs.aws.amazon.com/rekognition/latest/dg/labels-detect-labels-image.html Detecting Labels in an Image>.
--
-- You can specify @MinConfidence@ to control the confidence threshold for
-- the labels returned. The default is 55%. You can also add the
-- @MaxLabels@ parameter to limit the number of labels returned. The
-- default and upper limit is 1000 labels.
--
-- __Response Elements__
--
-- For each object, scene, and concept the API returns one or more labels.
-- The API returns the following types of information regarding labels:
--
-- -   Name - The name of the detected label.
--
-- -   Confidence - The level of confidence in the label assigned to a
--     detected object.
--
-- -   Parents - The ancestor labels for a detected label. DetectLabels
--     returns a hierarchical taxonomy of detected labels. For example, a
--     detected car might be assigned the label car. The label car has two
--     parent labels: Vehicle (its parent) and Transportation (its
--     grandparent). The response includes the all ancestors for a label,
--     where every ancestor is a unique label. In the previous example,
--     Car, Vehicle, and Transportation are returned as unique labels in
--     the response.
--
-- -   Aliases - Possible Aliases for the label.
--
-- -   Categories - The label categories that the detected label belongs
--     to.
--
-- -   BoundingBox — Bounding boxes are described for all instances of
--     detected common object labels, returned in an array of Instance
--     objects. An Instance object contains a BoundingBox object,
--     describing the location of the label on the input image. It also
--     includes the confidence for the accuracy of the detected bounding
--     box.
--
-- The API returns the following information regarding the image, as part
-- of the ImageProperties structure:
--
-- -   Quality - Information about the Sharpness, Brightness, and Contrast
--     of the input image, scored between 0 to 100. Image quality is
--     returned for the entire image, as well as the background and the
--     foreground.
--
-- -   Dominant Color - An array of the dominant colors in the image.
--
-- -   Foreground - Information about the sharpness, brightness, and
--     dominant colors of the input image’s foreground.
--
-- -   Background - Information about the sharpness, brightness, and
--     dominant colors of the input image’s background.
--
-- The list of returned labels will include at least one label for every
-- detected object, along with information about that label. In the
-- following example, suppose the input image has a lighthouse, the sea,
-- and a rock. The response includes all three labels, one for each object,
-- as well as the confidence in the label:
--
-- @{Name: lighthouse, Confidence: 98.4629}@
--
-- @{Name: rock,Confidence: 79.2097}@
--
-- @ {Name: sea,Confidence: 75.061}@
--
-- The list of labels can include multiple labels for the same object. For
-- example, if the input image shows a flower (for example, a tulip), the
-- operation might return the following three labels.
--
-- @{Name: flower,Confidence: 99.0562}@
--
-- @{Name: plant,Confidence: 99.0562}@
--
-- @{Name: tulip,Confidence: 99.0562}@
--
-- In this example, the detection algorithm more precisely identifies the
-- flower as a tulip.
--
-- If the object detected is a person, the operation doesn\'t provide the
-- same facial details that the DetectFaces operation provides.
--
-- This is a stateless API operation. That is, the operation does not
-- persist any data.
--
-- This operation requires permissions to perform the
-- @rekognition:DetectLabels@ action.
module Amazonka.Rekognition.DetectLabels
  ( -- * Creating a Request
    DetectLabels (..),
    newDetectLabels,

    -- * Request Lenses
    detectLabels_features,
    detectLabels_maxLabels,
    detectLabels_minConfidence,
    detectLabels_settings,
    detectLabels_image,

    -- * Destructuring the Response
    DetectLabelsResponse (..),
    newDetectLabelsResponse,

    -- * Response Lenses
    detectLabelsResponse_imageProperties,
    detectLabelsResponse_labelModelVersion,
    detectLabelsResponse_labels,
    detectLabelsResponse_orientationCorrection,
    detectLabelsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDetectLabels' smart constructor.
data DetectLabels = DetectLabels'
  { -- | A list of the types of analysis to perform. Specifying GENERAL_LABELS
    -- uses the label detection feature, while specifying IMAGE_PROPERTIES
    -- returns information regarding image color and quality. If no option is
    -- specified GENERAL_LABELS is used by default.
    DetectLabels -> Maybe [DetectLabelsFeatureName]
features :: Prelude.Maybe [DetectLabelsFeatureName],
    -- | Maximum number of labels you want the service to return in the response.
    -- The service returns the specified number of highest confidence labels.
    DetectLabels -> Maybe Natural
maxLabels :: Prelude.Maybe Prelude.Natural,
    -- | Specifies the minimum confidence level for the labels to return. Amazon
    -- Rekognition doesn\'t return any labels with confidence lower than this
    -- specified value.
    --
    -- If @MinConfidence@ is not specified, the operation returns labels with a
    -- confidence values greater than or equal to 55 percent.
    DetectLabels -> Maybe Double
minConfidence :: Prelude.Maybe Prelude.Double,
    -- | A list of the filters to be applied to returned detected labels and
    -- image properties. Specified filters can be inclusive, exclusive, or a
    -- combination of both. Filters can be used for individual labels or label
    -- categories. The exact label names or label categories must be supplied.
    -- For a full list of labels and label categories, see LINK HERE.
    DetectLabels -> Maybe DetectLabelsSettings
settings :: Prelude.Maybe DetectLabelsSettings,
    -- | The input image as base64-encoded bytes or an S3 object. If you use the
    -- AWS CLI to call Amazon Rekognition operations, passing image bytes is
    -- not supported. Images stored in an S3 Bucket do not need to be
    -- base64-encoded.
    --
    -- If you are using an AWS SDK to call Amazon Rekognition, you might not
    -- need to base64-encode image bytes passed using the @Bytes@ field. For
    -- more information, see Images in the Amazon Rekognition developer guide.
    DetectLabels -> Image
image :: Image
  }
  deriving (DetectLabels -> DetectLabels -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectLabels -> DetectLabels -> Bool
$c/= :: DetectLabels -> DetectLabels -> Bool
== :: DetectLabels -> DetectLabels -> Bool
$c== :: DetectLabels -> DetectLabels -> Bool
Prelude.Eq, ReadPrec [DetectLabels]
ReadPrec DetectLabels
Int -> ReadS DetectLabels
ReadS [DetectLabels]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectLabels]
$creadListPrec :: ReadPrec [DetectLabels]
readPrec :: ReadPrec DetectLabels
$creadPrec :: ReadPrec DetectLabels
readList :: ReadS [DetectLabels]
$creadList :: ReadS [DetectLabels]
readsPrec :: Int -> ReadS DetectLabels
$creadsPrec :: Int -> ReadS DetectLabels
Prelude.Read, Int -> DetectLabels -> ShowS
[DetectLabels] -> ShowS
DetectLabels -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectLabels] -> ShowS
$cshowList :: [DetectLabels] -> ShowS
show :: DetectLabels -> String
$cshow :: DetectLabels -> String
showsPrec :: Int -> DetectLabels -> ShowS
$cshowsPrec :: Int -> DetectLabels -> ShowS
Prelude.Show, forall x. Rep DetectLabels x -> DetectLabels
forall x. DetectLabels -> Rep DetectLabels x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectLabels x -> DetectLabels
$cfrom :: forall x. DetectLabels -> Rep DetectLabels x
Prelude.Generic)

-- |
-- Create a value of 'DetectLabels' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'features', 'detectLabels_features' - A list of the types of analysis to perform. Specifying GENERAL_LABELS
-- uses the label detection feature, while specifying IMAGE_PROPERTIES
-- returns information regarding image color and quality. If no option is
-- specified GENERAL_LABELS is used by default.
--
-- 'maxLabels', 'detectLabels_maxLabels' - Maximum number of labels you want the service to return in the response.
-- The service returns the specified number of highest confidence labels.
--
-- 'minConfidence', 'detectLabels_minConfidence' - Specifies the minimum confidence level for the labels to return. Amazon
-- Rekognition doesn\'t return any labels with confidence lower than this
-- specified value.
--
-- If @MinConfidence@ is not specified, the operation returns labels with a
-- confidence values greater than or equal to 55 percent.
--
-- 'settings', 'detectLabels_settings' - A list of the filters to be applied to returned detected labels and
-- image properties. Specified filters can be inclusive, exclusive, or a
-- combination of both. Filters can be used for individual labels or label
-- categories. The exact label names or label categories must be supplied.
-- For a full list of labels and label categories, see LINK HERE.
--
-- 'image', 'detectLabels_image' - The input image as base64-encoded bytes or an S3 object. If you use the
-- AWS CLI to call Amazon Rekognition operations, passing image bytes is
-- not supported. Images stored in an S3 Bucket do not need to be
-- base64-encoded.
--
-- If you are using an AWS SDK to call Amazon Rekognition, you might not
-- need to base64-encode image bytes passed using the @Bytes@ field. For
-- more information, see Images in the Amazon Rekognition developer guide.
newDetectLabels ::
  -- | 'image'
  Image ->
  DetectLabels
newDetectLabels :: Image -> DetectLabels
newDetectLabels Image
pImage_ =
  DetectLabels'
    { $sel:features:DetectLabels' :: Maybe [DetectLabelsFeatureName]
features = forall a. Maybe a
Prelude.Nothing,
      $sel:maxLabels:DetectLabels' :: Maybe Natural
maxLabels = forall a. Maybe a
Prelude.Nothing,
      $sel:minConfidence:DetectLabels' :: Maybe Double
minConfidence = forall a. Maybe a
Prelude.Nothing,
      $sel:settings:DetectLabels' :: Maybe DetectLabelsSettings
settings = forall a. Maybe a
Prelude.Nothing,
      $sel:image:DetectLabels' :: Image
image = Image
pImage_
    }

-- | A list of the types of analysis to perform. Specifying GENERAL_LABELS
-- uses the label detection feature, while specifying IMAGE_PROPERTIES
-- returns information regarding image color and quality. If no option is
-- specified GENERAL_LABELS is used by default.
detectLabels_features :: Lens.Lens' DetectLabels (Prelude.Maybe [DetectLabelsFeatureName])
detectLabels_features :: Lens' DetectLabels (Maybe [DetectLabelsFeatureName])
detectLabels_features = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabels' {Maybe [DetectLabelsFeatureName]
features :: Maybe [DetectLabelsFeatureName]
$sel:features:DetectLabels' :: DetectLabels -> Maybe [DetectLabelsFeatureName]
features} -> Maybe [DetectLabelsFeatureName]
features) (\s :: DetectLabels
s@DetectLabels' {} Maybe [DetectLabelsFeatureName]
a -> DetectLabels
s {$sel:features:DetectLabels' :: Maybe [DetectLabelsFeatureName]
features = Maybe [DetectLabelsFeatureName]
a} :: DetectLabels) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Maximum number of labels you want the service to return in the response.
-- The service returns the specified number of highest confidence labels.
detectLabels_maxLabels :: Lens.Lens' DetectLabels (Prelude.Maybe Prelude.Natural)
detectLabels_maxLabels :: Lens' DetectLabels (Maybe Natural)
detectLabels_maxLabels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabels' {Maybe Natural
maxLabels :: Maybe Natural
$sel:maxLabels:DetectLabels' :: DetectLabels -> Maybe Natural
maxLabels} -> Maybe Natural
maxLabels) (\s :: DetectLabels
s@DetectLabels' {} Maybe Natural
a -> DetectLabels
s {$sel:maxLabels:DetectLabels' :: Maybe Natural
maxLabels = Maybe Natural
a} :: DetectLabels)

-- | Specifies the minimum confidence level for the labels to return. Amazon
-- Rekognition doesn\'t return any labels with confidence lower than this
-- specified value.
--
-- If @MinConfidence@ is not specified, the operation returns labels with a
-- confidence values greater than or equal to 55 percent.
detectLabels_minConfidence :: Lens.Lens' DetectLabels (Prelude.Maybe Prelude.Double)
detectLabels_minConfidence :: Lens' DetectLabels (Maybe Double)
detectLabels_minConfidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabels' {Maybe Double
minConfidence :: Maybe Double
$sel:minConfidence:DetectLabels' :: DetectLabels -> Maybe Double
minConfidence} -> Maybe Double
minConfidence) (\s :: DetectLabels
s@DetectLabels' {} Maybe Double
a -> DetectLabels
s {$sel:minConfidence:DetectLabels' :: Maybe Double
minConfidence = Maybe Double
a} :: DetectLabels)

-- | A list of the filters to be applied to returned detected labels and
-- image properties. Specified filters can be inclusive, exclusive, or a
-- combination of both. Filters can be used for individual labels or label
-- categories. The exact label names or label categories must be supplied.
-- For a full list of labels and label categories, see LINK HERE.
detectLabels_settings :: Lens.Lens' DetectLabels (Prelude.Maybe DetectLabelsSettings)
detectLabels_settings :: Lens' DetectLabels (Maybe DetectLabelsSettings)
detectLabels_settings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabels' {Maybe DetectLabelsSettings
settings :: Maybe DetectLabelsSettings
$sel:settings:DetectLabels' :: DetectLabels -> Maybe DetectLabelsSettings
settings} -> Maybe DetectLabelsSettings
settings) (\s :: DetectLabels
s@DetectLabels' {} Maybe DetectLabelsSettings
a -> DetectLabels
s {$sel:settings:DetectLabels' :: Maybe DetectLabelsSettings
settings = Maybe DetectLabelsSettings
a} :: DetectLabels)

-- | The input image as base64-encoded bytes or an S3 object. If you use the
-- AWS CLI to call Amazon Rekognition operations, passing image bytes is
-- not supported. Images stored in an S3 Bucket do not need to be
-- base64-encoded.
--
-- If you are using an AWS SDK to call Amazon Rekognition, you might not
-- need to base64-encode image bytes passed using the @Bytes@ field. For
-- more information, see Images in the Amazon Rekognition developer guide.
detectLabels_image :: Lens.Lens' DetectLabels Image
detectLabels_image :: Lens' DetectLabels Image
detectLabels_image = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabels' {Image
image :: Image
$sel:image:DetectLabels' :: DetectLabels -> Image
image} -> Image
image) (\s :: DetectLabels
s@DetectLabels' {} Image
a -> DetectLabels
s {$sel:image:DetectLabels' :: Image
image = Image
a} :: DetectLabels)

instance Core.AWSRequest DetectLabels where
  type AWSResponse DetectLabels = DetectLabelsResponse
  request :: (Service -> Service) -> DetectLabels -> Request DetectLabels
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DetectLabels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetectLabels)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DetectLabelsImageProperties
-> Maybe Text
-> Maybe [Label]
-> Maybe OrientationCorrection
-> Int
-> DetectLabelsResponse
DetectLabelsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ImageProperties")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"LabelModelVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Labels" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"OrientationCorrection")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DetectLabels where
  hashWithSalt :: Int -> DetectLabels -> Int
hashWithSalt Int
_salt DetectLabels' {Maybe Double
Maybe Natural
Maybe [DetectLabelsFeatureName]
Maybe DetectLabelsSettings
Image
image :: Image
settings :: Maybe DetectLabelsSettings
minConfidence :: Maybe Double
maxLabels :: Maybe Natural
features :: Maybe [DetectLabelsFeatureName]
$sel:image:DetectLabels' :: DetectLabels -> Image
$sel:settings:DetectLabels' :: DetectLabels -> Maybe DetectLabelsSettings
$sel:minConfidence:DetectLabels' :: DetectLabels -> Maybe Double
$sel:maxLabels:DetectLabels' :: DetectLabels -> Maybe Natural
$sel:features:DetectLabels' :: DetectLabels -> Maybe [DetectLabelsFeatureName]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DetectLabelsFeatureName]
features
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxLabels
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
minConfidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DetectLabelsSettings
settings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Image
image

instance Prelude.NFData DetectLabels where
  rnf :: DetectLabels -> ()
rnf DetectLabels' {Maybe Double
Maybe Natural
Maybe [DetectLabelsFeatureName]
Maybe DetectLabelsSettings
Image
image :: Image
settings :: Maybe DetectLabelsSettings
minConfidence :: Maybe Double
maxLabels :: Maybe Natural
features :: Maybe [DetectLabelsFeatureName]
$sel:image:DetectLabels' :: DetectLabels -> Image
$sel:settings:DetectLabels' :: DetectLabels -> Maybe DetectLabelsSettings
$sel:minConfidence:DetectLabels' :: DetectLabels -> Maybe Double
$sel:maxLabels:DetectLabels' :: DetectLabels -> Maybe Natural
$sel:features:DetectLabels' :: DetectLabels -> Maybe [DetectLabelsFeatureName]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DetectLabelsFeatureName]
features
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxLabels
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
minConfidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DetectLabelsSettings
settings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Image
image

instance Data.ToHeaders DetectLabels where
  toHeaders :: DetectLabels -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"RekognitionService.DetectLabels" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DetectLabels where
  toJSON :: DetectLabels -> Value
toJSON DetectLabels' {Maybe Double
Maybe Natural
Maybe [DetectLabelsFeatureName]
Maybe DetectLabelsSettings
Image
image :: Image
settings :: Maybe DetectLabelsSettings
minConfidence :: Maybe Double
maxLabels :: Maybe Natural
features :: Maybe [DetectLabelsFeatureName]
$sel:image:DetectLabels' :: DetectLabels -> Image
$sel:settings:DetectLabels' :: DetectLabels -> Maybe DetectLabelsSettings
$sel:minConfidence:DetectLabels' :: DetectLabels -> Maybe Double
$sel:maxLabels:DetectLabels' :: DetectLabels -> Maybe Natural
$sel:features:DetectLabels' :: DetectLabels -> Maybe [DetectLabelsFeatureName]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Features" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DetectLabelsFeatureName]
features,
            (Key
"MaxLabels" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxLabels,
            (Key
"MinConfidence" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
minConfidence,
            (Key
"Settings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DetectLabelsSettings
settings,
            forall a. a -> Maybe a
Prelude.Just (Key
"Image" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Image
image)
          ]
      )

instance Data.ToPath DetectLabels where
  toPath :: DetectLabels -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery DetectLabels where
  toQuery :: DetectLabels -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDetectLabelsResponse' smart constructor.
data DetectLabelsResponse = DetectLabelsResponse'
  { -- | Information about the properties of the input image, such as brightness,
    -- sharpness, contrast, and dominant colors.
    DetectLabelsResponse -> Maybe DetectLabelsImageProperties
imageProperties :: Prelude.Maybe DetectLabelsImageProperties,
    -- | Version number of the label detection model that was used to detect
    -- labels.
    DetectLabelsResponse -> Maybe Text
labelModelVersion :: Prelude.Maybe Prelude.Text,
    -- | An array of labels for the real-world objects detected.
    DetectLabelsResponse -> Maybe [Label]
labels :: Prelude.Maybe [Label],
    -- | The value of @OrientationCorrection@ is always null.
    --
    -- If the input image is in .jpeg format, it might contain exchangeable
    -- image file format (Exif) metadata that includes the image\'s
    -- orientation. Amazon Rekognition uses this orientation information to
    -- perform image correction. The bounding box coordinates are translated to
    -- represent object locations after the orientation information in the Exif
    -- metadata is used to correct the image orientation. Images in .png format
    -- don\'t contain Exif metadata.
    --
    -- Amazon Rekognition doesn’t perform image correction for images in .png
    -- format and .jpeg images without orientation information in the image
    -- Exif metadata. The bounding box coordinates aren\'t translated and
    -- represent the object locations before the image is rotated.
    DetectLabelsResponse -> Maybe OrientationCorrection
orientationCorrection :: Prelude.Maybe OrientationCorrection,
    -- | The response's http status code.
    DetectLabelsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DetectLabelsResponse -> DetectLabelsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectLabelsResponse -> DetectLabelsResponse -> Bool
$c/= :: DetectLabelsResponse -> DetectLabelsResponse -> Bool
== :: DetectLabelsResponse -> DetectLabelsResponse -> Bool
$c== :: DetectLabelsResponse -> DetectLabelsResponse -> Bool
Prelude.Eq, ReadPrec [DetectLabelsResponse]
ReadPrec DetectLabelsResponse
Int -> ReadS DetectLabelsResponse
ReadS [DetectLabelsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectLabelsResponse]
$creadListPrec :: ReadPrec [DetectLabelsResponse]
readPrec :: ReadPrec DetectLabelsResponse
$creadPrec :: ReadPrec DetectLabelsResponse
readList :: ReadS [DetectLabelsResponse]
$creadList :: ReadS [DetectLabelsResponse]
readsPrec :: Int -> ReadS DetectLabelsResponse
$creadsPrec :: Int -> ReadS DetectLabelsResponse
Prelude.Read, Int -> DetectLabelsResponse -> ShowS
[DetectLabelsResponse] -> ShowS
DetectLabelsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectLabelsResponse] -> ShowS
$cshowList :: [DetectLabelsResponse] -> ShowS
show :: DetectLabelsResponse -> String
$cshow :: DetectLabelsResponse -> String
showsPrec :: Int -> DetectLabelsResponse -> ShowS
$cshowsPrec :: Int -> DetectLabelsResponse -> ShowS
Prelude.Show, forall x. Rep DetectLabelsResponse x -> DetectLabelsResponse
forall x. DetectLabelsResponse -> Rep DetectLabelsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectLabelsResponse x -> DetectLabelsResponse
$cfrom :: forall x. DetectLabelsResponse -> Rep DetectLabelsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DetectLabelsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'imageProperties', 'detectLabelsResponse_imageProperties' - Information about the properties of the input image, such as brightness,
-- sharpness, contrast, and dominant colors.
--
-- 'labelModelVersion', 'detectLabelsResponse_labelModelVersion' - Version number of the label detection model that was used to detect
-- labels.
--
-- 'labels', 'detectLabelsResponse_labels' - An array of labels for the real-world objects detected.
--
-- 'orientationCorrection', 'detectLabelsResponse_orientationCorrection' - The value of @OrientationCorrection@ is always null.
--
-- If the input image is in .jpeg format, it might contain exchangeable
-- image file format (Exif) metadata that includes the image\'s
-- orientation. Amazon Rekognition uses this orientation information to
-- perform image correction. The bounding box coordinates are translated to
-- represent object locations after the orientation information in the Exif
-- metadata is used to correct the image orientation. Images in .png format
-- don\'t contain Exif metadata.
--
-- Amazon Rekognition doesn’t perform image correction for images in .png
-- format and .jpeg images without orientation information in the image
-- Exif metadata. The bounding box coordinates aren\'t translated and
-- represent the object locations before the image is rotated.
--
-- 'httpStatus', 'detectLabelsResponse_httpStatus' - The response's http status code.
newDetectLabelsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DetectLabelsResponse
newDetectLabelsResponse :: Int -> DetectLabelsResponse
newDetectLabelsResponse Int
pHttpStatus_ =
  DetectLabelsResponse'
    { $sel:imageProperties:DetectLabelsResponse' :: Maybe DetectLabelsImageProperties
imageProperties =
        forall a. Maybe a
Prelude.Nothing,
      $sel:labelModelVersion:DetectLabelsResponse' :: Maybe Text
labelModelVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:labels:DetectLabelsResponse' :: Maybe [Label]
labels = forall a. Maybe a
Prelude.Nothing,
      $sel:orientationCorrection:DetectLabelsResponse' :: Maybe OrientationCorrection
orientationCorrection = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DetectLabelsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the properties of the input image, such as brightness,
-- sharpness, contrast, and dominant colors.
detectLabelsResponse_imageProperties :: Lens.Lens' DetectLabelsResponse (Prelude.Maybe DetectLabelsImageProperties)
detectLabelsResponse_imageProperties :: Lens' DetectLabelsResponse (Maybe DetectLabelsImageProperties)
detectLabelsResponse_imageProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabelsResponse' {Maybe DetectLabelsImageProperties
imageProperties :: Maybe DetectLabelsImageProperties
$sel:imageProperties:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe DetectLabelsImageProperties
imageProperties} -> Maybe DetectLabelsImageProperties
imageProperties) (\s :: DetectLabelsResponse
s@DetectLabelsResponse' {} Maybe DetectLabelsImageProperties
a -> DetectLabelsResponse
s {$sel:imageProperties:DetectLabelsResponse' :: Maybe DetectLabelsImageProperties
imageProperties = Maybe DetectLabelsImageProperties
a} :: DetectLabelsResponse)

-- | Version number of the label detection model that was used to detect
-- labels.
detectLabelsResponse_labelModelVersion :: Lens.Lens' DetectLabelsResponse (Prelude.Maybe Prelude.Text)
detectLabelsResponse_labelModelVersion :: Lens' DetectLabelsResponse (Maybe Text)
detectLabelsResponse_labelModelVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabelsResponse' {Maybe Text
labelModelVersion :: Maybe Text
$sel:labelModelVersion:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe Text
labelModelVersion} -> Maybe Text
labelModelVersion) (\s :: DetectLabelsResponse
s@DetectLabelsResponse' {} Maybe Text
a -> DetectLabelsResponse
s {$sel:labelModelVersion:DetectLabelsResponse' :: Maybe Text
labelModelVersion = Maybe Text
a} :: DetectLabelsResponse)

-- | An array of labels for the real-world objects detected.
detectLabelsResponse_labels :: Lens.Lens' DetectLabelsResponse (Prelude.Maybe [Label])
detectLabelsResponse_labels :: Lens' DetectLabelsResponse (Maybe [Label])
detectLabelsResponse_labels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabelsResponse' {Maybe [Label]
labels :: Maybe [Label]
$sel:labels:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe [Label]
labels} -> Maybe [Label]
labels) (\s :: DetectLabelsResponse
s@DetectLabelsResponse' {} Maybe [Label]
a -> DetectLabelsResponse
s {$sel:labels:DetectLabelsResponse' :: Maybe [Label]
labels = Maybe [Label]
a} :: DetectLabelsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The value of @OrientationCorrection@ is always null.
--
-- If the input image is in .jpeg format, it might contain exchangeable
-- image file format (Exif) metadata that includes the image\'s
-- orientation. Amazon Rekognition uses this orientation information to
-- perform image correction. The bounding box coordinates are translated to
-- represent object locations after the orientation information in the Exif
-- metadata is used to correct the image orientation. Images in .png format
-- don\'t contain Exif metadata.
--
-- Amazon Rekognition doesn’t perform image correction for images in .png
-- format and .jpeg images without orientation information in the image
-- Exif metadata. The bounding box coordinates aren\'t translated and
-- represent the object locations before the image is rotated.
detectLabelsResponse_orientationCorrection :: Lens.Lens' DetectLabelsResponse (Prelude.Maybe OrientationCorrection)
detectLabelsResponse_orientationCorrection :: Lens' DetectLabelsResponse (Maybe OrientationCorrection)
detectLabelsResponse_orientationCorrection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabelsResponse' {Maybe OrientationCorrection
orientationCorrection :: Maybe OrientationCorrection
$sel:orientationCorrection:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe OrientationCorrection
orientationCorrection} -> Maybe OrientationCorrection
orientationCorrection) (\s :: DetectLabelsResponse
s@DetectLabelsResponse' {} Maybe OrientationCorrection
a -> DetectLabelsResponse
s {$sel:orientationCorrection:DetectLabelsResponse' :: Maybe OrientationCorrection
orientationCorrection = Maybe OrientationCorrection
a} :: DetectLabelsResponse)

-- | The response's http status code.
detectLabelsResponse_httpStatus :: Lens.Lens' DetectLabelsResponse Prelude.Int
detectLabelsResponse_httpStatus :: Lens' DetectLabelsResponse Int
detectLabelsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabelsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetectLabelsResponse' :: DetectLabelsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DetectLabelsResponse
s@DetectLabelsResponse' {} Int
a -> DetectLabelsResponse
s {$sel:httpStatus:DetectLabelsResponse' :: Int
httpStatus = Int
a} :: DetectLabelsResponse)

instance Prelude.NFData DetectLabelsResponse where
  rnf :: DetectLabelsResponse -> ()
rnf DetectLabelsResponse' {Int
Maybe [Label]
Maybe Text
Maybe DetectLabelsImageProperties
Maybe OrientationCorrection
httpStatus :: Int
orientationCorrection :: Maybe OrientationCorrection
labels :: Maybe [Label]
labelModelVersion :: Maybe Text
imageProperties :: Maybe DetectLabelsImageProperties
$sel:httpStatus:DetectLabelsResponse' :: DetectLabelsResponse -> Int
$sel:orientationCorrection:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe OrientationCorrection
$sel:labels:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe [Label]
$sel:labelModelVersion:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe Text
$sel:imageProperties:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe DetectLabelsImageProperties
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DetectLabelsImageProperties
imageProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
labelModelVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Label]
labels
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OrientationCorrection
orientationCorrection
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus