Class ImageReader
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);
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.digimarc.dms.readers.BaseReader
BaseReader.AudioSymbology, BaseReader.ImageDetectionType, BaseReader.ImageSymbology, BaseReader.ReaderError, BaseReader.ResultType, BaseReader.Symbology, BaseReader.UndefinedSymbology
-
Field Summary
Fields inherited from class com.digimarc.dms.readers.BaseReader
All_Audio_Readers, All_Barcode_1D_Readers, All_Barcode_Readers, All_Image_Readers
-
Method Summary
Modifier and TypeMethodDescriptionstatic ImageReader.Builder
Builder
(SdkSession session) Get Builder object for creating an ImageReader objectvoid
This method clears the internalPayloadCache
.processBitmap
(android.graphics.Bitmap bitmap) Synchronously process a bitmap image and return a result when completed.processImageFrame
(ImageData imageData) Synchronously process anImageData
and return a result when completed.void
release()
This method should be called when the reader is no longer needed.void
setAllowPerformanceScheduling
(boolean allowPerformanceScheduling) This method allows managed reader performance to be turned off.setImageDetectionRegion
(android.graphics.RectF rect) Deprecated.This method may not work as expected in all display orientations.void
setImageDetectionRegion
(DetectionRegion detectionRegion) Specifies the image area that will be used for detection.Methods inherited from class com.digimarc.dms.readers.BaseReader
buildSymbologyMask, getReaderOptions, getSymbologies, setReaderOptions, setSymbologies
-
Method Details
-
Builder
Get Builder object for creating an ImageReader object- Parameters:
session
- SdkSession object initialized with a valid license key.- Returns:
- Builder
-
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 classBaseReader
-
clearCache
public void clearCache()Description copied from class:BaseReader
This method clears the internalPayloadCache
.- Overrides:
clearCache
in classBaseReader
-
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 classBaseReader
- 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 anImageData
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 thanCameraHelper
.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
Specifies the image area that will be used for detection.- Parameters:
detectionRegion
- TheDetectionRegion
for detection.
-