{-# 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.CustomLabel
-- 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.CustomLabel where

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

-- | A custom label detected in an image by a call to DetectCustomLabels.
--
-- /See:/ 'newCustomLabel' smart constructor.
data CustomLabel = CustomLabel'
  { -- | The confidence that the model has in the detection of the custom label.
    -- The range is 0-100. A higher value indicates a higher confidence.
    CustomLabel -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | The name of the custom label.
    CustomLabel -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The location of the detected object on the image that corresponds to the
    -- custom label. Includes an axis aligned coarse bounding box surrounding
    -- the object and a finer grain polygon for more accurate spatial
    -- information.
    CustomLabel -> Maybe Geometry
geometry :: Prelude.Maybe Geometry
  }
  deriving (CustomLabel -> CustomLabel -> Bool
(CustomLabel -> CustomLabel -> Bool)
-> (CustomLabel -> CustomLabel -> Bool) -> Eq CustomLabel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomLabel -> CustomLabel -> Bool
$c/= :: CustomLabel -> CustomLabel -> Bool
== :: CustomLabel -> CustomLabel -> Bool
$c== :: CustomLabel -> CustomLabel -> Bool
Prelude.Eq, ReadPrec [CustomLabel]
ReadPrec CustomLabel
Int -> ReadS CustomLabel
ReadS [CustomLabel]
(Int -> ReadS CustomLabel)
-> ReadS [CustomLabel]
-> ReadPrec CustomLabel
-> ReadPrec [CustomLabel]
-> Read CustomLabel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomLabel]
$creadListPrec :: ReadPrec [CustomLabel]
readPrec :: ReadPrec CustomLabel
$creadPrec :: ReadPrec CustomLabel
readList :: ReadS [CustomLabel]
$creadList :: ReadS [CustomLabel]
readsPrec :: Int -> ReadS CustomLabel
$creadsPrec :: Int -> ReadS CustomLabel
Prelude.Read, Int -> CustomLabel -> ShowS
[CustomLabel] -> ShowS
CustomLabel -> String
(Int -> CustomLabel -> ShowS)
-> (CustomLabel -> String)
-> ([CustomLabel] -> ShowS)
-> Show CustomLabel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomLabel] -> ShowS
$cshowList :: [CustomLabel] -> ShowS
show :: CustomLabel -> String
$cshow :: CustomLabel -> String
showsPrec :: Int -> CustomLabel -> ShowS
$cshowsPrec :: Int -> CustomLabel -> ShowS
Prelude.Show, (forall x. CustomLabel -> Rep CustomLabel x)
-> (forall x. Rep CustomLabel x -> CustomLabel)
-> Generic CustomLabel
forall x. Rep CustomLabel x -> CustomLabel
forall x. CustomLabel -> Rep CustomLabel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomLabel x -> CustomLabel
$cfrom :: forall x. CustomLabel -> Rep CustomLabel x
Prelude.Generic)

-- |
-- Create a value of 'CustomLabel' 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:
--
-- 'confidence', 'customLabel_confidence' - The confidence that the model has in the detection of the custom label.
-- The range is 0-100. A higher value indicates a higher confidence.
--
-- 'name', 'customLabel_name' - The name of the custom label.
--
-- 'geometry', 'customLabel_geometry' - The location of the detected object on the image that corresponds to the
-- custom label. Includes an axis aligned coarse bounding box surrounding
-- the object and a finer grain polygon for more accurate spatial
-- information.
newCustomLabel ::
  CustomLabel
newCustomLabel :: CustomLabel
newCustomLabel =
  CustomLabel' :: Maybe Double -> Maybe Text -> Maybe Geometry -> CustomLabel
CustomLabel'
    { $sel:confidence:CustomLabel' :: Maybe Double
confidence = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CustomLabel' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:geometry:CustomLabel' :: Maybe Geometry
geometry = Maybe Geometry
forall a. Maybe a
Prelude.Nothing
    }

-- | The confidence that the model has in the detection of the custom label.
-- The range is 0-100. A higher value indicates a higher confidence.
customLabel_confidence :: Lens.Lens' CustomLabel (Prelude.Maybe Prelude.Double)
customLabel_confidence :: (Maybe Double -> f (Maybe Double)) -> CustomLabel -> f CustomLabel
customLabel_confidence = (CustomLabel -> Maybe Double)
-> (CustomLabel -> Maybe Double -> CustomLabel)
-> Lens CustomLabel CustomLabel (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomLabel' {Maybe Double
confidence :: Maybe Double
$sel:confidence:CustomLabel' :: CustomLabel -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: CustomLabel
s@CustomLabel' {} Maybe Double
a -> CustomLabel
s {$sel:confidence:CustomLabel' :: Maybe Double
confidence = Maybe Double
a} :: CustomLabel)

-- | The name of the custom label.
customLabel_name :: Lens.Lens' CustomLabel (Prelude.Maybe Prelude.Text)
customLabel_name :: (Maybe Text -> f (Maybe Text)) -> CustomLabel -> f CustomLabel
customLabel_name = (CustomLabel -> Maybe Text)
-> (CustomLabel -> Maybe Text -> CustomLabel)
-> Lens CustomLabel CustomLabel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomLabel' {Maybe Text
name :: Maybe Text
$sel:name:CustomLabel' :: CustomLabel -> Maybe Text
name} -> Maybe Text
name) (\s :: CustomLabel
s@CustomLabel' {} Maybe Text
a -> CustomLabel
s {$sel:name:CustomLabel' :: Maybe Text
name = Maybe Text
a} :: CustomLabel)

-- | The location of the detected object on the image that corresponds to the
-- custom label. Includes an axis aligned coarse bounding box surrounding
-- the object and a finer grain polygon for more accurate spatial
-- information.
customLabel_geometry :: Lens.Lens' CustomLabel (Prelude.Maybe Geometry)
customLabel_geometry :: (Maybe Geometry -> f (Maybe Geometry))
-> CustomLabel -> f CustomLabel
customLabel_geometry = (CustomLabel -> Maybe Geometry)
-> (CustomLabel -> Maybe Geometry -> CustomLabel)
-> Lens CustomLabel CustomLabel (Maybe Geometry) (Maybe Geometry)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomLabel' {Maybe Geometry
geometry :: Maybe Geometry
$sel:geometry:CustomLabel' :: CustomLabel -> Maybe Geometry
geometry} -> Maybe Geometry
geometry) (\s :: CustomLabel
s@CustomLabel' {} Maybe Geometry
a -> CustomLabel
s {$sel:geometry:CustomLabel' :: Maybe Geometry
geometry = Maybe Geometry
a} :: CustomLabel)

instance Core.FromJSON CustomLabel where
  parseJSON :: Value -> Parser CustomLabel
parseJSON =
    String
-> (Object -> Parser CustomLabel) -> Value -> Parser CustomLabel
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomLabel"
      ( \Object
x ->
          Maybe Double -> Maybe Text -> Maybe Geometry -> CustomLabel
CustomLabel'
            (Maybe Double -> Maybe Text -> Maybe Geometry -> CustomLabel)
-> Parser (Maybe Double)
-> Parser (Maybe Text -> Maybe Geometry -> CustomLabel)
forall (f :: * -> *) a b. Functor 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")
            Parser (Maybe Text -> Maybe Geometry -> CustomLabel)
-> Parser (Maybe Text) -> Parser (Maybe Geometry -> CustomLabel)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser (Maybe Geometry -> CustomLabel)
-> Parser (Maybe Geometry) -> Parser CustomLabel
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Geometry)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Geometry")
      )

instance Prelude.Hashable CustomLabel

instance Prelude.NFData CustomLabel