{-# 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.TextDetection
-- 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.TextDetection 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.Geometry
import Amazonka.Rekognition.Types.TextTypes

-- | Information about a word or line of text detected by DetectText.
--
-- The @DetectedText@ field contains the text that Amazon Rekognition
-- detected in the image.
--
-- Every word and line has an identifier (@Id@). Each word belongs to a
-- line and has a parent identifier (@ParentId@) that identifies the line
-- of text in which the word appears. The word @Id@ is also an index for
-- the word within a line of words.
--
-- For more information, see Detecting text in the Amazon Rekognition
-- Developer Guide.
--
-- /See:/ 'newTextDetection' smart constructor.
data TextDetection = TextDetection'
  { -- | The confidence that Amazon Rekognition has in the accuracy of the
    -- detected text and the accuracy of the geometry points around the
    -- detected text.
    TextDetection -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | The word or line of text recognized by Amazon Rekognition.
    TextDetection -> Maybe Text
detectedText :: Prelude.Maybe Prelude.Text,
    -- | The location of the detected text on the image. Includes an axis aligned
    -- coarse bounding box surrounding the text and a finer grain polygon for
    -- more accurate spatial information.
    TextDetection -> Maybe Geometry
geometry :: Prelude.Maybe Geometry,
    -- | The identifier for the detected text. The identifier is only unique for
    -- a single call to @DetectText@.
    TextDetection -> Maybe Natural
id :: Prelude.Maybe Prelude.Natural,
    -- | The Parent identifier for the detected text identified by the value of
    -- @ID@. If the type of detected text is @LINE@, the value of @ParentId@ is
    -- @Null@.
    TextDetection -> Maybe Natural
parentId :: Prelude.Maybe Prelude.Natural,
    -- | The type of text that was detected.
    TextDetection -> Maybe TextTypes
type' :: Prelude.Maybe TextTypes
  }
  deriving (TextDetection -> TextDetection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextDetection -> TextDetection -> Bool
$c/= :: TextDetection -> TextDetection -> Bool
== :: TextDetection -> TextDetection -> Bool
$c== :: TextDetection -> TextDetection -> Bool
Prelude.Eq, ReadPrec [TextDetection]
ReadPrec TextDetection
Int -> ReadS TextDetection
ReadS [TextDetection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextDetection]
$creadListPrec :: ReadPrec [TextDetection]
readPrec :: ReadPrec TextDetection
$creadPrec :: ReadPrec TextDetection
readList :: ReadS [TextDetection]
$creadList :: ReadS [TextDetection]
readsPrec :: Int -> ReadS TextDetection
$creadsPrec :: Int -> ReadS TextDetection
Prelude.Read, Int -> TextDetection -> ShowS
[TextDetection] -> ShowS
TextDetection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextDetection] -> ShowS
$cshowList :: [TextDetection] -> ShowS
show :: TextDetection -> String
$cshow :: TextDetection -> String
showsPrec :: Int -> TextDetection -> ShowS
$cshowsPrec :: Int -> TextDetection -> ShowS
Prelude.Show, forall x. Rep TextDetection x -> TextDetection
forall x. TextDetection -> Rep TextDetection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TextDetection x -> TextDetection
$cfrom :: forall x. TextDetection -> Rep TextDetection x
Prelude.Generic)

-- |
-- Create a value of 'TextDetection' 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:
--
-- 'confidence', 'textDetection_confidence' - The confidence that Amazon Rekognition has in the accuracy of the
-- detected text and the accuracy of the geometry points around the
-- detected text.
--
-- 'detectedText', 'textDetection_detectedText' - The word or line of text recognized by Amazon Rekognition.
--
-- 'geometry', 'textDetection_geometry' - The location of the detected text on the image. Includes an axis aligned
-- coarse bounding box surrounding the text and a finer grain polygon for
-- more accurate spatial information.
--
-- 'id', 'textDetection_id' - The identifier for the detected text. The identifier is only unique for
-- a single call to @DetectText@.
--
-- 'parentId', 'textDetection_parentId' - The Parent identifier for the detected text identified by the value of
-- @ID@. If the type of detected text is @LINE@, the value of @ParentId@ is
-- @Null@.
--
-- 'type'', 'textDetection_type' - The type of text that was detected.
newTextDetection ::
  TextDetection
newTextDetection :: TextDetection
newTextDetection =
  TextDetection'
    { $sel:confidence:TextDetection' :: Maybe Double
confidence = forall a. Maybe a
Prelude.Nothing,
      $sel:detectedText:TextDetection' :: Maybe Text
detectedText = forall a. Maybe a
Prelude.Nothing,
      $sel:geometry:TextDetection' :: Maybe Geometry
geometry = forall a. Maybe a
Prelude.Nothing,
      $sel:id:TextDetection' :: Maybe Natural
id = forall a. Maybe a
Prelude.Nothing,
      $sel:parentId:TextDetection' :: Maybe Natural
parentId = forall a. Maybe a
Prelude.Nothing,
      $sel:type':TextDetection' :: Maybe TextTypes
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The confidence that Amazon Rekognition has in the accuracy of the
-- detected text and the accuracy of the geometry points around the
-- detected text.
textDetection_confidence :: Lens.Lens' TextDetection (Prelude.Maybe Prelude.Double)
textDetection_confidence :: Lens' TextDetection (Maybe Double)
textDetection_confidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextDetection' {Maybe Double
confidence :: Maybe Double
$sel:confidence:TextDetection' :: TextDetection -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: TextDetection
s@TextDetection' {} Maybe Double
a -> TextDetection
s {$sel:confidence:TextDetection' :: Maybe Double
confidence = Maybe Double
a} :: TextDetection)

-- | The word or line of text recognized by Amazon Rekognition.
textDetection_detectedText :: Lens.Lens' TextDetection (Prelude.Maybe Prelude.Text)
textDetection_detectedText :: Lens' TextDetection (Maybe Text)
textDetection_detectedText = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextDetection' {Maybe Text
detectedText :: Maybe Text
$sel:detectedText:TextDetection' :: TextDetection -> Maybe Text
detectedText} -> Maybe Text
detectedText) (\s :: TextDetection
s@TextDetection' {} Maybe Text
a -> TextDetection
s {$sel:detectedText:TextDetection' :: Maybe Text
detectedText = Maybe Text
a} :: TextDetection)

-- | The location of the detected text on the image. Includes an axis aligned
-- coarse bounding box surrounding the text and a finer grain polygon for
-- more accurate spatial information.
textDetection_geometry :: Lens.Lens' TextDetection (Prelude.Maybe Geometry)
textDetection_geometry :: Lens' TextDetection (Maybe Geometry)
textDetection_geometry = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextDetection' {Maybe Geometry
geometry :: Maybe Geometry
$sel:geometry:TextDetection' :: TextDetection -> Maybe Geometry
geometry} -> Maybe Geometry
geometry) (\s :: TextDetection
s@TextDetection' {} Maybe Geometry
a -> TextDetection
s {$sel:geometry:TextDetection' :: Maybe Geometry
geometry = Maybe Geometry
a} :: TextDetection)

-- | The identifier for the detected text. The identifier is only unique for
-- a single call to @DetectText@.
textDetection_id :: Lens.Lens' TextDetection (Prelude.Maybe Prelude.Natural)
textDetection_id :: Lens' TextDetection (Maybe Natural)
textDetection_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextDetection' {Maybe Natural
id :: Maybe Natural
$sel:id:TextDetection' :: TextDetection -> Maybe Natural
id} -> Maybe Natural
id) (\s :: TextDetection
s@TextDetection' {} Maybe Natural
a -> TextDetection
s {$sel:id:TextDetection' :: Maybe Natural
id = Maybe Natural
a} :: TextDetection)

-- | The Parent identifier for the detected text identified by the value of
-- @ID@. If the type of detected text is @LINE@, the value of @ParentId@ is
-- @Null@.
textDetection_parentId :: Lens.Lens' TextDetection (Prelude.Maybe Prelude.Natural)
textDetection_parentId :: Lens' TextDetection (Maybe Natural)
textDetection_parentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextDetection' {Maybe Natural
parentId :: Maybe Natural
$sel:parentId:TextDetection' :: TextDetection -> Maybe Natural
parentId} -> Maybe Natural
parentId) (\s :: TextDetection
s@TextDetection' {} Maybe Natural
a -> TextDetection
s {$sel:parentId:TextDetection' :: Maybe Natural
parentId = Maybe Natural
a} :: TextDetection)

-- | The type of text that was detected.
textDetection_type :: Lens.Lens' TextDetection (Prelude.Maybe TextTypes)
textDetection_type :: Lens' TextDetection (Maybe TextTypes)
textDetection_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextDetection' {Maybe TextTypes
type' :: Maybe TextTypes
$sel:type':TextDetection' :: TextDetection -> Maybe TextTypes
type'} -> Maybe TextTypes
type') (\s :: TextDetection
s@TextDetection' {} Maybe TextTypes
a -> TextDetection
s {$sel:type':TextDetection' :: Maybe TextTypes
type' = Maybe TextTypes
a} :: TextDetection)

instance Data.FromJSON TextDetection where
  parseJSON :: Value -> Parser TextDetection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TextDetection"
      ( \Object
x ->
          Maybe Double
-> Maybe Text
-> Maybe Geometry
-> Maybe Natural
-> Maybe Natural
-> Maybe TextTypes
-> TextDetection
TextDetection'
            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
"Confidence")
            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
"DetectedText")
            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
"Geometry")
            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
"Id")
            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
"ParentId")
            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
"Type")
      )

instance Prelude.Hashable TextDetection where
  hashWithSalt :: Int -> TextDetection -> Int
hashWithSalt Int
_salt TextDetection' {Maybe Double
Maybe Natural
Maybe Text
Maybe Geometry
Maybe TextTypes
type' :: Maybe TextTypes
parentId :: Maybe Natural
id :: Maybe Natural
geometry :: Maybe Geometry
detectedText :: Maybe Text
confidence :: Maybe Double
$sel:type':TextDetection' :: TextDetection -> Maybe TextTypes
$sel:parentId:TextDetection' :: TextDetection -> Maybe Natural
$sel:id:TextDetection' :: TextDetection -> Maybe Natural
$sel:geometry:TextDetection' :: TextDetection -> Maybe Geometry
$sel:detectedText:TextDetection' :: TextDetection -> Maybe Text
$sel:confidence:TextDetection' :: TextDetection -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
confidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
detectedText
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Geometry
geometry
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
parentId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TextTypes
type'

instance Prelude.NFData TextDetection where
  rnf :: TextDetection -> ()
rnf TextDetection' {Maybe Double
Maybe Natural
Maybe Text
Maybe Geometry
Maybe TextTypes
type' :: Maybe TextTypes
parentId :: Maybe Natural
id :: Maybe Natural
geometry :: Maybe Geometry
detectedText :: Maybe Text
confidence :: Maybe Double
$sel:type':TextDetection' :: TextDetection -> Maybe TextTypes
$sel:parentId:TextDetection' :: TextDetection -> Maybe Natural
$sel:id:TextDetection' :: TextDetection -> Maybe Natural
$sel:geometry:TextDetection' :: TextDetection -> Maybe Geometry
$sel:detectedText:TextDetection' :: TextDetection -> Maybe Text
$sel:confidence:TextDetection' :: TextDetection -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
confidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
detectedText
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Geometry
geometry
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
parentId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TextTypes
type'