{-# 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.LabelDetection
-- 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.LabelDetection 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.Label

-- | Information about a label detected in a video analysis request and the
-- time the label was detected in the video.
--
-- /See:/ 'newLabelDetection' smart constructor.
data LabelDetection = LabelDetection'
  { -- | The time duration of a segment in milliseconds, I.e. time elapsed from
    -- StartTimestampMillis to EndTimestampMillis.
    LabelDetection -> Maybe Natural
durationMillis :: Prelude.Maybe Prelude.Natural,
    -- | The time in milliseconds defining the end of the timeline segment
    -- containing a continuously detected label.
    LabelDetection -> Maybe Natural
endTimestampMillis :: Prelude.Maybe Prelude.Natural,
    -- | Details about the detected label.
    LabelDetection -> Maybe Label
label :: Prelude.Maybe Label,
    -- | The time in milliseconds defining the start of the timeline segment
    -- containing a continuously detected label.
    LabelDetection -> Maybe Natural
startTimestampMillis :: Prelude.Maybe Prelude.Natural,
    -- | Time, in milliseconds from the start of the video, that the label was
    -- detected. Note that @Timestamp@ is not guaranteed to be accurate to the
    -- individual frame where the label first appears.
    LabelDetection -> Maybe Integer
timestamp :: Prelude.Maybe Prelude.Integer
  }
  deriving (LabelDetection -> LabelDetection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LabelDetection -> LabelDetection -> Bool
$c/= :: LabelDetection -> LabelDetection -> Bool
== :: LabelDetection -> LabelDetection -> Bool
$c== :: LabelDetection -> LabelDetection -> Bool
Prelude.Eq, ReadPrec [LabelDetection]
ReadPrec LabelDetection
Int -> ReadS LabelDetection
ReadS [LabelDetection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LabelDetection]
$creadListPrec :: ReadPrec [LabelDetection]
readPrec :: ReadPrec LabelDetection
$creadPrec :: ReadPrec LabelDetection
readList :: ReadS [LabelDetection]
$creadList :: ReadS [LabelDetection]
readsPrec :: Int -> ReadS LabelDetection
$creadsPrec :: Int -> ReadS LabelDetection
Prelude.Read, Int -> LabelDetection -> ShowS
[LabelDetection] -> ShowS
LabelDetection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LabelDetection] -> ShowS
$cshowList :: [LabelDetection] -> ShowS
show :: LabelDetection -> String
$cshow :: LabelDetection -> String
showsPrec :: Int -> LabelDetection -> ShowS
$cshowsPrec :: Int -> LabelDetection -> ShowS
Prelude.Show, forall x. Rep LabelDetection x -> LabelDetection
forall x. LabelDetection -> Rep LabelDetection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LabelDetection x -> LabelDetection
$cfrom :: forall x. LabelDetection -> Rep LabelDetection x
Prelude.Generic)

-- |
-- Create a value of 'LabelDetection' 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:
--
-- 'durationMillis', 'labelDetection_durationMillis' - The time duration of a segment in milliseconds, I.e. time elapsed from
-- StartTimestampMillis to EndTimestampMillis.
--
-- 'endTimestampMillis', 'labelDetection_endTimestampMillis' - The time in milliseconds defining the end of the timeline segment
-- containing a continuously detected label.
--
-- 'label', 'labelDetection_label' - Details about the detected label.
--
-- 'startTimestampMillis', 'labelDetection_startTimestampMillis' - The time in milliseconds defining the start of the timeline segment
-- containing a continuously detected label.
--
-- 'timestamp', 'labelDetection_timestamp' - Time, in milliseconds from the start of the video, that the label was
-- detected. Note that @Timestamp@ is not guaranteed to be accurate to the
-- individual frame where the label first appears.
newLabelDetection ::
  LabelDetection
newLabelDetection :: LabelDetection
newLabelDetection =
  LabelDetection'
    { $sel:durationMillis:LabelDetection' :: Maybe Natural
durationMillis = forall a. Maybe a
Prelude.Nothing,
      $sel:endTimestampMillis:LabelDetection' :: Maybe Natural
endTimestampMillis = forall a. Maybe a
Prelude.Nothing,
      $sel:label:LabelDetection' :: Maybe Label
label = forall a. Maybe a
Prelude.Nothing,
      $sel:startTimestampMillis:LabelDetection' :: Maybe Natural
startTimestampMillis = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:LabelDetection' :: Maybe Integer
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | The time duration of a segment in milliseconds, I.e. time elapsed from
-- StartTimestampMillis to EndTimestampMillis.
labelDetection_durationMillis :: Lens.Lens' LabelDetection (Prelude.Maybe Prelude.Natural)
labelDetection_durationMillis :: Lens' LabelDetection (Maybe Natural)
labelDetection_durationMillis = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelDetection' {Maybe Natural
durationMillis :: Maybe Natural
$sel:durationMillis:LabelDetection' :: LabelDetection -> Maybe Natural
durationMillis} -> Maybe Natural
durationMillis) (\s :: LabelDetection
s@LabelDetection' {} Maybe Natural
a -> LabelDetection
s {$sel:durationMillis:LabelDetection' :: Maybe Natural
durationMillis = Maybe Natural
a} :: LabelDetection)

-- | The time in milliseconds defining the end of the timeline segment
-- containing a continuously detected label.
labelDetection_endTimestampMillis :: Lens.Lens' LabelDetection (Prelude.Maybe Prelude.Natural)
labelDetection_endTimestampMillis :: Lens' LabelDetection (Maybe Natural)
labelDetection_endTimestampMillis = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelDetection' {Maybe Natural
endTimestampMillis :: Maybe Natural
$sel:endTimestampMillis:LabelDetection' :: LabelDetection -> Maybe Natural
endTimestampMillis} -> Maybe Natural
endTimestampMillis) (\s :: LabelDetection
s@LabelDetection' {} Maybe Natural
a -> LabelDetection
s {$sel:endTimestampMillis:LabelDetection' :: Maybe Natural
endTimestampMillis = Maybe Natural
a} :: LabelDetection)

-- | Details about the detected label.
labelDetection_label :: Lens.Lens' LabelDetection (Prelude.Maybe Label)
labelDetection_label :: Lens' LabelDetection (Maybe Label)
labelDetection_label = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelDetection' {Maybe Label
label :: Maybe Label
$sel:label:LabelDetection' :: LabelDetection -> Maybe Label
label} -> Maybe Label
label) (\s :: LabelDetection
s@LabelDetection' {} Maybe Label
a -> LabelDetection
s {$sel:label:LabelDetection' :: Maybe Label
label = Maybe Label
a} :: LabelDetection)

-- | The time in milliseconds defining the start of the timeline segment
-- containing a continuously detected label.
labelDetection_startTimestampMillis :: Lens.Lens' LabelDetection (Prelude.Maybe Prelude.Natural)
labelDetection_startTimestampMillis :: Lens' LabelDetection (Maybe Natural)
labelDetection_startTimestampMillis = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelDetection' {Maybe Natural
startTimestampMillis :: Maybe Natural
$sel:startTimestampMillis:LabelDetection' :: LabelDetection -> Maybe Natural
startTimestampMillis} -> Maybe Natural
startTimestampMillis) (\s :: LabelDetection
s@LabelDetection' {} Maybe Natural
a -> LabelDetection
s {$sel:startTimestampMillis:LabelDetection' :: Maybe Natural
startTimestampMillis = Maybe Natural
a} :: LabelDetection)

-- | Time, in milliseconds from the start of the video, that the label was
-- detected. Note that @Timestamp@ is not guaranteed to be accurate to the
-- individual frame where the label first appears.
labelDetection_timestamp :: Lens.Lens' LabelDetection (Prelude.Maybe Prelude.Integer)
labelDetection_timestamp :: Lens' LabelDetection (Maybe Integer)
labelDetection_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelDetection' {Maybe Integer
timestamp :: Maybe Integer
$sel:timestamp:LabelDetection' :: LabelDetection -> Maybe Integer
timestamp} -> Maybe Integer
timestamp) (\s :: LabelDetection
s@LabelDetection' {} Maybe Integer
a -> LabelDetection
s {$sel:timestamp:LabelDetection' :: Maybe Integer
timestamp = Maybe Integer
a} :: LabelDetection)

instance Data.FromJSON LabelDetection where
  parseJSON :: Value -> Parser LabelDetection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LabelDetection"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Label
-> Maybe Natural
-> Maybe Integer
-> LabelDetection
LabelDetection'
            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
"DurationMillis")
            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
"EndTimestampMillis")
            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
"Label")
            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
"StartTimestampMillis")
            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
"Timestamp")
      )

instance Prelude.Hashable LabelDetection where
  hashWithSalt :: Int -> LabelDetection -> Int
hashWithSalt Int
_salt LabelDetection' {Maybe Integer
Maybe Natural
Maybe Label
timestamp :: Maybe Integer
startTimestampMillis :: Maybe Natural
label :: Maybe Label
endTimestampMillis :: Maybe Natural
durationMillis :: Maybe Natural
$sel:timestamp:LabelDetection' :: LabelDetection -> Maybe Integer
$sel:startTimestampMillis:LabelDetection' :: LabelDetection -> Maybe Natural
$sel:label:LabelDetection' :: LabelDetection -> Maybe Label
$sel:endTimestampMillis:LabelDetection' :: LabelDetection -> Maybe Natural
$sel:durationMillis:LabelDetection' :: LabelDetection -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
durationMillis
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
endTimestampMillis
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Label
label
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
startTimestampMillis
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
timestamp

instance Prelude.NFData LabelDetection where
  rnf :: LabelDetection -> ()
rnf LabelDetection' {Maybe Integer
Maybe Natural
Maybe Label
timestamp :: Maybe Integer
startTimestampMillis :: Maybe Natural
label :: Maybe Label
endTimestampMillis :: Maybe Natural
durationMillis :: Maybe Natural
$sel:timestamp:LabelDetection' :: LabelDetection -> Maybe Integer
$sel:startTimestampMillis:LabelDetection' :: LabelDetection -> Maybe Natural
$sel:label:LabelDetection' :: LabelDetection -> Maybe Label
$sel:endTimestampMillis:LabelDetection' :: LabelDetection -> Maybe Natural
$sel:durationMillis:LabelDetection' :: LabelDetection -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
durationMillis
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
endTimestampMillis
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Label
label
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
startTimestampMillis
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
timestamp