{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.Instance
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rekognition.Types.Instance 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.BoundingBox
import Amazonka.Rekognition.Types.DominantColor

-- | An instance of a label returned by Amazon Rekognition Image
-- (DetectLabels) or by Amazon Rekognition Video (GetLabelDetection).
--
-- /See:/ 'newInstance' smart constructor.
data Instance = Instance'
  { -- | The position of the label instance on the image.
    Instance -> Maybe BoundingBox
boundingBox :: Prelude.Maybe BoundingBox,
    -- | The confidence that Amazon Rekognition has in the accuracy of the
    -- bounding box.
    Instance -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | The dominant colors found in an individual instance of a label.
    Instance -> Maybe [DominantColor]
dominantColors :: Prelude.Maybe [DominantColor]
  }
  deriving (Instance -> Instance -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Instance -> Instance -> Bool
$c/= :: Instance -> Instance -> Bool
== :: Instance -> Instance -> Bool
$c== :: Instance -> Instance -> Bool
Prelude.Eq, ReadPrec [Instance]
ReadPrec Instance
Int -> ReadS Instance
ReadS [Instance]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Instance]
$creadListPrec :: ReadPrec [Instance]
readPrec :: ReadPrec Instance
$creadPrec :: ReadPrec Instance
readList :: ReadS [Instance]
$creadList :: ReadS [Instance]
readsPrec :: Int -> ReadS Instance
$creadsPrec :: Int -> ReadS Instance
Prelude.Read, Int -> Instance -> ShowS
[Instance] -> ShowS
Instance -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Instance] -> ShowS
$cshowList :: [Instance] -> ShowS
show :: Instance -> String
$cshow :: Instance -> String
showsPrec :: Int -> Instance -> ShowS
$cshowsPrec :: Int -> Instance -> ShowS
Prelude.Show, forall x. Rep Instance x -> Instance
forall x. Instance -> Rep Instance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Instance x -> Instance
$cfrom :: forall x. Instance -> Rep Instance x
Prelude.Generic)

-- |
-- Create a value of 'Instance' 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:
--
-- 'boundingBox', 'instance_boundingBox' - The position of the label instance on the image.
--
-- 'confidence', 'instance_confidence' - The confidence that Amazon Rekognition has in the accuracy of the
-- bounding box.
--
-- 'dominantColors', 'instance_dominantColors' - The dominant colors found in an individual instance of a label.
newInstance ::
  Instance
newInstance :: Instance
newInstance =
  Instance'
    { $sel:boundingBox:Instance' :: Maybe BoundingBox
boundingBox = forall a. Maybe a
Prelude.Nothing,
      $sel:confidence:Instance' :: Maybe Double
confidence = forall a. Maybe a
Prelude.Nothing,
      $sel:dominantColors:Instance' :: Maybe [DominantColor]
dominantColors = forall a. Maybe a
Prelude.Nothing
    }

-- | The position of the label instance on the image.
instance_boundingBox :: Lens.Lens' Instance (Prelude.Maybe BoundingBox)
instance_boundingBox :: Lens' Instance (Maybe BoundingBox)
instance_boundingBox = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Instance' {Maybe BoundingBox
boundingBox :: Maybe BoundingBox
$sel:boundingBox:Instance' :: Instance -> Maybe BoundingBox
boundingBox} -> Maybe BoundingBox
boundingBox) (\s :: Instance
s@Instance' {} Maybe BoundingBox
a -> Instance
s {$sel:boundingBox:Instance' :: Maybe BoundingBox
boundingBox = Maybe BoundingBox
a} :: Instance)

-- | The confidence that Amazon Rekognition has in the accuracy of the
-- bounding box.
instance_confidence :: Lens.Lens' Instance (Prelude.Maybe Prelude.Double)
instance_confidence :: Lens' Instance (Maybe Double)
instance_confidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Instance' {Maybe Double
confidence :: Maybe Double
$sel:confidence:Instance' :: Instance -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: Instance
s@Instance' {} Maybe Double
a -> Instance
s {$sel:confidence:Instance' :: Maybe Double
confidence = Maybe Double
a} :: Instance)

-- | The dominant colors found in an individual instance of a label.
instance_dominantColors :: Lens.Lens' Instance (Prelude.Maybe [DominantColor])
instance_dominantColors :: Lens' Instance (Maybe [DominantColor])
instance_dominantColors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Instance' {Maybe [DominantColor]
dominantColors :: Maybe [DominantColor]
$sel:dominantColors:Instance' :: Instance -> Maybe [DominantColor]
dominantColors} -> Maybe [DominantColor]
dominantColors) (\s :: Instance
s@Instance' {} Maybe [DominantColor]
a -> Instance
s {$sel:dominantColors:Instance' :: Maybe [DominantColor]
dominantColors = Maybe [DominantColor]
a} :: Instance) 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

instance Data.FromJSON Instance where
  parseJSON :: Value -> Parser Instance
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Instance"
      ( \Object
x ->
          Maybe BoundingBox
-> Maybe Double -> Maybe [DominantColor] -> Instance
Instance'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"BoundingBox")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Confidence")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DominantColors"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable Instance where
  hashWithSalt :: Int -> Instance -> Int
hashWithSalt Int
_salt Instance' {Maybe Double
Maybe [DominantColor]
Maybe BoundingBox
dominantColors :: Maybe [DominantColor]
confidence :: Maybe Double
boundingBox :: Maybe BoundingBox
$sel:dominantColors:Instance' :: Instance -> Maybe [DominantColor]
$sel:confidence:Instance' :: Instance -> Maybe Double
$sel:boundingBox:Instance' :: Instance -> Maybe BoundingBox
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BoundingBox
boundingBox
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
confidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DominantColor]
dominantColors

instance Prelude.NFData Instance where
  rnf :: Instance -> ()
rnf Instance' {Maybe Double
Maybe [DominantColor]
Maybe BoundingBox
dominantColors :: Maybe [DominantColor]
confidence :: Maybe Double
boundingBox :: Maybe BoundingBox
$sel:dominantColors:Instance' :: Instance -> Maybe [DominantColor]
$sel:confidence:Instance' :: Instance -> Maybe Double
$sel:boundingBox:Instance' :: Instance -> Maybe BoundingBox
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BoundingBox
boundingBox
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
confidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [DominantColor]
dominantColors