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

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

-- | Provides face metadata. In addition, it also provides the confidence in
-- the match of this face with the input face.
--
-- /See:/ 'newFaceMatch' smart constructor.
data FaceMatch = FaceMatch'
  { -- | Confidence in the match of this face with the input face.
    FaceMatch -> Maybe Double
similarity :: Prelude.Maybe Prelude.Double,
    -- | Describes the face properties such as the bounding box, face ID, image
    -- ID of the source image, and external image ID that you assigned.
    FaceMatch -> Maybe Face
face :: Prelude.Maybe Face
  }
  deriving (FaceMatch -> FaceMatch -> Bool
(FaceMatch -> FaceMatch -> Bool)
-> (FaceMatch -> FaceMatch -> Bool) -> Eq FaceMatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FaceMatch -> FaceMatch -> Bool
$c/= :: FaceMatch -> FaceMatch -> Bool
== :: FaceMatch -> FaceMatch -> Bool
$c== :: FaceMatch -> FaceMatch -> Bool
Prelude.Eq, ReadPrec [FaceMatch]
ReadPrec FaceMatch
Int -> ReadS FaceMatch
ReadS [FaceMatch]
(Int -> ReadS FaceMatch)
-> ReadS [FaceMatch]
-> ReadPrec FaceMatch
-> ReadPrec [FaceMatch]
-> Read FaceMatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FaceMatch]
$creadListPrec :: ReadPrec [FaceMatch]
readPrec :: ReadPrec FaceMatch
$creadPrec :: ReadPrec FaceMatch
readList :: ReadS [FaceMatch]
$creadList :: ReadS [FaceMatch]
readsPrec :: Int -> ReadS FaceMatch
$creadsPrec :: Int -> ReadS FaceMatch
Prelude.Read, Int -> FaceMatch -> ShowS
[FaceMatch] -> ShowS
FaceMatch -> String
(Int -> FaceMatch -> ShowS)
-> (FaceMatch -> String)
-> ([FaceMatch] -> ShowS)
-> Show FaceMatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FaceMatch] -> ShowS
$cshowList :: [FaceMatch] -> ShowS
show :: FaceMatch -> String
$cshow :: FaceMatch -> String
showsPrec :: Int -> FaceMatch -> ShowS
$cshowsPrec :: Int -> FaceMatch -> ShowS
Prelude.Show, (forall x. FaceMatch -> Rep FaceMatch x)
-> (forall x. Rep FaceMatch x -> FaceMatch) -> Generic FaceMatch
forall x. Rep FaceMatch x -> FaceMatch
forall x. FaceMatch -> Rep FaceMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FaceMatch x -> FaceMatch
$cfrom :: forall x. FaceMatch -> Rep FaceMatch x
Prelude.Generic)

-- |
-- Create a value of 'FaceMatch' 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:
--
-- 'similarity', 'faceMatch_similarity' - Confidence in the match of this face with the input face.
--
-- 'face', 'faceMatch_face' - Describes the face properties such as the bounding box, face ID, image
-- ID of the source image, and external image ID that you assigned.
newFaceMatch ::
  FaceMatch
newFaceMatch :: FaceMatch
newFaceMatch =
  FaceMatch' :: Maybe Double -> Maybe Face -> FaceMatch
FaceMatch'
    { $sel:similarity:FaceMatch' :: Maybe Double
similarity = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:face:FaceMatch' :: Maybe Face
face = Maybe Face
forall a. Maybe a
Prelude.Nothing
    }

-- | Confidence in the match of this face with the input face.
faceMatch_similarity :: Lens.Lens' FaceMatch (Prelude.Maybe Prelude.Double)
faceMatch_similarity :: (Maybe Double -> f (Maybe Double)) -> FaceMatch -> f FaceMatch
faceMatch_similarity = (FaceMatch -> Maybe Double)
-> (FaceMatch -> Maybe Double -> FaceMatch)
-> Lens FaceMatch FaceMatch (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaceMatch' {Maybe Double
similarity :: Maybe Double
$sel:similarity:FaceMatch' :: FaceMatch -> Maybe Double
similarity} -> Maybe Double
similarity) (\s :: FaceMatch
s@FaceMatch' {} Maybe Double
a -> FaceMatch
s {$sel:similarity:FaceMatch' :: Maybe Double
similarity = Maybe Double
a} :: FaceMatch)

-- | Describes the face properties such as the bounding box, face ID, image
-- ID of the source image, and external image ID that you assigned.
faceMatch_face :: Lens.Lens' FaceMatch (Prelude.Maybe Face)
faceMatch_face :: (Maybe Face -> f (Maybe Face)) -> FaceMatch -> f FaceMatch
faceMatch_face = (FaceMatch -> Maybe Face)
-> (FaceMatch -> Maybe Face -> FaceMatch)
-> Lens FaceMatch FaceMatch (Maybe Face) (Maybe Face)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaceMatch' {Maybe Face
face :: Maybe Face
$sel:face:FaceMatch' :: FaceMatch -> Maybe Face
face} -> Maybe Face
face) (\s :: FaceMatch
s@FaceMatch' {} Maybe Face
a -> FaceMatch
s {$sel:face:FaceMatch' :: Maybe Face
face = Maybe Face
a} :: FaceMatch)

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

instance Prelude.Hashable FaceMatch

instance Prelude.NFData FaceMatch