Accessing Last Processed Image

This page describes how to access the last processed camera frame using the Anyline Mobile SDK for Android, even when no scan result is produced.

Overview

The getLastProcessedImage() method on ScanPlugin provides access to the most recently processed camera frame, regardless of whether it produced a scan result. This feature enables advanced use cases such as manual image capture, debugging workflows, and custom image processing.

Usage

Basic Access

Access the most recent processed image from your scan plugin:

// Get the most recent processed image
AnylineImage lastImage = scanPlugin.getLastProcessedImage();
if (lastImage != null) {
    // Convert to Bitmap for further processing
    Bitmap bitmap = lastImage.getBitmap();

    // Your custom logic here
    processImage(bitmap);

    // Important: Release when done if not used elsewhere
    // lastImage.release();
}

Manual Image Capture

Create a manual capture feature for users:

public void onCaptureButtonPressed() {
    AnylineImage currentFrame = scanPlugin.getLastProcessedImage();
    if (currentFrame != null) {
        // Save to gallery
        MediaStore.Images.Media.insertImage(
            getContentResolver(),
            currentFrame.getBitmap(),
            "Anyline_Capture",
            "Captured with Anyline SDK"
        );

        // Show feedback to user
        showCaptureSuccessMessage();

        // Release the image
        currentFrame.release();
    } else {
        showNoCameraFrameMessage();
    }
}

Best Practices

  • Always check for null: The method returns null if no frame has been processed yet

  • Always call release(): Call image.release() when finished to free memory immediately

  • Use try-finally: Ensure images are released even if exceptions occur

  • Access efficiently: Avoid calling the method repeatedly in tight loops

Limitations

  • Only the most recent processed frame is available (no frame history)

  • Images returned by getLastProcessedImage() must be explicitly released to prevent memory leaks

  • Only processed frames are available, not raw camera data