目录

HmsBitMap

Barcode scanning utility class that supports barcode scanning in Bitmap mode.

Declaration

@interface HmsBitMap : NSObject

Initialization method.

HmsBitMap *bitMap = [[HmsBitMap alloc] init];

bitMapForImage: withOptions:

Obtains the decoding result for a single barcode based on the input image parameter and algorithm. For details, please refer to Image Mode.

Declaration

+(NSDictionary *)bitMapForImage:(UIImage *)image withOptions:(HmsScanOptions *)options

Example:

[bitMap bitMapForImage:(UIImage *)image withOptions:(HmsScanOptions *)options];

bitMapForSampleBuffer: withOptions:

Obtains the decoding result for a single barcode based on the input sampleBuffer parameter and algorithm. For details, please refer to Image Mode.

Declaration

+(NSDictionary *)bitMapForSampleBuffer:(CMSampleBufferRef)sampleBuffer withOptions:(HmsScanOptions *)options

Example:

[bitMap bitMapForSampleBuffer:(CMSampleBufferRef)sampleBuffer withOptions:(HmsScanOptions *)options];

multiDecodeBitMapForImage: withOptions:

Obtains the decoding result for multiple barcodes based on the input image parameter and algorithm. For details, please refer to Camera Mode.

Declaration

+ (NSArray *)multiDecodeBitMapForImage:(UIImage *)image withOptions:(HmsScanOptions *)options

Example:

[bitMap multiDecodeBitMapForImage:(UIImage *)image withOptions:(HmsScanOptions *)options];

multiDecodeBitMapForSampleBuffer: withOptions:

Obtains the decoding result for multiple barcodes based on the input sampleBuffer parameter and algorithm. For details, please refer to Camera Mode.

Declaration

+(NSArray *)multiDecodeBitMapForSampleBuffer:(CMSampleBufferRef)sampleBuffer withOptions:(HmsScanOptions *)options

Example:

[bitMap multiDecodeBitMapForSampleBuffer:(CMSampleBufferRef)sampleBuffer withOptions:(HmsScanOptions *)options];

Image Mode

Obtains the decoding result for a single barcode based on the input image parameter and algorithm.

NSDictionary *dic = [HmsBitMap bitMapForImage:image withOptions:[[HmsScanOptions alloc] initWithScanFormatType:ALL]];

Obtains the decoding result for multiple barcodes based on the input image parameter and algorithm.

NSArray *list = [HmsBitMap multiDecodeBitMapForImage:image withOptions:[[HmsScanOptions alloc] initWithScanFormatType:ALL]];

Camera Mode

  1. Use AVCaptureSession in the iOS framework to implement the camera mode.
    AVCaptureSession
  2. Obtain frame sample data through delegate methods in camera mode.
    -(void)captureOutput:(AVCaptureOutput *)output didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
  3. Obtain the decoding result for a single barcode based on the input sampleBuffer parameter and algorithm.
    NSDictionary *dic = [HmsBitMap bitMapForSampleBuffer:sampleBuffer withOptions:[[HmsScanOptions alloc] initWithScanFormatType:ALL]];
  4. Obtain the decoding result for multiple barcodes based on the input sampleBuffer parameter and algorithm.
    NSArray *list = [HmsBitMap multiDecodeBitMapForSampleBuffer:sampleBuffer withOptions:[[HmsScanOptions alloc] initWithScanFormatType:ALL]];
Parameters

Name

Description

image

Image to be decoded. For optimal effect, it is recommended that the image dimensions range from 960 x 540 px to 1920 x 1080 px, with a maximum file size of 50 MB.

sampleBuffer

Video frame to be decoded.

[[HmsScanOptions alloc] initWithScanFormatType:All]

Specified barcode format.

Returns

Type

Description

NSDictionary (single barcode)

NSDictionary class that contains scanning result data, including:

  • zoomValue: camera lens magnification ratio
  • text: barcode value
  • exposureAdjustmentValue: exposure coefficient
  • formatValue: barcode format.
  • ResultPoint: coordinates of barcode corners.
  • sceneType: scenario type
  • parserDic: data returned in the corresponding scenario, including:
    • Contact: contact information
    • Email: email address
    • WebSite: URL
    • ISBN
    • Location: location information
    • SMS: SMS information
    • Tel: phone number
    • EVENT: calendar event
    • Wi-Fi: Wi-Fi information

NSArray (multiple barcodes)

NSArray class that contains one or more NSDictionary classes. Under the multi-barcode scenario, the data in each NSDictionary class is the same as that in the NSDictionary class under the single barcode scenario.