Class VideoCaptureReader
This class provides asynchronous image reading with a built in level of performance management.
Integrating with CameraHelper
The CameraHelper class allows developers to
create a camera session and easily integrate it with a VideoCaptureReader. The following example
demonstrates how to create and connect the objects, so that camera frames are piped to the capture
reader:
// Define a ResultListener for handling results from the reader
resultListener = new ResultListener() {
public void onReaderResult(@NonNull ReaderResult result, @NonNull BaseReader.ResultType resultType) {
if (result.getNewPayloads() != null) {
// handle results
}
}
public void onError(@NonNull BaseReader.ReaderError errorCode, @NonNull BaseReader.ResultType resultType){
// handle error
}
};
// Create CameraHelper object
cameraHelper = CameraHelper.Builder().build();
// Build VideoCaptureReader object, passing in mCameraHelper as the camera source
cameraReader = VideoCaptureReader.Builder()
.setSymbologies(BaseReader.All_Image_Readers)
.setResultListener(resultListener)
.setCameraHelper(cameraHelper)
.build();
-
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 TypeMethodDescriptionvoidattachCamera(CameraHelper camera) This method will create a CameraDataListener instance and pipe the images received directly into the reader's processImageFrame() method.static VideoCaptureReader.BuilderBuilder(SdkSession session) Get Builder object for creating an VideoCaptureReader objectvoidThis method clears the internalPayloadCache.voidprocessImageFrame(ImageData image) Asynchronously process an image frame.voidrelease()This method should be called when the reader is no longer needed.voidUnregister this reader's CameraDataListener instance.voidsetAllowPerformanceScheduling(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.voidsetImageDetectionRegion(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 VideoCaptureReader object- Parameters:
session- SdkSession object initialized with a valid license key.- Returns:
- Builder
-
release
public void release()Description copied from class:BaseReaderThis 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:
releasein classBaseCaptureReader
-
clearCache
public void clearCache()Description copied from class:BaseReaderThis method clears the internalPayloadCache.- Overrides:
clearCachein classBaseReader
-
setAllowPerformanceScheduling
public void setAllowPerformanceScheduling(boolean allowPerformanceScheduling) Description copied from class:BaseReaderThis 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:
setAllowPerformanceSchedulingin 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
Asynchronously process an image frame. This method will return immediately and results will be delivered via theResultListener.onReaderResult(ReaderResult, ResultType),ResultListener.onError(com.digimarc.dms.readers.BaseReader.ReaderError, com.digimarc.dms.readers.BaseReader.ResultType)- Parameters:
image- An ImageData object containing the image.- 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.Nonewill 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- TheDetectionRegionfor detection.
-
attachCamera
This method will create a CameraDataListener instance and pipe the images received directly into the reader's processImageFrame() method.- Parameters:
camera- Camera instance.
-
releaseCamera
public void releaseCamera()Unregister this reader's CameraDataListener instance. This method is also called as part of therelease()method.
-