Class ImageReader

java.lang.Object
com.digimarc.dms.readers.BaseReader
com.digimarc.dms.readers.image.ImageReader

public class ImageReader extends BaseReader

This class provides synchronous image reading functionality.

When an image frame is passed in the reader will process the entire image before returning. When the call returns the image is no longer needed by the reader and can be released, returned to the camera, etc.

To create an ImageReader, the application must specify a detection strategy, which includes an BaseReader.ImageDetectionType and whether ImageReader should meter performance by skipping input frames. The following code shows how to build an ImageReader that uses the default DetectionType and processes every frame:


  imageReader = ImageReader.Builder()
                 .setSymbologies(BaseReader.All_Image_Readers)
                 .setDetectionStrategy(BaseReader.ImageDetectionType.Default, false)
                 .build();
 

Image detection can then be performed using one of the detection functions:


 ReaderResult result = imageReader.processBitmap(myBitmap);
 
  • Method Details

    • Builder

      @NonNull public static ImageReader.Builder Builder(SdkSession session)
      Get Builder object for creating an ImageReader object
      Parameters:
      session - SdkSession object initialized with a valid license key.
      Returns:
      Builder
    • initialize

      protected void initialize() throws ReaderException
      Overrides:
      initialize in class BaseReader
      Throws:
      ReaderException
    • createDetectors

      protected void createDetectors() throws ReaderException
      Overrides:
      createDetectors in class BaseReader
      Throws:
      ReaderException
    • release

      public void release()
      Description copied from class: BaseReader
      This method should be called when the reader is no longer needed. Failure to call this method may result in objects remaining in memory beyond their useful lifespan.
      Overrides:
      release in class BaseReader
    • clearCache

      public void clearCache()
      Description copied from class: BaseReader
      This method clears the internal PayloadCache.
      Overrides:
      clearCache in class BaseReader
    • setAllowPerformanceScheduling

      public void setAllowPerformanceScheduling(boolean allowPerformanceScheduling)
      Description copied from class: BaseReader
      This method allows managed reader performance to be turned off. It is primarily useful for applications using asynchronous readers, although it can be used with synchronous readers.

      In normal operation the SDK will work to balance the performance of asynchronous readers. This is useful for maximizing throughput while also working to not overload the device. In practice this means that some image frames might be ignored by a reader. In some applications, though, this might not be desirable to disable this behavior. For instance, if your application is performing operations (resizing, scaling, etc.) on the image frames before they go into the reader you would want to be sure that every frame you modified was read, otherwise you might be wasting time processing a frame that is going to be dropped.

      Overrides:
      setAllowPerformanceScheduling in class BaseReader
      Parameters:
      allowPerformanceScheduling - Set whether performance scheduling may occur. If scheduling is not allowed then every frame passed into the reader will be processed.
    • processImageFrame

      @Nullable public ReaderResult processImageFrame(@NonNull ImageData imageData) throws ReaderException
      Synchronously process an ImageData and return a result when completed.
      Parameters:
      imageData - ImageData object containing the image to read.
      Returns:
      ReaderResult object containing image processing results.
      Throws:
      ReaderException - Throws an exception if an error occurs in processing. This may occur if the image data doesn't match the image dimensions.
    • processBitmap

      @Nullable public ReaderResult processBitmap(@NonNull android.graphics.Bitmap bitmap) throws ReaderException
      Synchronously process a bitmap image and return a result when completed.
      Parameters:
      bitmap - Bitmap object containing the image to read.
      Returns:
      ReaderResult object containing image processing results.
      Throws:
      ReaderException - Throws an exception if an error occurs in processing. This may occur if the image data doesn't match the image dimensions.
    • setImageDetectionRegion

      @NonNull @Deprecated public BaseReader.ReaderError setImageDetectionRegion(@NonNull android.graphics.RectF rect)
      Deprecated.
      This method may not work as expected in all display orientations. setImageDetectionRegion(DetectionRegion) should be used for apps that need to support rotation or frame sources other than CameraHelper.
      Specifies the image area that will be used for detection.
      Parameters:
      rect - Region for detection. Each value within the rect should be in the range 0..1
      Returns:
      BaseReader.ReaderError.None will be returned on success. An error code will be returned if the coordinates are invalid. This occurs if 1) any value < 0.0f, 2) any value > 1.0f, 3) left > right, 4) top > bottom, or 5) if either the height or width of the region < 0.15f.
    • setImageDetectionRegion

      public void setImageDetectionRegion(@NonNull DetectionRegion detectionRegion)
      Specifies the image area that will be used for detection.
      Parameters:
      detectionRegion - The DetectionRegion for detection.