Class GeniusScanLibrary


  • public class GeniusScanLibrary
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static DocumentDetectionResult analyzeQuadStream​(Quadrangle quadrangle)
      Analyze quadrangle from a video stream.
      static Quadrangle detectFrame​(byte[] ycrcb420Buffer, int width, int height)
      Detect a quadrangle in the image.
      static Quadrangle detectFrame​(android.graphics.Bitmap bitmap)
      Detect a quadrangle in the image.
      static Quadrangle detectFrame​(java.lang.String imageToAnalyzePath)
      Detect a quadrangle in the image.
      static ImageType detectImageType​(android.graphics.Bitmap bitmap)
      Detect the type of image.
      static ImageType detectImageType​(java.lang.String imagePath)
      Detect the type of image.
      static android.graphics.Bitmap enhanceImage​(android.graphics.Bitmap in, ImageType imageType)
      Enhance image according to the given image type.
      static void enhanceImage​(java.lang.String imageToEnhancePath, java.lang.String enhancedImagePath, ImageType imageType)
      Enhance image according to the given image type.
      static Logger getLogger()
      Return the logger used by the SDK.
      static int getMinDurationInAboutToTriggerForTrigger()
      Minimum duration between DocumentDetectionStatus.ABOUT_TO_TRIGGER and DocumentDetectionStatus.TRIGGER.
      static void init​(android.content.Context context, java.lang.String licenseKey)
      Initialize the SDK library
      static void initQuadrangleAnalyzer()
      Reset status of the quadrangle analyzer.
      static BitmapProcessingResult process​(android.graphics.Bitmap inBitmap, ProcessingParameters parameters)
      Process bitmap using the given processing parameters.
      static ProcessingParameters process​(java.lang.String inPath, java.lang.String outPath, ProcessingParameters parameters)
      Detect the type of image if needed, warp it, and enhance it using the pre-defined parameters.
      static android.graphics.Bitmap rotateImage​(android.graphics.Bitmap in, int angle)
      Rotate an image.
      static void rotateImage​(java.lang.String imageToRotatePath, java.lang.String rotatedImagePath, RotationAngle angle)
      Rotate an image.
      static void scaleImage​(java.lang.String inPath, java.lang.String outPath, float scalingRatio)
      Create a new scaled image.
      static void scaleImage​(java.lang.String inPath, java.lang.String outPath, int maxImageSize)
      Scale image so that both dimensions fit inside given size.
      static void setJPGQuality​(int JPGQuality)
      Sets the JPG quality used to write images
      static void setLogger​(Logger logger)
      Set the logger used by the SDK.
      static android.graphics.Bitmap warpImage​(android.graphics.Bitmap in, Quadrangle quadrangle)
      Warp the image according to the given quadrangle.
      static void warpImage​(java.lang.String imageToWarpPath, java.lang.String warpedImagePath, Quadrangle quadrangle)
      Warp the image according to the given quadrangle.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GeniusScanLibrary

        public GeniusScanLibrary()
    • Method Detail

      • init

        public static void init​(android.content.Context context,
                                java.lang.String licenseKey)
                         throws LicenseException
        Initialize the SDK library
        Parameters:
        context - Application or activity context
        Throws:
        LicenseException
      • setLogger

        public static void setLogger​(Logger logger)
        Set the logger used by the SDK.
        Parameters:
        logger - Logger
      • getLogger

        public static Logger getLogger()
        Return the logger used by the SDK. Default implementation logs to the Android console
        Returns:
        Object implementing the Logger interface
      • setJPGQuality

        public static void setJPGQuality​(int JPGQuality)
        Sets the JPG quality used to write images
        Parameters:
        JPGQuality - Desired JPG quality (between 0 and 100)
      • detectFrame

        public static Quadrangle detectFrame​(java.lang.String imageToAnalyzePath)
                                      throws java.io.IOException,
                                             ProcessingException,
                                             LicenseException
        Detect a quadrangle in the image. The quadrangle x and y coordinates are relative respectively to the width and height of the image. If nothing is detected, the quadrangle is set to the full image.
        Parameters:
        imageToAnalyzePath - Path to the input image
        Returns:
        The detected quadrangle
        Throws:
        java.io.IOException - if input file cannot be read
        ProcessingException - if detection failed (e.g. image is corrupted)
        LicenseException
      • warpImage

        public static void warpImage​(java.lang.String imageToWarpPath,
                                     java.lang.String warpedImagePath,
                                     Quadrangle quadrangle)
                              throws java.io.IOException,
                                     ProcessingException,
                                     LicenseException
        Warp the image according to the given quadrangle.
        Parameters:
        imageToWarpPath - Path of the image to warp
        warpedImagePath - Desired path for the warped image
        quadrangle - Quadrangle used to warp the image
        Throws:
        java.io.IOException - if input file cannot be read or output folder does not exist
        ProcessingException - if warping failed (e.g. quadrangle is not convex)
        LicenseException
      • detectImageType

        public static ImageType detectImageType​(java.lang.String imagePath)
                                         throws java.io.IOException,
                                                ProcessingException,
                                                LicenseException
        Detect the type of image. Type of the image can be Color, Black and white...
        Parameters:
        imagePath - Path of the input image
        Returns:
        The type of image
        Throws:
        java.io.IOException - if input file cannot be read
        ProcessingException
        LicenseException
      • enhanceImage

        public static void enhanceImage​(java.lang.String imageToEnhancePath,
                                        java.lang.String enhancedImagePath,
                                        ImageType imageType)
                                 throws java.io.IOException,
                                        LicenseException,
                                        ProcessingException
        Enhance image according to the given image type.
        Parameters:
        imageToEnhancePath - Path of the input image
        enhancedImagePath - Desired path for the enhanced image
        imageType - Image type used to enhance image
        Throws:
        java.io.IOException - if input file cannot be read or output folder does not exist
        LicenseException
        ProcessingException
      • enhanceImage

        public static android.graphics.Bitmap enhanceImage​(android.graphics.Bitmap in,
                                                           ImageType imageType)
                                                    throws ProcessingException,
                                                           LicenseException
        Enhance image according to the given image type.
        Parameters:
        in - Image bitmap to enhance
        imageType - Image type used to enhance image
        Returns:
        The enhanced image bitmap
        Throws:
        ProcessingException - if enhancing failed (e.g. if bitmap is not valid)
        LicenseException
      • rotateImage

        public static void rotateImage​(java.lang.String imageToRotatePath,
                                       java.lang.String rotatedImagePath,
                                       RotationAngle angle)
                                throws java.io.IOException,
                                       ProcessingException,
                                       LicenseException
        Rotate an image.
        Parameters:
        imageToRotatePath - Path to the input image
        rotatedImagePath - Desired path to the output image
        angle - Rotation angle
        Throws:
        java.io.IOException - if input file cannot be read or output folder does not exist
        ProcessingException
        LicenseException
      • rotateImage

        public static android.graphics.Bitmap rotateImage​(android.graphics.Bitmap in,
                                                          int angle)
                                                   throws ProcessingException,
                                                          LicenseException
        Rotate an image.
        Parameters:
        in - Image bitmap to rotate
        angle - Rotation angle in degrees. It must a multiple of 90 degrees.
        Returns:
        The rotated image bitmap
        Throws:
        ProcessingException - if rotation fails (eg if bitmap is not valid)
        LicenseException
      • scaleImage

        public static void scaleImage​(java.lang.String inPath,
                                      java.lang.String outPath,
                                      float scalingRatio)
                               throws java.io.IOException,
                                      LicenseException,
                                      ProcessingException
        Create a new scaled image.
        Parameters:
        inPath - Path of the input image
        outPath - Path of the output image
        scalingRatio - Ratio between the output image and the input image
        Throws:
        java.io.IOException - if input file cannot be read
        LicenseException
        ProcessingException
      • scaleImage

        public static void scaleImage​(java.lang.String inPath,
                                      java.lang.String outPath,
                                      int maxImageSize)
                               throws java.io.IOException,
                                      LicenseException,
                                      ProcessingException
        Scale image so that both dimensions fit inside given size.
        Parameters:
        inPath - Path of the input image
        outPath - Path of the output image
        maxImageSize - Max image size after resize operation
        Throws:
        java.io.IOException - if input file cannot be read
        LicenseException
        ProcessingException
      • process

        @NonNull
        public static ProcessingParameters process​(java.lang.String inPath,
                                                   java.lang.String outPath,
                                                   ProcessingParameters parameters)
                                            throws java.io.IOException,
                                                   ProcessingException,
                                                   LicenseException
        Detect the type of image if needed, warp it, and enhance it using the pre-defined parameters.
        Parameters:
        inPath - Path of the input image
        outPath - Path of the output image
        parameters - User-defined settings to process the image
        Returns:
        Settings used to process the image after optional detection
        Throws:
        java.io.IOException - if input file cannot be read
        ProcessingException
        LicenseException
      • analyzeQuadStream

        public static DocumentDetectionResult analyzeQuadStream​(Quadrangle quadrangle)
        Analyze quadrangle from a video stream. This is intended to be used for real-time detection.
        Parameters:
        quadrangle - Quadrangle to analyze
        Returns:
        Result of the analysis. A result contains a status and an optional quadrangle.
      • initQuadrangleAnalyzer

        public static void initQuadrangleAnalyzer()
        Reset status of the quadrangle analyzer. Should be called when a new video stream starts.
      • getMinDurationInAboutToTriggerForTrigger

        public static int getMinDurationInAboutToTriggerForTrigger()
        Minimum duration between DocumentDetectionStatus.ABOUT_TO_TRIGGER and DocumentDetectionStatus.TRIGGER.
        Returns:
        duration (milliseconds)