BRCameraViewController
Objective-C
@interface BRCameraViewController : UIViewController
Swift
class BRCameraViewController : UIViewController
Base camera controller class. Subclass to build your own UI on top of the fullscreen camera view
-
Set this property of your subclass in order to scan only a certain region of the returned image from the camera. The values of the
CGRect
are all given from 0.0 to 1.0, indicating a fraction of the current view’s dimensions. Default is (0.0, 0.0, 1.0, 1.0) which scans the whole screen. It is recommended to set the scanning region equal to the area of the screen that is not covered by other UI elements, so that the frames being scanned are consistent with what the user appears to be snapping photos ofDeclaration
Objective-C
@property (nonatomic) CGRect scanningRegion;
Swift
var scanningRegion: CGRect { get set }
-
Indicates whether the torch is on
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isTorchOn;
Swift
var isTorchOn: Bool { get }
-
Indicates whether scanning is paused
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isPaused;
Swift
var isPaused: Bool { get }
-
Indicates whether edge detection is running
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isEdgeDetectionRunning;
Swift
var isEdgeDetectionRunning: Bool { get }
-
Set this property to
YES
to prevent the parent view controller from starting and stopping theAVCaptureSession
based on view lifecycle events. You will be responsible for manually calling-[BRCameraViewController resumeScanning]
and-[BRCameraViewController pauseScanning]
to manage the capture sessionDeclaration
Objective-C
@property (nonatomic) BOOL manualCaptureSession;
Swift
var manualCaptureSession: Bool { get set }
-
Unique ID of the current receipt
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSString *blinkReceiptId;
Swift
var blinkReceiptId: String! { get }
-
Call this method to notify the camera controller that the user has attempted to snap a picture.
Declaration
Objective-C
- (void)userSnappedPhotoOnReady:(void (^)(UIImage *, BRFrameAttributes *))readyBlock;
Swift
func userSnappedPhoto(onReady readyBlock: ((UIImage?, BRFrameAttributes?) -> Void)!)
Parameters
readyBlock
This block will be invoked once the camera controller has obtained a suitable frame to display to the user as a preview. Be careful of retain cycles in this block!
UIImage *frameImg
- The frame to display as a previewBRFrameAttributes *frameAttributes
- Various attributes about the current frame (blurriness, screen detection, etc seeBRFrameAttributes
)
-
Call this method to notify the camera controller that the user has indicated they have finished scanning. This will perform some cleanup and then call
-[BRScanResultsDelegate didFinishScanning:withScanResults:]
on your scanning delegate. It is recommended that prior to or simultaneous with calling this method, you display some sort of loader until the callback is receivedDeclaration
Objective-C
- (void)userFinishedScan;
Swift
func userFinishedScan()
-
Call this method to invoke the same processing that happens at the end of the scan session.
Declaration
Objective-C
- (void)getPreliminaryResults:(BOOL (^)(BRScanResults *))callback;
Swift
func getPreliminaryResults(_ callback: ((BRScanResults?) -> Bool)!)
Parameters
callback
This callback is invoked as soon as it is possible to return preliminary results The client should return
YES
orNO
depending on whether the results are satisfactory to end the scanning sessionBRScanResults *scanResults
- The scan results up to this point
-
Call this method to notify the camera controller that the user has cancelled scanning. This will perform some cleanup and then call
-[BRScanResultsDelegate didCancelScanning:]
on your scanning delegateDeclaration
Objective-C
- (void)userCancelledScan;
Swift
func userCancelledScan()
-
Call this method to notify the camera controller that the user has confirmed a particular frame. This will mark the frame internally as a user frame which allows it to be saved remotely after the scan session, and also saved to disk if
BRScanOptions.storeUserFrames
is setDeclaration
Objective-C
- (void)userConfirmedFrame:(UIImage *)frameImg;
Swift
func userConfirmedFrame(_ frameImg: UIImage!)
Parameters
frameImg
The image the user has confirmed. Should be the same as the image passed to the
readyBlock
ofuserSnappedPhotoOnReady:
above -
Toggle the status of the torch
Declaration
Objective-C
- (void)setTorch:(BOOL)torchOn;
Swift
func setTorch(_ torchOn: Bool)
Parameters
torchOn
Whether to turn the torch on or off
-
Pause frame capture and scanning. Any frames that are already in the processing pipeline will continue to be scanned
Declaration
Objective-C
- (void)pauseScanning;
Swift
func pauseScanning()
-
Resume frame capture and scanning.
Declaration
Objective-C
- (void)resumeScanning;
Swift
func resumeScanning()
-
After receiving the
didDetectWrongRetailer:
callback, call this method to indicate that scanning should use the new retailer going forwardDeclaration
Objective-C
- (void)confirmCorrectRetailer:(WFRetailerId)retailerId;
Swift
func confirmCorrectRetailer(_ retailerId: WFRetailerId)
Parameters
retailerId
The new retailer to use
-
Override this method to be notified when a determination is made that the user’s scanning distance is either too far or is acceptable (OK)
Declaration
Objective-C
- (void)userDistanceChanged:(BRDistanceStatus)newStatus;
Swift
func userDistanceChanged(_ newStatus: BRDistanceStatus)
Parameters
newStatus
The newly detected distance status
-
Override this method to receive statistics on each frame that is processed
Declaration
Objective-C
- (void)didGetFrameStats:(NSDictionary *)frameStats;
Swift
func didGetFrameStats(_ frameStats: [AnyHashable : Any]!)
Parameters
frameStats
A dictionary with the following keys:
contentWidth
- a float indicating what percent (0-100) of the image the receipt appears inedgesRect
- aCGRect
wrapped inNSNumber
indicating the location of edges found in percentages of image sizeisReceipt
- aBOOL
wrapped inNSNumber
indicating whether the current frame is believed to contain a receipt -
Override this method to be notified when the SDK detects that the receipt being scanned is from a different retailer than was specified
Declaration
Objective-C
- (void)didDetectWrongRetailer:(WFRetailerId)correctRetailer withConfidence:(BRWrongRetailerConfidence)confidence;
Swift
func didDetectWrongRetailer(_ correctRetailer: WFRetailerId, with confidence: BRWrongRetailerConfidence)
Parameters
correctRetailer
The retailer the SDK believes the receipt to be from
confidence
Whether the new retailer is based only on a store phone match, or if we have also successfully parsed products using the new retailer
-
Override this method to receive frame by frame scan results (note: metadata only, does not include product results). Results are cumulative from all frames previously scanned.
Declaration
Objective-C
- (void)didGetFrameResults:(BRScanResults *)frameResults;
Swift
func didGetFrameResults(_ frameResults: BRScanResults!)
Parameters
frameResults
The scan results at this point in time
-
Override this method to receive frame by frame estimations about whether the user is scanning a valid receipt (estimation is cumulative based on all previous frames scanned to that point)
Declaration
Objective-C
- (void)receiptValidityEstimate:(BOOL)validReceipt;
Swift
func receiptValidityEstimate(_ validReceipt: Bool)
Parameters
validReceipt
Whether the SDK believes that it is scanning a valid receipt at this point
-
When
BRScanOptions.manualTorchControl
is enabled, this callback will indicate to the client VC if the SDK detects a new lighting condition. Note: Lighting is assumed to start inBRLightingConditionTerrible
, so there will never be a callback with that passed as a parameter, rather we only upgrade the lighting toBRLightingConditionLow
orBRLightingConditionGood
Declaration
Objective-C
- (void)didGetLightingCondition:(BRLightingCondition)lightingCondition;
Swift
func didGet(_ lightingCondition: BRLightingCondition)
Parameters
lightingCondition
The new lighting condition
-
Override this method to receive a callback when one or both horizontal edges is detected on the current frame. Note: This does not guarantee that this frame will be scanned. To determine if a top/bottom edge was seen on any of the scanned frames, consult
BRScanResults.foundTopEdge
andBRScanResults.foundBottomEdge
Declaration
Objective-C
- (void)didGetHorizontalEdges:(BOOL)topEdge andBottomEdge:(BOOL)bottomEdge;
Swift
func didGetHorizontalEdges(_ topEdge: Bool, andBottomEdge bottomEdge: Bool)
Parameters
topEdge
Whether a top edge was detected on this frame
bottomEdge
Whether a bottom edge was detected on this frame