Class DocumentSpecification

java.lang.Object
com.microblink.blinkinput.entities.detectors.quad.Specification
com.microblink.blinkinput.entities.detectors.quad.document.DocumentSpecification

public class DocumentSpecification extends Specification
Class representing specification of document that can be detected with DocumentDetector.
  • Field Summary

    Fields inherited from class com.microblink.blinkinput.entities.detectors.quad.Specification

    mNativeContext
  • Constructor Summary

    Constructors
    Constructor
    Description
    DocumentSpecification(double aspectRatio, float physicalHeightInInches)
    Constructor, defines aspect ratio of document that needs to be detected.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new document that will be detected from preset.
    double
    Returns the aspect ratio of document that will be detected.
    Returns the detection mode that defines in which orientations can this document be detected.
    double[]
    Returns the scale and tolerance that will be used when detecting document in landscape orientation.
    double
    Retrieves maximum angle for document detection
    double[]
    Returns the scale and tolerance that will be used when detecting document in portrait orientation.
    double[]
    Gets the percentage of possible document offset on x axis.
    double[]
    Gets the percentage of possible document offset on y axis.
    void
    setAspectRatio(double aspectRatio)
    Sets the aspect ratio of document that will be detected.
    void
    Sets the detection mode that defines in which orientations can this document be detected.
    void
    setLandscapeScale(double scale, double tolerance)
    Sets the scale and scale tolerance that will be used when detecting document in landscape orientation.
    void
    setMaxAngle(double maxAngle)
    Sets maximum angle for document detection.
    void
    setPortraitScale(double scale, double tolerance)
    Sets the scale and scale tolerance that will be used when detecting document in portrait orientation.
    void
    setScale(double scale, double tolerance)
    Sets the scale and scale tolerance that will be used when detecting document in both orientations.
    void
    setXRange(double leftRange, double rightRange)
    Sets percentage of possible document offset on x axis.
    void
    setYRange(double aboveRange, double belowRange)
    Sets percentage of possible document offset on y axis.
    protected void
    terminateNative(long nativeContext)
     

    Methods inherited from class com.microblink.blinkinput.entities.detectors.quad.Specification

    finalize, getPhysicalHeightInInches

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DocumentSpecification

      public DocumentSpecification(@FloatRange(from=0.0,fromInclusive=false) double aspectRatio, @FloatRange(from=0.0,fromInclusive=false) float physicalHeightInInches)
      Constructor, defines aspect ratio of document that needs to be detected.
      Parameters:
      aspectRatio - Aspect ratio of the document, must be positive
      physicalHeightInInches - Physical height of document in inches.
  • Method Details

    • getAspectRatio

      public double getAspectRatio()
      Returns the aspect ratio of document that will be detected.
      Returns:
      the aspect ratio of document that will be detected.
    • setAspectRatio

      public void setAspectRatio(@FloatRange(from=0.0,fromInclusive=false) double aspectRatio)
      Sets the aspect ratio of document that will be detected.
      Parameters:
      aspectRatio - aspect ratio of document, must be positive
    • getDetectionMode

      @NonNull public DetectionMode getDetectionMode()
      Returns the detection mode that defines in which orientations can this document be detected.
      Returns:
      the detection mode that defines in which orientations can this document be detected.
    • setDetectionMode

      public void setDetectionMode(@NonNull DetectionMode mode)
      Sets the detection mode that defines in which orientations can this document be detected.
      Parameters:
      mode - detection mode that defines in which orientations can this document be detected.
    • setLandscapeScale

      public void setLandscapeScale(@FloatRange(from=0.0,fromInclusive=false,to=1.0) double scale, @FloatRange(from=0.0,to=1.0) double tolerance)
      Sets the scale and scale tolerance that will be used when detecting document in landscape orientation.
      Parameters:
      scale - Ideal scale defined as percentage of frame height at which document should be detected.
      tolerance - Scale tolerance is number that together with scale defines scale interval at which document can be detected. Scale interval is [scale-tolerance, scale+tolerance]
    • getLandscapeScale

      @NonNull public double[] getLandscapeScale()
      Returns the scale and tolerance that will be used when detecting document in landscape orientation.
      Returns:
      Array containing two numbers. First number (at index 0) will be scale and second (at index 1) will be scale tolerance.
    • setPortraitScale

      public void setPortraitScale(@FloatRange(from=0.0,fromInclusive=false,to=1.0) double scale, @FloatRange(from=0.0,to=1.0) double tolerance)
      Sets the scale and scale tolerance that will be used when detecting document in portrait orientation.
      Parameters:
      scale - Ideal scale defined as percentage of frame height at which document should be detected.
      tolerance - Scale tolerance is number that together with scale defines scale interval at which document can be detected. Scale interval is [scale-tolerance, scale+tolerance]
    • getPortraitScale

      @NonNull public double[] getPortraitScale()
      Returns the scale and tolerance that will be used when detecting document in portrait orientation.
      Returns:
      Array containing two numbers. First number (at index 0) will be scale and second (at index 1) will be scale tolerance.
    • setScale

      public void setScale(@FloatRange(from=0.0,fromInclusive=false,to=1.0) double scale, @FloatRange(from=0.0,to=1.0) double tolerance)
      Sets the scale and scale tolerance that will be used when detecting document in both orientations. This method is same as calling both setPortraitScale(double, double) and setLandscapeScale(double, double) with same parameters.
      Parameters:
      scale - Ideal scale defined as percentage of frame height at which document should be detected.
      tolerance - Scale tolerance is number that together with scale defines scale interval at which document can be detected. Scale interval is [scale-tolerance, scale+tolerance]
    • setMaxAngle

      public void setMaxAngle(@FloatRange(from=0.0,to=35.0) double maxAngle)
      Sets maximum angle for document detection. Allowed values are in interval [0, 35]
      Parameters:
      maxAngle - maximum angle for document detection. Allowed values are in interval [0, 35].
    • getMaxAngle

      public double getMaxAngle()
      Retrieves maximum angle for document detection
      Returns:
      maximum angle for document detection
    • setXRange

      public void setXRange(@FloatRange(from=-1.0,to=0.0) double leftRange, @FloatRange(from=0.0,to=1.0) double rightRange)
      Sets percentage of possible document offset on x axis.
      Parameters:
      leftRange - possible left offset of centre. Value must be in range [-1, 0].
      rightRange - possible right offset of centre. Value must be in range [0, 1]
    • getXRange

      @NonNull public double[] getXRange()
      Gets the percentage of possible document offset on x axis.
      Returns:
      Array of two elements, first indicating the possible left offset of centre and second indicating the possible right offset of centre.
    • setYRange

      public void setYRange(@FloatRange(from=-1.0,to=0.0) double aboveRange, @FloatRange(from=0.0,to=1.0) double belowRange)
      Sets percentage of possible document offset on y axis.
      Parameters:
      aboveRange - possible offset above centre. Value must be in range [-1, 0].
      belowRange - possible offset below centre. Value must be in range [0, 1]
    • getYRange

      @NonNull public double[] getYRange()
      Gets the percentage of possible document offset on y axis.
      Returns:
      Array of two elements, first indicating the possible offset above centre and second indicating the possible offset below centre.
    • terminateNative

      protected void terminateNative(long nativeContext)
      Specified by:
      terminateNative in class Specification
    • createFromPreset

      @NonNull public static DocumentSpecification createFromPreset(@NonNull DocumentSpecificationPreset preset)
      Creates a new document that will be detected from preset.
      Parameters:
      preset - Preset defining which document detection settings should be created.
      Returns:
      document created from given preset