All Implemented Interfaces:
android.os.Parcelable, GlareDetectorOptions

public final class DetectorRecognizer extends TemplatingRecognizer<DetectorRecognizer.Result>
Templating API recognizer for scanning generic documents by using custom QuadWithSizeDetector. This recognizer is used for implementing support for data extraction from custom document types by using templating API. If you don't need data extraction, but only want to take cropped document images, use DocumentCaptureRecognizer instead.
  • Field Details

    • CREATOR

      @NonNull public static final android.os.Parcelable.Creator<DetectorRecognizer> CREATOR
  • Constructor Details

    • DetectorRecognizer

      public DetectorRecognizer(@NonNull QuadWithSizeDetector<?> detector)
      Parameters:
      detector - Detector that will be used for performing document detection during recognition
  • Method Details

    • getDetector

      @NonNull public QuadWithSizeDetector<?> getDetector()
      Returns the detector that will be used for performing the document detection during recognition
      Returns:
      the detector
    • setAllowFlippedRecognition

      public void setAllowFlippedRecognition(boolean allowFlippedRecognition)
      Set this to true to enable recognition of document also in upside down direction. This is useful if detector being used cannot determine correct orientation of detected document (for example DocumentDetector). Keep in mind that enabling this feature will make recognition two times slower and possibly less accurate. By default, this is turned off.
      Parameters:
      allowFlippedRecognition - whether or not flipped recognition is allowed
    • isAllowFlippedRecognition

      public boolean isAllowFlippedRecognition()
      Returns whether or not flipped recognition feature is enabled. For more information, see setAllowFlippedRecognition(boolean).
      Returns:
      whether or not flipped recognition feature is enabled
    • setDetectGlare

      public void setDetectGlare(boolean detectGlare)
      Description copied from interface: GlareDetectorOptions
      Defines whether glare detector will be used during recognition process. By default this option is set to true and glare detector is used. If the glare detector is used and GlareCallback is set to MetadataCallbacks, it will receive glare status will. Also when glare is detected OCR will not be performed on the affected document position to prevent errors in the extracted data. By default, this is set to 'true'.
      Parameters:
      detectGlare - whether glare detector will be used during recognition process.
    • shouldDetectGlare

      public boolean shouldDetectGlare()
      Description copied from interface: GlareDetectorOptions
      Returns whether glare detector is enabled. By default, this is set to 'true'.
      Returns:
      it the glare detector is enabled returns true, otherwise returns false.
    • setNativeTemplatingClasses

      protected void setNativeTemplatingClasses(@Nullable long[] nativeTemplatingClasses)
      Specified by:
      setNativeTemplatingClasses in class TemplatingRecognizer<DetectorRecognizer.Result>
    • terminateNative

      protected void terminateNative(long nativeContext)
      Specified by:
      terminateNative in class Entity<DetectorRecognizer.Result>
    • serializeNativeSettings

      @Nullable protected byte[] serializeNativeSettings()
      Specified by:
      serializeNativeSettings in class Entity<DetectorRecognizer.Result>
    • deserializeNativeSettings

      protected void deserializeNativeSettings(@NonNull byte[] serializedSettings)
      Specified by:
      deserializeNativeSettings in class Entity<DetectorRecognizer.Result>
    • clone

      @NonNull public DetectorRecognizer clone()
      Description copied from class: Entity
      Create a copy of the entity. This is required if properties of the entity must be modified while background thread performs processing. In order to avoid race conditions, changing properties is not allowed while entity is used in background processing. However, you are able to make a copy of the entity, change properties of it and then update the RecognizerRunnerView or RecognizerRunner with the updated entity hierarchy.
      Specified by:
      clone in class Recognizer<DetectorRecognizer.Result>
      Returns:
      a copy of the entity
    • consumeResultFrom

      public void consumeResultFrom(@NonNull Entity other)
      Description copied from class: Entity
      Consume result from other entity. The result from other will be put instead current result of this entity. This method is used inside BaseIntentTransferable.loadFromIntent(Intent) and similar methods to replace the result content of the saved entities with results that have arrived over Intent
      Overrides:
      consumeResultFrom in class TemplatingRecognizer<DetectorRecognizer.Result>
      Parameters:
      other - Entity from which result should be consumed.
    • writeToParcel

      public void writeToParcel(@NonNull android.os.Parcel dest, int flags)
      Specified by:
      writeToParcel in interface android.os.Parcelable
      Overrides:
      writeToParcel in class TemplatingRecognizer<DetectorRecognizer.Result>