SmartScanner

@interface SmartScanner : NSObject

This class contains the main access to the smartscanner library.

Provides all the functions needed to manipulate the camera stream, and the decoding functions/options

Initialization

  • Basic constructor

    allows to init the SmartScanner. When the scanner is initialized with this function you’ll need to use the setDecodingType: function.

    Declaration

    Objective-C

    - (nonnull id)init;

    Return Value

    SmartScanner instance

Create the video stream view

  • Retrieve a view containing the camera stream of the given size

    Allows to retrieve an UIView containing the camera stream, and starts the decoding.

    The video stream will always be automatically managed to keep it’s ratio (It’s in ‘AspectFill’ in the preview view)

    Declaration

    Objective-C

    - (nonnull UIView *)previewViewWithViewSize:(CGRect)aRect;

    Parameters

    aRect

    Desirated size for the camera view.

    Return Value

    UIView that can be manipulated and added to any other view. The Returned view is ownded by the scanner, and will be released when the scanner is killed

  • Retrieve a view containing the camera stream of the given size

    Allows to retrieve an UIView containing the camera stream, and starts the decoding. It allows to use a custom video stream quality.

    Warning

    Using an above Normal stream quality should only be necessary in rare conditions, and might slow down the decoding.

    Declaration

    Objective-C

    - (nonnull UIView *)previewViewWithViewSize:(CGRect)aRect
                      andAVCaptureSeesionPreset:(SmartScannerQuality)aPreset;

    Parameters

    aRect

    Desirated size for the camera view.

    aPreset

    any SmartScannerQuality preset. normal quality is the default one

    Return Value

    UIView that can be manipulated and added to any other view

Destruction

  • Close the smartscanner object and video stream relative objects Should be used when you don’t need to use the smartscanner anymore

    Declaration

    Objective-C

    - (void)closeCameraStream;

Utility functions

  • Retrieve a string corresponding to the code type

    Retrieve a string description of a SmartDecodingType. It can be usefull in the case where you are decoding multiple types and want more details about the which type has actually been decoded.

    Declaration

    Objective-C

    - (nonnull NSString *)getResultTypeName:(uint64_t)aCodeType
                                 andSubType:(uint64_t)aSubType;

    Parameters

    aCodeType

    type of code

    aSubType

    subtype of code

    Return Value

    NSString

  • Use the flash light as a torche

    Allows to turn ON/OFF the flash light to help decoding in case of bad lighting

    Declaration

    Objective-C

    - (void)setFlashEnabled:(_Bool)aValue;

    Parameters

    aValue

    the dedirated state of the light

  • Use the flash light as a torche

    Allows to turn ON/OFF with a specified flash level the flash light to help decoding in case of bad lighting

    Declaration

    Objective-C

    - (void)setFlashLevel:(float)aValue;

    Parameters

    aValue

    the desirated intensity. from 0.0 to 1.0 (0.0 will shut it down)

  • Set the zoom factor of the camera

    allow to set the zoom factor. The zoom factor is related to the current one.

    Declaration

    Objective-C

    - (void)setNewZoomFactor:(CGFloat)aZoomFactor;

    Parameters

    aZoomFactor

    new zoom factore

  • Retrieve an UIImage of the current stream

    This is an async function that will order the decoder to capture an image of the current stream. It will be returned in the -(void)SmartScanner:(SmartScanner*)smartScan didFinishTakingAPicuture:(UIImage*)aPicture;

    Declaration

    Objective-C

    - (void)captureImage;
  • Use the iPhone stabilisation mode.

    Allows to enable the stabilization mode of the iOS video capture connection.

    Declaration

    Objective-C

    - (_Bool)setStabilisationEnabled:(_Bool)aEnable;

    Parameters

    aEnable

    set the feature ON or OFF

    Return Value

    return the next state. Might return always false on device that don’t support it.

Decoder Configuration

  • Delegate that will be called when a scan or error has to be reported

    Declaration

    Objective-C

    @property (nonatomic) id<SmartScannerDelegate> _Nonnull scDelegate;
  • Set the zone of interest to scan

    Allows to set which zone in the video stream (640 X 480 by default, but depending on the steam quality you choosed) will be scanned.

    This function can be replaced by the more -programmer firendly- one : -(CGRect)setRegionOfInterestInPreviewViewCoordinates:(CGRect)aTargetRec;

    This function needs to be called after setting the types of code

    Declaration

    Objective-C

    - (CGRect)setRegionOfInterest:(CGRect)aTargetRec;

    Parameters

    aTargetRec

    A rectangle that must be within the video stream

    Return Value

    the zone of interest relative to the previewView

  • Conveniance function to set the Region of intereset relative to the preview view, instead of the stream (remplacement for setRegionOfInterest:…

    Declaration

    Objective-C

    - (CGRect)setRegionOfInterestInPreviewViewCoordinates:(CGRect)aTargetRec;

    Parameters

    aTargetRec

    Rect in the preview view

    Return Value

    return the rect passed in params, with potential little adjustement to be exact

  • Set the decoding orientation

    When using any type of OCR decoding, the default orientation will be landscape right (with home button on the right) If you want to use any other orientation while decoding, you should specify the orientation you want with this function

    Declaration

    Objective-C

    - (void)setDecodingOrientation:(UIInterfaceOrientation)aOrientation;

    Parameters

    aOrientation

    UIDeviceOrientation you want to use for ocr decoding

  • Enable decoding

    allows to enable/disable the decoding without closing the video stream

    Declaration

    Objective-C

    - (void)enableDecoding:(_Bool)aEnable;

    Parameters

    aEnable

    bool representing the desirated decoding state

  • Allow to set the behavior when a code is found. This property must be set everytime after a new initialisation of smartScan

    Declaration

    Objective-C

    - (void)setSmartScannerResultBehavior:(SmartScannerResultBehavior)behavior;

    Parameters

    behavior

    SmartScannerResultBehavior enum

  • While using a behavior that is different from SmartScannerResultBehaviorContinuous. It is possible to ask the decoder to force the decoder to have multiple same results before returning it. This could help with some code_type that don’t have checksums The default value, is 3.

    Declaration

    Objective-C

    - (void)enableMultipleResultsConfirmation:(NSUInteger)value;

    Parameters

    value

    a Value >0 et < 10 that represent the number of needed match to have a positive

  • Will Try to change the framerate of the camera (if supported) default is the OS default (30FPS while writing this lines) Advised value is 60. Not sure what device can support higher ones.

    Declaration

    Objective-C

    - (_Bool)setCameraFramerate:(NSUInteger)aNewFramerate;

    Parameters

    aNewFramerate

    The new framerate

    Return Value

    return if the OS accesspted the change

  • Allows to select the type of code you want to scan. Must be called after the view has been set as shown in IcareDecodersCodes.h file

    Refers to CodeTypes.h

    This function reset the Region of interest (ROI) to it’s default value for the select type of code.

    Multiple codes can be activated at the same time using ‘|’

    But any type you will add that you don’t need will add an additional computation time in the decoding procedure

    Declaration

    Objective-C

    - (CGRect)setDecodingType:(uint64_t)aDecodeType
                   andSubType:(uint64_t)aDecodeSubType;

    Parameters

    aDecodeType

    Type of code

  • Set the focus point of the camera

    Allows to manually set the focus zone of the camera

    Declaration

    Objective-C

    - (void)continuousFocusAtPoint:(CGPoint)aPoint;

    Parameters

    aPoint

    CGpoint (Can be the direct output of the default iOS touch events) representing where in the stream the camera should do the autofocus

  • Set the frame that should be process.

    Might be usefull to lower battery consumption. By default the scanner will decode every frame (by default 30 frame per seconde). This setting allows to skip some frames.

    For example you can use aFrameToProcess = 1 & aFrameToSkip = 1 to read half the frames

    Declaration

    Objective-C

    - (void)setFramesToProcess:(int)aFrameToProcess frameToSkip:(int)aFrameToSkip;

    Parameters

    aFrameToProcess

    The number of frames to read

    aFrameToSkip

    The number of frames to skip after the

Test / Helpers

  • Can be used to test your implementation or when you running smartscan on the simulator

    Allows to ask smartidscan to return a specific value in 1 sec.

    Declaration

    Objective-C

    - (void)smartScanShouldReturnResultCode:(nonnull NSString *)aCode
                                   withType:(uint64_t)aType
                                 andSubType:(uint64_t)aSubType;

    Parameters

    aCode

    The string that will be returned

    aType

    The type that will be returned

Informations

  • Retrieve the smartscanner and decoding type versions

    Declaration

    Objective-C

    - (nonnull NSString *)sdkDescription;
  • return the framwork version

    Declaration

    Objective-C

    - (nonnull NSString *)version;
  • return the expiration date of the scanner (if you have an expiration date in your contract)

    Declaration

    Objective-C

    - (nonnull NSString *)getExpirationDate;
  • Zone of interest (zone where the smartscanner will try to find a code) relative to the previewView

    Declaration

    Objective-C

    - (CGRect)regionOfInterest;
  • Declaration

    Objective-C

    - (CGSize)currentStreamSize;

    Return Value

    the current selected stream size. Might be usefull to calculte the ROI (region of interest) you want to use

  • Allow to enable some statistics, that will be sent into the apropriate delegate

    Declaration

    Objective-C

    - (void)setStatsEnabled:(_Bool)aEnabled;

    Parameters

    aEnabled

    enabld or not

  • Allows to start the decoding on a stack UIImage. The decoding will be done on the full image. So you’re advised to provide your user a way to crop the image. The result will be send in the usual delegate

    Warning

    This is a beta feature, might not work as advertised. If you need it and you notice some issues, tell us !

    Declaration

    Objective-C

    - (void)decodeStillImage:(nonnull UIImage *)aImage;

    Parameters

    aImage

    aImage