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

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

-- | Specifies a location within the frame that Rekognition checks for text.
-- Uses a @BoundingBox@ object to set a region of the screen.
--
-- A word is included in the region if the word is more than half in that
-- region. If there is more than one region, the word will be compared with
-- all regions of the screen. Any word more than half in a region is kept
-- in the results.
--
-- /See:/ 'newRegionOfInterest' smart constructor.
data RegionOfInterest = RegionOfInterest'
  { -- | The box representing a region of interest on screen.
    RegionOfInterest -> Maybe BoundingBox
boundingBox :: Prelude.Maybe BoundingBox
  }
  deriving (RegionOfInterest -> RegionOfInterest -> Bool
(RegionOfInterest -> RegionOfInterest -> Bool)
-> (RegionOfInterest -> RegionOfInterest -> Bool)
-> Eq RegionOfInterest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegionOfInterest -> RegionOfInterest -> Bool
$c/= :: RegionOfInterest -> RegionOfInterest -> Bool
== :: RegionOfInterest -> RegionOfInterest -> Bool
$c== :: RegionOfInterest -> RegionOfInterest -> Bool
Prelude.Eq, ReadPrec [RegionOfInterest]
ReadPrec RegionOfInterest
Int -> ReadS RegionOfInterest
ReadS [RegionOfInterest]
(Int -> ReadS RegionOfInterest)
-> ReadS [RegionOfInterest]
-> ReadPrec RegionOfInterest
-> ReadPrec [RegionOfInterest]
-> Read RegionOfInterest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegionOfInterest]
$creadListPrec :: ReadPrec [RegionOfInterest]
readPrec :: ReadPrec RegionOfInterest
$creadPrec :: ReadPrec RegionOfInterest
readList :: ReadS [RegionOfInterest]
$creadList :: ReadS [RegionOfInterest]
readsPrec :: Int -> ReadS RegionOfInterest
$creadsPrec :: Int -> ReadS RegionOfInterest
Prelude.Read, Int -> RegionOfInterest -> ShowS
[RegionOfInterest] -> ShowS
RegionOfInterest -> String
(Int -> RegionOfInterest -> ShowS)
-> (RegionOfInterest -> String)
-> ([RegionOfInterest] -> ShowS)
-> Show RegionOfInterest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegionOfInterest] -> ShowS
$cshowList :: [RegionOfInterest] -> ShowS
show :: RegionOfInterest -> String
$cshow :: RegionOfInterest -> String
showsPrec :: Int -> RegionOfInterest -> ShowS
$cshowsPrec :: Int -> RegionOfInterest -> ShowS
Prelude.Show, (forall x. RegionOfInterest -> Rep RegionOfInterest x)
-> (forall x. Rep RegionOfInterest x -> RegionOfInterest)
-> Generic RegionOfInterest
forall x. Rep RegionOfInterest x -> RegionOfInterest
forall x. RegionOfInterest -> Rep RegionOfInterest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegionOfInterest x -> RegionOfInterest
$cfrom :: forall x. RegionOfInterest -> Rep RegionOfInterest x
Prelude.Generic)

-- |
-- Create a value of 'RegionOfInterest' 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:
--
-- 'boundingBox', 'regionOfInterest_boundingBox' - The box representing a region of interest on screen.
newRegionOfInterest ::
  RegionOfInterest
newRegionOfInterest :: RegionOfInterest
newRegionOfInterest =
  RegionOfInterest' :: Maybe BoundingBox -> RegionOfInterest
RegionOfInterest' {$sel:boundingBox:RegionOfInterest' :: Maybe BoundingBox
boundingBox = Maybe BoundingBox
forall a. Maybe a
Prelude.Nothing}

-- | The box representing a region of interest on screen.
regionOfInterest_boundingBox :: Lens.Lens' RegionOfInterest (Prelude.Maybe BoundingBox)
regionOfInterest_boundingBox :: (Maybe BoundingBox -> f (Maybe BoundingBox))
-> RegionOfInterest -> f RegionOfInterest
regionOfInterest_boundingBox = (RegionOfInterest -> Maybe BoundingBox)
-> (RegionOfInterest -> Maybe BoundingBox -> RegionOfInterest)
-> Lens
     RegionOfInterest
     RegionOfInterest
     (Maybe BoundingBox)
     (Maybe BoundingBox)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegionOfInterest' {Maybe BoundingBox
boundingBox :: Maybe BoundingBox
$sel:boundingBox:RegionOfInterest' :: RegionOfInterest -> Maybe BoundingBox
boundingBox} -> Maybe BoundingBox
boundingBox) (\s :: RegionOfInterest
s@RegionOfInterest' {} Maybe BoundingBox
a -> RegionOfInterest
s {$sel:boundingBox:RegionOfInterest' :: Maybe BoundingBox
boundingBox = Maybe BoundingBox
a} :: RegionOfInterest)

instance Prelude.Hashable RegionOfInterest

instance Prelude.NFData RegionOfInterest

instance Core.ToJSON RegionOfInterest where
  toJSON :: RegionOfInterest -> Value
toJSON RegionOfInterest' {Maybe BoundingBox
boundingBox :: Maybe BoundingBox
$sel:boundingBox:RegionOfInterest' :: RegionOfInterest -> Maybe BoundingBox
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"BoundingBox" Text -> BoundingBox -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (BoundingBox -> Pair) -> Maybe BoundingBox -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BoundingBox
boundingBox]
      )