Class BaseReader

java.lang.Object
com.digimarc.dms.readers.BaseReader
Direct Known Subclasses:
AudioReader, BaseCaptureReader, ImageReader

public class BaseReader extends Object
All reader objects derive from this base class. Readers are available for both image and audio, and they can be separated into two main types: synchronous and asynchronous. The synchronous readers (ImageReader and AudioReader) provide a base level of reading functionality but they are not intended for use with streaming or captured media. The asynchronous readers (VideoCaptureReader and AudioCaptureReader) are intended for media capture applications and provide a more advanced level of capabilities. The asynchronous readers are designed to balance their performance levels (processor use, frequency of execution, etc.) to provide the best reading experience for an application.
  • Field Details

    • All_Barcode_1D_Readers

      public static final int All_Barcode_1D_Readers
      Prebuilt bitmask containing all the available 1D barcode readers.
      See Also:
    • All_Barcode_Readers

      public static final int All_Barcode_Readers
      Prebuilt bitmask containing the normally used barcode readers (1D & QR). Note that PDF417 is not included in this bitmask.
      See Also:
    • All_Image_Readers

      public static final int All_Image_Readers
      Prebuilt bitmask containing the normally used image readers. Note that PDF417 is not included in this bitmask.
      See Also:
    • All_Audio_Readers

      public static final int All_Audio_Readers
      Prebuilt bitmask containing all the available audio readers.
      See Also:
    • mOptions

      @NonNull protected ReaderOptions mOptions
    • mSymbologyMask

      protected int mSymbologyMask
    • mAllowScheduling

      protected boolean mAllowScheduling
    • mActionLock

      protected final ReentrantLock mActionLock
  • Constructor Details

    • BaseReader

      protected BaseReader(int symbologyMask, @Nullable ReaderOptions options) throws ReaderException
      Constructor.
      Parameters:
      symbologyMask - A bitmask value containing the symbologies that the reader should use.
      options - An optional dictionary of flags and settings for the reader. The available entries are documented separately.
      Throws:
      ReaderException - An exception will be thrown if an invalid symbology or options entry is specified for this reader.
  • Method Details

    • release

      @CallSuper public void release()
      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.
    • setSymbologies

      @CallSuper public void setSymbologies(int symbologyMask) throws ReaderException
      Throws:
      ReaderException
    • buildSymbologyMask

      public static int buildSymbologyMask(@NonNull BaseReader.Symbology... symbologies)
      Helper method to build a symbology bitmask of different reader types.
      Parameters:
      symbologies - A list of the symbologies to be added to the bitmask
      Returns:
      A bitmask value containing the specified readers.
    • initialize

      @CallSuper protected void initialize() throws ReaderException
      Throws:
      ReaderException
    • createDetectors

      @CallSuper protected void createDetectors() throws ReaderException
      Throws:
      ReaderException
    • releaseDetectors

      protected void releaseDetectors()
    • getReaderOptions

      @Nullable public ReaderOptions getReaderOptions()
      Allows an application to retrieve the reader dictionary that was passed in to the constructor.
      Returns:
      A ReaderOptions dictionary or null if none was specified in the constructor.
    • setReaderOptions

      public void setReaderOptions(@Nullable ReaderOptions options) throws ReaderException
      Allows the reader to be reconfigured with new reader options after creation. Passing in null will clear all existing reader options.
      Parameters:
      options - ReaderOptions dictionary.
      Throws:
      ReaderException
    • getSymbologies

      public int getSymbologies()
      Get the bitmask of symbologies the reader is looking for.
      Returns:
      Bitmask of symbologies.
    • setAllowPerformanceScheduling

      @CallSuper public void setAllowPerformanceScheduling(boolean allowScheduling)
      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.

      Parameters:
      allowScheduling - Set whether performance scheduling may occur. If scheduling is not allowed then every frame passed into the reader will be processed.
    • clearCache

      public void clearCache()
      This method clears the internal PayloadCache.
    • validateSymbologies

      protected boolean validateSymbologies(int symbologyMask, @NonNull BaseReader.ReaderType type)
      This method will ensure that the symbology mask value specified for a reader includes at least one valid symbology for this type of reader (image or audio).
      Parameters:
      symbologyMask - Bitmask of symbology values as passed into the reader constructor.
      type - Enum from BaseReader.ReaderType for what type of reader we are validating.
      Returns:
      Returns true if the bitmask contains at least one valid symbology for the indicated reader type, false otherwise.