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

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

-- | Provides information about a face in a target image that matches the
-- source image face analyzed by @CompareFaces@. The @Face@ property
-- contains the bounding box of the face in the target image. The
-- @Similarity@ property is the confidence that the source image face
-- matches the face in the bounding box.
--
-- /See:/ 'newCompareFacesMatch' smart constructor.
data CompareFacesMatch = CompareFacesMatch'
  { -- | Level of confidence that the faces match.
    CompareFacesMatch -> Maybe Double
similarity :: Prelude.Maybe Prelude.Double,
    -- | Provides face metadata (bounding box and confidence that the bounding
    -- box actually contains a face).
    CompareFacesMatch -> Maybe ComparedFace
face :: Prelude.Maybe ComparedFace
  }
  deriving (CompareFacesMatch -> CompareFacesMatch -> Bool
(CompareFacesMatch -> CompareFacesMatch -> Bool)
-> (CompareFacesMatch -> CompareFacesMatch -> Bool)
-> Eq CompareFacesMatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompareFacesMatch -> CompareFacesMatch -> Bool
$c/= :: CompareFacesMatch -> CompareFacesMatch -> Bool
== :: CompareFacesMatch -> CompareFacesMatch -> Bool
$c== :: CompareFacesMatch -> CompareFacesMatch -> Bool
Prelude.Eq, ReadPrec [CompareFacesMatch]
ReadPrec CompareFacesMatch
Int -> ReadS CompareFacesMatch
ReadS [CompareFacesMatch]
(Int -> ReadS CompareFacesMatch)
-> ReadS [CompareFacesMatch]
-> ReadPrec CompareFacesMatch
-> ReadPrec [CompareFacesMatch]
-> Read CompareFacesMatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompareFacesMatch]
$creadListPrec :: ReadPrec [CompareFacesMatch]
readPrec :: ReadPrec CompareFacesMatch
$creadPrec :: ReadPrec CompareFacesMatch
readList :: ReadS [CompareFacesMatch]
$creadList :: ReadS [CompareFacesMatch]
readsPrec :: Int -> ReadS CompareFacesMatch
$creadsPrec :: Int -> ReadS CompareFacesMatch
Prelude.Read, Int -> CompareFacesMatch -> ShowS
[CompareFacesMatch] -> ShowS
CompareFacesMatch -> String
(Int -> CompareFacesMatch -> ShowS)
-> (CompareFacesMatch -> String)
-> ([CompareFacesMatch] -> ShowS)
-> Show CompareFacesMatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompareFacesMatch] -> ShowS
$cshowList :: [CompareFacesMatch] -> ShowS
show :: CompareFacesMatch -> String
$cshow :: CompareFacesMatch -> String
showsPrec :: Int -> CompareFacesMatch -> ShowS
$cshowsPrec :: Int -> CompareFacesMatch -> ShowS
Prelude.Show, (forall x. CompareFacesMatch -> Rep CompareFacesMatch x)
-> (forall x. Rep CompareFacesMatch x -> CompareFacesMatch)
-> Generic CompareFacesMatch
forall x. Rep CompareFacesMatch x -> CompareFacesMatch
forall x. CompareFacesMatch -> Rep CompareFacesMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CompareFacesMatch x -> CompareFacesMatch
$cfrom :: forall x. CompareFacesMatch -> Rep CompareFacesMatch x
Prelude.Generic)

-- |
-- Create a value of 'CompareFacesMatch' 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', 'compareFacesMatch_similarity' - Level of confidence that the faces match.
--
-- 'face', 'compareFacesMatch_face' - Provides face metadata (bounding box and confidence that the bounding
-- box actually contains a face).
newCompareFacesMatch ::
  CompareFacesMatch
newCompareFacesMatch :: CompareFacesMatch
newCompareFacesMatch =
  CompareFacesMatch' :: Maybe Double -> Maybe ComparedFace -> CompareFacesMatch
CompareFacesMatch'
    { $sel:similarity:CompareFacesMatch' :: Maybe Double
similarity = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:face:CompareFacesMatch' :: Maybe ComparedFace
face = Maybe ComparedFace
forall a. Maybe a
Prelude.Nothing
    }

-- | Level of confidence that the faces match.
compareFacesMatch_similarity :: Lens.Lens' CompareFacesMatch (Prelude.Maybe Prelude.Double)
compareFacesMatch_similarity :: (Maybe Double -> f (Maybe Double))
-> CompareFacesMatch -> f CompareFacesMatch
compareFacesMatch_similarity = (CompareFacesMatch -> Maybe Double)
-> (CompareFacesMatch -> Maybe Double -> CompareFacesMatch)
-> Lens
     CompareFacesMatch CompareFacesMatch (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompareFacesMatch' {Maybe Double
similarity :: Maybe Double
$sel:similarity:CompareFacesMatch' :: CompareFacesMatch -> Maybe Double
similarity} -> Maybe Double
similarity) (\s :: CompareFacesMatch
s@CompareFacesMatch' {} Maybe Double
a -> CompareFacesMatch
s {$sel:similarity:CompareFacesMatch' :: Maybe Double
similarity = Maybe Double
a} :: CompareFacesMatch)

-- | Provides face metadata (bounding box and confidence that the bounding
-- box actually contains a face).
compareFacesMatch_face :: Lens.Lens' CompareFacesMatch (Prelude.Maybe ComparedFace)
compareFacesMatch_face :: (Maybe ComparedFace -> f (Maybe ComparedFace))
-> CompareFacesMatch -> f CompareFacesMatch
compareFacesMatch_face = (CompareFacesMatch -> Maybe ComparedFace)
-> (CompareFacesMatch -> Maybe ComparedFace -> CompareFacesMatch)
-> Lens
     CompareFacesMatch
     CompareFacesMatch
     (Maybe ComparedFace)
     (Maybe ComparedFace)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompareFacesMatch' {Maybe ComparedFace
face :: Maybe ComparedFace
$sel:face:CompareFacesMatch' :: CompareFacesMatch -> Maybe ComparedFace
face} -> Maybe ComparedFace
face) (\s :: CompareFacesMatch
s@CompareFacesMatch' {} Maybe ComparedFace
a -> CompareFacesMatch
s {$sel:face:CompareFacesMatch' :: Maybe ComparedFace
face = Maybe ComparedFace
a} :: CompareFacesMatch)

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

instance Prelude.Hashable CompareFacesMatch

instance Prelude.NFData CompareFacesMatch