{-# 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.PersonMatch
-- 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.PersonMatch 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.FaceMatch
import Amazonka.Rekognition.Types.PersonDetail

-- | Information about a person whose face matches a face(s) in an Amazon
-- Rekognition collection. Includes information about the faces in the
-- Amazon Rekognition collection (FaceMatch), information about the person
-- (PersonDetail), and the time stamp for when the person was detected in a
-- video. An array of @PersonMatch@ objects is returned by GetFaceSearch.
--
-- /See:/ 'newPersonMatch' smart constructor.
data PersonMatch = PersonMatch'
  { -- | Information about the faces in the input collection that match the face
    -- of a person in the video.
    PersonMatch -> Maybe [FaceMatch]
faceMatches :: Prelude.Maybe [FaceMatch],
    -- | Information about the matched person.
    PersonMatch -> Maybe PersonDetail
person :: Prelude.Maybe PersonDetail,
    -- | The time, in milliseconds from the beginning of the video, that the
    -- person was matched in the video.
    PersonMatch -> Maybe Integer
timestamp :: Prelude.Maybe Prelude.Integer
  }
  deriving (PersonMatch -> PersonMatch -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PersonMatch -> PersonMatch -> Bool
$c/= :: PersonMatch -> PersonMatch -> Bool
== :: PersonMatch -> PersonMatch -> Bool
$c== :: PersonMatch -> PersonMatch -> Bool
Prelude.Eq, ReadPrec [PersonMatch]
ReadPrec PersonMatch
Int -> ReadS PersonMatch
ReadS [PersonMatch]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PersonMatch]
$creadListPrec :: ReadPrec [PersonMatch]
readPrec :: ReadPrec PersonMatch
$creadPrec :: ReadPrec PersonMatch
readList :: ReadS [PersonMatch]
$creadList :: ReadS [PersonMatch]
readsPrec :: Int -> ReadS PersonMatch
$creadsPrec :: Int -> ReadS PersonMatch
Prelude.Read, Int -> PersonMatch -> ShowS
[PersonMatch] -> ShowS
PersonMatch -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PersonMatch] -> ShowS
$cshowList :: [PersonMatch] -> ShowS
show :: PersonMatch -> String
$cshow :: PersonMatch -> String
showsPrec :: Int -> PersonMatch -> ShowS
$cshowsPrec :: Int -> PersonMatch -> ShowS
Prelude.Show, forall x. Rep PersonMatch x -> PersonMatch
forall x. PersonMatch -> Rep PersonMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PersonMatch x -> PersonMatch
$cfrom :: forall x. PersonMatch -> Rep PersonMatch x
Prelude.Generic)

-- |
-- Create a value of 'PersonMatch' 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:
--
-- 'faceMatches', 'personMatch_faceMatches' - Information about the faces in the input collection that match the face
-- of a person in the video.
--
-- 'person', 'personMatch_person' - Information about the matched person.
--
-- 'timestamp', 'personMatch_timestamp' - The time, in milliseconds from the beginning of the video, that the
-- person was matched in the video.
newPersonMatch ::
  PersonMatch
newPersonMatch :: PersonMatch
newPersonMatch =
  PersonMatch'
    { $sel:faceMatches:PersonMatch' :: Maybe [FaceMatch]
faceMatches = forall a. Maybe a
Prelude.Nothing,
      $sel:person:PersonMatch' :: Maybe PersonDetail
person = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:PersonMatch' :: Maybe Integer
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the faces in the input collection that match the face
-- of a person in the video.
personMatch_faceMatches :: Lens.Lens' PersonMatch (Prelude.Maybe [FaceMatch])
personMatch_faceMatches :: Lens' PersonMatch (Maybe [FaceMatch])
personMatch_faceMatches = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PersonMatch' {Maybe [FaceMatch]
faceMatches :: Maybe [FaceMatch]
$sel:faceMatches:PersonMatch' :: PersonMatch -> Maybe [FaceMatch]
faceMatches} -> Maybe [FaceMatch]
faceMatches) (\s :: PersonMatch
s@PersonMatch' {} Maybe [FaceMatch]
a -> PersonMatch
s {$sel:faceMatches:PersonMatch' :: Maybe [FaceMatch]
faceMatches = Maybe [FaceMatch]
a} :: PersonMatch) 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

-- | Information about the matched person.
personMatch_person :: Lens.Lens' PersonMatch (Prelude.Maybe PersonDetail)
personMatch_person :: Lens' PersonMatch (Maybe PersonDetail)
personMatch_person = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PersonMatch' {Maybe PersonDetail
person :: Maybe PersonDetail
$sel:person:PersonMatch' :: PersonMatch -> Maybe PersonDetail
person} -> Maybe PersonDetail
person) (\s :: PersonMatch
s@PersonMatch' {} Maybe PersonDetail
a -> PersonMatch
s {$sel:person:PersonMatch' :: Maybe PersonDetail
person = Maybe PersonDetail
a} :: PersonMatch)

-- | The time, in milliseconds from the beginning of the video, that the
-- person was matched in the video.
personMatch_timestamp :: Lens.Lens' PersonMatch (Prelude.Maybe Prelude.Integer)
personMatch_timestamp :: Lens' PersonMatch (Maybe Integer)
personMatch_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PersonMatch' {Maybe Integer
timestamp :: Maybe Integer
$sel:timestamp:PersonMatch' :: PersonMatch -> Maybe Integer
timestamp} -> Maybe Integer
timestamp) (\s :: PersonMatch
s@PersonMatch' {} Maybe Integer
a -> PersonMatch
s {$sel:timestamp:PersonMatch' :: Maybe Integer
timestamp = Maybe Integer
a} :: PersonMatch)

instance Data.FromJSON PersonMatch where
  parseJSON :: Value -> Parser PersonMatch
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PersonMatch"
      ( \Object
x ->
          Maybe [FaceMatch]
-> Maybe PersonDetail -> Maybe Integer -> PersonMatch
PersonMatch'
            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
"FaceMatches" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Person")
            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 PersonMatch where
  hashWithSalt :: Int -> PersonMatch -> Int
hashWithSalt Int
_salt PersonMatch' {Maybe Integer
Maybe [FaceMatch]
Maybe PersonDetail
timestamp :: Maybe Integer
person :: Maybe PersonDetail
faceMatches :: Maybe [FaceMatch]
$sel:timestamp:PersonMatch' :: PersonMatch -> Maybe Integer
$sel:person:PersonMatch' :: PersonMatch -> Maybe PersonDetail
$sel:faceMatches:PersonMatch' :: PersonMatch -> Maybe [FaceMatch]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [FaceMatch]
faceMatches
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PersonDetail
person
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
timestamp

instance Prelude.NFData PersonMatch where
  rnf :: PersonMatch -> ()
rnf PersonMatch' {Maybe Integer
Maybe [FaceMatch]
Maybe PersonDetail
timestamp :: Maybe Integer
person :: Maybe PersonDetail
faceMatches :: Maybe [FaceMatch]
$sel:timestamp:PersonMatch' :: PersonMatch -> Maybe Integer
$sel:person:PersonMatch' :: PersonMatch -> Maybe PersonDetail
$sel:faceMatches:PersonMatch' :: PersonMatch -> Maybe [FaceMatch]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FaceMatch]
faceMatches
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PersonDetail
person
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
timestamp