Class GeniusScanLibrary
- java.lang.Object
-
- com.thegrizzlylabs.geniusscan.sdk.core.GeniusScanLibrary
-
public class GeniusScanLibrary extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description GeniusScanLibrary()
-
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 librarystatic 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 imagesstatic 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.
-
-
-
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 readProcessingException
- if detection failed (e.g. image is corrupted)LicenseException
-
detectFrame
public static Quadrangle detectFrame(byte[] ycrcb420Buffer, int width, int height) throws ProcessingException, LicenseException
Detect a quadrangle in the image.- Parameters:
ycrcb420Buffer
- Byte array containing image YCrCb420 pixel valueswidth
- Width of the imageheight
- Height of the image- Returns:
- The detected quadrangle
- Throws:
ProcessingException
LicenseException
- See Also:
detectFrame(String)
-
detectFrame
public static Quadrangle detectFrame(android.graphics.Bitmap bitmap) throws ProcessingException, LicenseException
Detect a quadrangle in the image.- Parameters:
bitmap
- Input image bitmap- Returns:
- The detected quadrangle
- Throws:
ProcessingException
LicenseException
- See Also:
detectFrame(String)
-
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 warpwarpedImagePath
- Desired path for the warped imagequadrangle
- Quadrangle used to warp the image- Throws:
java.io.IOException
- if input file cannot be read or output folder does not existProcessingException
- if warping failed (e.g. quadrangle is not convex)LicenseException
-
warpImage
public static android.graphics.Bitmap warpImage(android.graphics.Bitmap in, Quadrangle quadrangle) throws ProcessingException, LicenseException
Warp the image according to the given quadrangle.- Parameters:
in
- Image bitmap to warpquadrangle
- Quadrangle used to warp the image- Returns:
- the warped bitmap image
- Throws:
ProcessingException
LicenseException
- See Also:
warpImage(String, String, Quadrangle)
-
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 readProcessingException
LicenseException
-
detectImageType
public static ImageType detectImageType(android.graphics.Bitmap bitmap) throws LicenseException, ProcessingException
Detect the type of image. Type of the image can be Color, Black and white...- Parameters:
bitmap
- Input image bitmap- Returns:
- The type of image
- Throws:
LicenseException
ProcessingException
- See Also:
detectImageType(String)
-
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 imageenhancedImagePath
- Desired path for the enhanced imageimageType
- Image type used to enhance image- Throws:
java.io.IOException
- if input file cannot be read or output folder does not existLicenseException
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 enhanceimageType
- 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 imagerotatedImagePath
- Desired path to the output imageangle
- Rotation angle- Throws:
java.io.IOException
- if input file cannot be read or output folder does not existProcessingException
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 rotateangle
- 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 imageoutPath
- Path of the output imagescalingRatio
- Ratio between the output image and the input image- Throws:
java.io.IOException
- if input file cannot be readLicenseException
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 imageoutPath
- Path of the output imagemaxImageSize
- Max image size after resize operation- Throws:
java.io.IOException
- if input file cannot be readLicenseException
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 imageoutPath
- Path of the output imageparameters
- 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 readProcessingException
LicenseException
-
process
public static BitmapProcessingResult process(android.graphics.Bitmap inBitmap, ProcessingParameters parameters) throws ProcessingException, LicenseException
Process bitmap using the given processing parameters.- Parameters:
inBitmap
- input bitmapparameters
- quadrangle and image type used to process image.- Returns:
- the processed bitmap and updated parameters
- Throws:
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)
-
-