{-# 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.FaceDetection
-- 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.FaceDetection 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.FaceDetail

-- | Information about a face detected in a video analysis request and the
-- time the face was detected in the video.
--
-- /See:/ 'newFaceDetection' smart constructor.
data FaceDetection = FaceDetection'
  { -- | The face properties for the detected face.
    FaceDetection -> Maybe FaceDetail
face :: Prelude.Maybe FaceDetail,
    -- | Time, in milliseconds from the start of the video, that the face was
    -- detected. Note that @Timestamp@ is not guaranteed to be accurate to the
    -- individual frame where the face first appears.
    FaceDetection -> Maybe Integer
timestamp :: Prelude.Maybe Prelude.Integer
  }
  deriving (FaceDetection -> FaceDetection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FaceDetection -> FaceDetection -> Bool
$c/= :: FaceDetection -> FaceDetection -> Bool
== :: FaceDetection -> FaceDetection -> Bool
$c== :: FaceDetection -> FaceDetection -> Bool
Prelude.Eq, ReadPrec [FaceDetection]
ReadPrec FaceDetection
Int -> ReadS FaceDetection
ReadS [FaceDetection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FaceDetection]
$creadListPrec :: ReadPrec [FaceDetection]
readPrec :: ReadPrec FaceDetection
$creadPrec :: ReadPrec FaceDetection
readList :: ReadS [FaceDetection]
$creadList :: ReadS [FaceDetection]
readsPrec :: Int -> ReadS FaceDetection
$creadsPrec :: Int -> ReadS FaceDetection
Prelude.Read, Int -> FaceDetection -> ShowS
[FaceDetection] -> ShowS
FaceDetection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FaceDetection] -> ShowS
$cshowList :: [FaceDetection] -> ShowS
show :: FaceDetection -> String
$cshow :: FaceDetection -> String
showsPrec :: Int -> FaceDetection -> ShowS
$cshowsPrec :: Int -> FaceDetection -> ShowS
Prelude.Show, forall x. Rep FaceDetection x -> FaceDetection
forall x. FaceDetection -> Rep FaceDetection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FaceDetection x -> FaceDetection
$cfrom :: forall x. FaceDetection -> Rep FaceDetection x
Prelude.Generic)

-- |
-- Create a value of 'FaceDetection' 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:
--
-- 'face', 'faceDetection_face' - The face properties for the detected face.
--
-- 'timestamp', 'faceDetection_timestamp' - Time, in milliseconds from the start of the video, that the face was
-- detected. Note that @Timestamp@ is not guaranteed to be accurate to the
-- individual frame where the face first appears.
newFaceDetection ::
  FaceDetection
newFaceDetection :: FaceDetection
newFaceDetection =
  FaceDetection'
    { $sel:face:FaceDetection' :: Maybe FaceDetail
face = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:FaceDetection' :: Maybe Integer
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | The face properties for the detected face.
faceDetection_face :: Lens.Lens' FaceDetection (Prelude.Maybe FaceDetail)
faceDetection_face :: Lens' FaceDetection (Maybe FaceDetail)
faceDetection_face = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaceDetection' {Maybe FaceDetail
face :: Maybe FaceDetail
$sel:face:FaceDetection' :: FaceDetection -> Maybe FaceDetail
face} -> Maybe FaceDetail
face) (\s :: FaceDetection
s@FaceDetection' {} Maybe FaceDetail
a -> FaceDetection
s {$sel:face:FaceDetection' :: Maybe FaceDetail
face = Maybe FaceDetail
a} :: FaceDetection)

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

instance Data.FromJSON FaceDetection where
  parseJSON :: Value -> Parser FaceDetection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FaceDetection"
      ( \Object
x ->
          Maybe FaceDetail -> Maybe Integer -> FaceDetection
FaceDetection'
            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
"Face")
            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 FaceDetection where
  hashWithSalt :: Int -> FaceDetection -> Int
hashWithSalt Int
_salt FaceDetection' {Maybe Integer
Maybe FaceDetail
timestamp :: Maybe Integer
face :: Maybe FaceDetail
$sel:timestamp:FaceDetection' :: FaceDetection -> Maybe Integer
$sel:face:FaceDetection' :: FaceDetection -> Maybe FaceDetail
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FaceDetail
face
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
timestamp

instance Prelude.NFData FaceDetection where
  rnf :: FaceDetection -> ()
rnf FaceDetection' {Maybe Integer
Maybe FaceDetail
timestamp :: Maybe Integer
face :: Maybe FaceDetail
$sel:timestamp:FaceDetection' :: FaceDetection -> Maybe Integer
$sel:face:FaceDetection' :: FaceDetection -> Maybe FaceDetail
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FaceDetail
face
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
timestamp