Skip to main content

BRCameraViewController

Base camera controller class. Subclass to build your own UI on top of the fullscreen camera view.

Declaration

@interface BRCameraViewController : UIViewController
class BRCameraViewController : UIViewController

Quick Reference

Properties

PropertyDescription
scanningRegionSet this property to scan only a certain region of the returned image.
isTorchOnIndicates whether the torch is currently active.
isPausedIndicates whether scanning is paused.
isEdgeDetectionRunningIndicates whether edge detection is running.
manualCaptureSessionSet to YES to prevent the parent from starting/stopping the AVCaptureSession.
blinkReceiptIdUnique identifier for the current receipt scan session.

Methods

MethodDescription
userSnappedPhotoOnReady:Notifies the camera controller the user attempted to snap a picture.
userFinishedScanNotifies the controller that scanning is complete.
getPreliminaryResults:Invokes the same processing pipeline as end-of-scan.
userCancelledScanNotifies the controller the user cancelled scanning.
userConfirmedFrame:Marks a frame as user-confirmed for remote saving and local storage.
setTorch:Toggles the torch on or off.
pauseScanningPauses frame capture and scanning.
resumeScanningResumes frame capture and scanning after a pause.
confirmCorrectRetailer:After wrong-retailer detection, call this with the corrected retailer ID.

Overridable Methods

MethodDescription
userDistanceChanged:Called when the user's distance from the receipt changes.
didGetFrameStats:Called per frame with statistics including content width and edges.
didDetectWrongRetailer:withConfidence:Called when the SDK detects the scanned receipt belongs to a different retailer.
didGetFrameResults:Called per frame with cumulative metadata results as they are parsed.
receiptValidityEstimate:Called per frame with a running estimate of receipt validity.
didGetLightingCondition:Called with lighting condition updates when manual torch control is enabled.
didGetHorizontalEdges:andBottomEdge:Called when horizontal edges are detected on the current frame.

Properties

scanningRegion

@property (nonatomic) CGRect scanningRegion;
var scanningRegion: CGRect { get set }

Set this property of your subclass to scan only a certain region of the returned image from the camera. Parameters are specified as percentages of the view size.

Default: (0.0, 0.0, 1.0, 1.0) (full frame)


isTorchOn (read-only)

@property (nonatomic, readonly) BOOL isTorchOn;
var isTorchOn: Bool { get }

Indicates whether the torch is currently active.


isPaused (read-only)

@property (nonatomic, readonly) BOOL isPaused;
var isPaused: Bool { get }

Indicates whether scanning is paused.


isEdgeDetectionRunning (read-only)

@property (nonatomic, readonly) BOOL isEdgeDetectionRunning;
var isEdgeDetectionRunning: Bool { get }

Indicates whether edge detection is running.


manualCaptureSession

@property (nonatomic) BOOL manualCaptureSession;
var manualCaptureSession: Bool { get set }

Set to YES to prevent the parent view controller from starting and stopping the AVCaptureSession. Use this when you manage the capture session lifecycle yourself.

Default: NO


blinkReceiptId (read-only)

@property (nonatomic, strong, readonly) NSString *blinkReceiptId;
var blinkReceiptId: String! { get }

Unique identifier for the current receipt scan session.


Methods

userSnappedPhotoOnReady:

- (void)userSnappedPhotoOnReady:(void (^)(UIImage *, BRFrameAttributes *))readyBlock;
func userSnappedPhoto(onReady readyBlock: ((UIImage?, BRFrameAttributes?) -> Void)!)

Notifies the camera controller the user attempted to snap a picture. The ready block is invoked once a suitable frame is obtained.


userFinishedScan

- (void)userFinishedScan;
func userFinishedScan()

Notifies the controller that scanning is complete. Triggers cleanup and fires the delegate callback with final results.


getPreliminaryResults:

- (void)getPreliminaryResults:(BOOL (^)(BRScanResults *))callback;
func getPreliminaryResults(_ callback: ((BRScanResults?) -> Bool)!)

Invokes the same processing pipeline as end-of-scan. The callback returns YES if the results are satisfactory, NO to continue scanning.


userCancelledScan

- (void)userCancelledScan;
func userCancelledScan()

Notifies the controller the user cancelled scanning. Performs cleanup and fires the cancelled delegate callback.


userConfirmedFrame:

- (void)userConfirmedFrame:(UIImage *)frameImg;
func userConfirmedFrame(_ frameImg: UIImage!)

Marks a frame as user-confirmed for remote saving and local storage per the active BRScanOptions.


setTorch:

- (void)setTorch:(BOOL)torchOn;
func setTorch(_ torchOn: Bool)

Toggles the torch on or off.


pauseScanning

- (void)pauseScanning;
func pauseScanning()

Pauses frame capture and scanning. Frames already in the processing pipeline are still handled.


resumeScanning

- (void)resumeScanning;
func resumeScanning()

Resumes frame capture and scanning after a pause.


confirmCorrectRetailer:

- (void)confirmCorrectRetailer:(WFRetailerId)retailerId;
func confirmCorrectRetailer(_ retailerId: WFRetailerId)

After wrong-retailer detection, call this with the corrected retailer ID to allow scanning to continue.


Overridable Methods

Override these in your subclass to receive scan-time callbacks.

userDistanceChanged:

- (void)userDistanceChanged:(BRDistanceStatus)newStatus;
func userDistanceChanged(_ newStatus: BRDistanceStatus)

Called when the user's distance from the receipt changes (too far vs. acceptable).


didGetFrameStats:

- (void)didGetFrameStats:(NSDictionary *)frameStats;
func didGetFrameStats(_ frameStats: [AnyHashable : Any]!)

Called per frame with statistics including content width, edges rect, and receipt detection.


didDetectWrongRetailer:withConfidence:

- (void)didDetectWrongRetailer:(WFRetailerId)correctRetailer withConfidence:(BRWrongRetailerConfidence)confidence;
func didDetectWrongRetailer(_ correctRetailer: WFRetailerId, with confidence: BRWrongRetailerConfidence)

Called when the SDK detects the scanned receipt belongs to a different retailer than specified.


didGetFrameResults:

- (void)didGetFrameResults:(BRScanResults *)frameResults;
func didGetFrameResults(_ frameResults: BRScanResults!)

Called per frame with cumulative metadata results as they are parsed.


receiptValidityEstimate:

- (void)receiptValidityEstimate:(BOOL)validReceipt;
func receiptValidityEstimate(_ validReceipt: Bool)

Called per frame with a running estimate of whether the frame appears to be a valid receipt.


didGetLightingCondition:

- (void)didGetLightingCondition:(BRLightingCondition)lightingCondition;
func didGet(_ lightingCondition: BRLightingCondition)

Called with lighting condition updates when manual torch control is enabled.


didGetHorizontalEdges:andBottomEdge:

- (void)didGetHorizontalEdges:(BOOL)topEdge andBottomEdge:(BOOL)bottomEdge;
func didGetHorizontalEdges(_ topEdge: Bool, andBottomEdge bottomEdge: Bool)

Called when horizontal edges are detected on the current frame.