管理中心

HmsBitMap

扫码工具类,提供BitMap Mode扫码方式。

Declaration

@interface HmsBitMap : NSObject

初始化方法:

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

bitMapForImage: withOptions:

获取图片image,传入算法获取单码解码结果。请参见图片扫码。

Declaration

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

调用示例:

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

bitMapForSampleBuffer: withOptions:

获取图片帧sampleBuffer,传入算法获取单码解码结果。请参见图片扫码。

Declaration

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

调用示例:

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

multiDecodeBitMapForImage: withOptions:

获取图片image,传入算法获取多码解码结果数组。请参见相机扫码。

Declaration

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

调用示例:

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

multiDecodeBitMapForSampleBuffer: withOptions:

获取图片帧sampleBuffer,传入算法获取多码解码结果数组。请参见相机扫码。

Declaration

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

调用示例:

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

图片扫码

获取图片image,传入算法获取单码解码结果。

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

获取图片image,传入算法获取多码解码结果数组。

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

相机扫码

  1. 使用iOS系统框架中AVCaptureSession实现相机功能:
    AVCaptureSession
  2. 实现相机功能后,在调用的代理方法中获得相机帧图像采样数据:
    -(void)captureOutput:(AVCaptureOutput *)output didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
  3. 获取图片帧sampleBuffer,传入算法获取单码解码结果:
    NSDictionary *dic = [HmsBitMap bitMapForSampleBuffer:sampleBuffer withOptions:[[HmsScanOptions alloc] initWithScanFormatType:ALL]];
  4. 获取图片帧sampleBuffer,传入算法获取多码解码结果数组:
    NSArray *list = [HmsBitMap multiDecodeBitMapForSampleBuffer:sampleBuffer withOptions:[[HmsScanOptions alloc] initWithScanFormatType:ALL]];
Parameters
展开

Name

Description

image

图片扫码下待解码的图片,为保证解码效果最佳,建议图片分辨率为960px*540px ~ 1920px*1080px,图片大小不要超过50M。

sampleBuffer

相机扫码下待解码的视频帧。

[[HmsScanOptions alloc] initWithScanFormatType:All]

指定的扫码格式。

Returns

展开

Type

Description

NSDictionary(单码)

扫码方式中扫码结果的回调NSDictionary数据,包含以下内容:

  • zoomValue:相机镜头放大系数。
  • text:码返回值。
  • exposureAdjustmentValue:曝光系数。
  • formatValue:码制式。
  • ResultPoint:码图角点坐标位置。
  • sceneType:场景类型。
  • parserDic:对应场景返回的值。其中包含有:
    • Contact(联系人信息)
    • Email(邮箱)
    • WebSite(URL链接)
    • ISBN
    • Location(地理位置信息)
    • SMS(SMS短信信息)
    • Tel(电话)
    • EVENT(日历事件信息)
    • Wi-Fi(Wi-Fi信息)

NSArray(多码)

扫码方式中扫码结果的回调NSArray数据,数组内包含一个或多个NSDictionary,NSDictionary内数据与单码相同。

搜索
请输入您想要搜索的关键词