{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rekognition.Types.Instance where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types.BoundingBox

-- | 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
  }
  deriving (Instance -> Instance -> Bool
(Instance -> Instance -> Bool)
-> (Instance -> Instance -> Bool) -> Eq Instance
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]
(Int -> ReadS Instance)
-> ReadS [Instance]
-> ReadPrec Instance
-> ReadPrec [Instance]
-> Read 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
(Int -> Instance -> ShowS)
-> (Instance -> String) -> ([Instance] -> ShowS) -> Show Instance
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. Instance -> Rep Instance x)
-> (forall x. Rep Instance x -> Instance) -> Generic Instance
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.
newInstance ::
  Instance
newInstance :: Instance
newInstance =
  Instance' :: Maybe BoundingBox -> Maybe Double -> Instance
Instance'
    { $sel:boundingBox:Instance' :: Maybe BoundingBox
boundingBox = Maybe BoundingBox
forall a. Maybe a
Prelude.Nothing,
      $sel:confidence:Instance' :: Maybe Double
confidence = Maybe Double
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 :: (Maybe BoundingBox -> f (Maybe BoundingBox))
-> Instance -> f Instance
instance_boundingBox = (Instance -> Maybe BoundingBox)
-> (Instance -> Maybe BoundingBox -> Instance)
-> Lens Instance Instance (Maybe BoundingBox) (Maybe 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 :: (Maybe Double -> f (Maybe Double)) -> Instance -> f Instance
instance_confidence = (Instance -> Maybe Double)
-> (Instance -> Maybe Double -> Instance)
-> Lens Instance Instance (Maybe Double) (Maybe Double)
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)

instance Core.FromJSON Instance where
  parseJSON :: Value -> Parser Instance
parseJSON =
    String -> (Object -> Parser Instance) -> Value -> Parser Instance
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Instance"
      ( \Object
x ->
          Maybe BoundingBox -> Maybe Double -> Instance
Instance'
            (Maybe BoundingBox -> Maybe Double -> Instance)
-> Parser (Maybe BoundingBox) -> Parser (Maybe Double -> Instance)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe BoundingBox)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BoundingBox")
            Parser (Maybe Double -> Instance)
-> Parser (Maybe Double) -> Parser Instance
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Confidence")
      )

instance Prelude.Hashable Instance

instance Prelude.NFData Instance