Class VideoCaptureReader


public class VideoCaptureReader extends BaseCaptureReader

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();
 
  • Method Details

    • Builder

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

      protected void createDetectors() throws ReaderException
      Create and initialize detectors for the currently configured set of symbologies.
      Overrides:
      createDetectors in class BaseReader
      Throws:
      ReaderException - Invalid configuration options will cause an exception to be thrown.
    • releaseDetectors

      protected void releaseDetectors()
      Release all current detectors.
      Overrides:
      releaseDetectors in class BaseReader
    • initialize

      protected void initialize() throws ReaderException
      Overrides:
      initialize 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 BaseCaptureReader
    • 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

      public void processImageFrame(@NonNull ImageData image) throws ReaderException
      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 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.
    • attachCamera

      public void attachCamera(@NonNull CameraHelper camera)
      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 the release() method.