bonus-material-app/nativeplugins/Mpaas-Scan/ios/TBDecodeSDK.framework/Headers/TBDecoder.h

150 lines
6.8 KiB
C
Raw Normal View History

2024-12-20 09:23:59 +08:00
//
// TBDecoder.h
// sdk_gen3_3g
//
// Created by Tom on 15/6/24.
// Copyright (c) 2015年 Taobao.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CoreVideo/CoreVideo.h>
#import <TBDecodeSDK/tbItf.h>
#import <TBDecodeSDK/TBDecodeResult.h>
typedef enum {
PreDetect_By_Normal = 0,
PreDetect_By_xNN = 1
} PreDetectTool;
typedef struct {
float codeProportion; ///< 疑似二维码的宽度所占比例,用于上层放大 zoom. value 0 代表没找到
CGPoint codeCenterInInterest;
CGPoint sweetPointForExposure;
PreDetectTool preDetectTool;
float codeRadius;
} PreDetectResult;
#define MAX_HOT_NUM 10
// 模糊检查
TBEXTERN_C NSString * const TBDecodeBlurNotification;
TBEXTERN_C NSString * const TBDecodeBlurNotificationInfoKey;
TBEXTERN_C NSString * const TBDecodeLogToFileNotification; ///< 算法层 log ,logToFile
TBEXTERN_C NSString * const TBDecodeLogToFileNotificationTagKey;
TBEXTERN_C NSString * const TBDecodeLogToFileNotificationLogKey;
TBEXTERN_C NSString * const TBDecodeTrackInfoNotification; // 解码信息埋点通知
TBEXTERN_C NSString * const TBDecodeTrackInfoNotificationSeedKey;
TBEXTERN_C NSString * const TBDecodeTrackInfoNotificationUcIdKey;
TBEXTERN_C NSString * const TBDecodeTrackInfoNotificationFlagKey; //FLAG_DEFAULT = 0, FLAG_NEED_LSB = 1
TBEXTERN_C NSString * const TBDecodeTrackInfoNotificationParamsKey;
@interface TBDecoder : NSObject
/**
* rect裁剪resample为YES时将剪裁后的图片缩放到360x360再解析@TBDecodeConfig
*
* @param buffer CVPixelBufferRef
* @param rect CGRectZero或CGRectNull时解析整张图片
* @param resample YES360x360NO使YES
* @param type ONED = ( EAN13 | EAN8 | UPCA | UPCE | CODE39 | CODE93 | CODE128 | ITF )
* @param PreDetectResult
*
* @return nil
*/
+ (NSArray<TBDecodeResult*> *)decodeCVPixelBuffer:(CVPixelBufferRef)buffer
rectOfInterest:(CGRect)rect
resample:(BOOL)resample
type:(int)type
cameraZoomFactor:(float)cameraZoomFactor
preDetectResult:(PreDetectResult*)preDetectResult;
/**
* rect裁剪resample为YES时将剪裁后的图片缩放到360x360再解析@TBDecodeConfig
*
* @param buffer CVPixelBufferRef
* @param rect CGRectZero或CGRectNull时解析整张图片
* @param resample YES360x360NO使YES
* @param type ONED = ( EAN13 | EAN8 | UPCA | UPCE | CODE39 | CODE93 | CODE128 | ITF )
* @param cameraZoomFactor 1
* @param codeProportion zoom.value 0
*
* @return nil
*/
+ (NSArray<TBDecodeResult*> *)decodeCVPixelBuffer:(CVPixelBufferRef)buffer
rectOfInterest:(CGRect)rect
resample:(BOOL)resample
type:(int)type
cameraZoomFactor:(float)cameraZoomFactor
codeProportion:(float*)codeProportion;
/**
Y通道图片数据
@param data Y通道图片数据
@param imgWidth
@param imgHeight
@param rect CGRectZero或CGRectNull时解析整张图片
@param resample YES360x360NO使YES
@param type ONED = ( EAN13 | EAN8 | UPCA | UPCE | CODE39 | CODE93 | CODE128 | ITF )
@param codeProportion zoom.value 0
@return nil
*/
+ (NSArray<TBDecodeResult*> *)decodeBufferData:(NSData *)data
imageWidth:(CGFloat)imgWidth
imageHeight:(CGFloat)imgHeight
rectOfInterest:(CGRect)rect
resample:(BOOL)resample
type:(int)type
codeProportion:(float*)codeProportion;
/**
* GEN3码
*
* @param image UIImage
*
* @return nil
*/
+ (TBDecodeResult *)decodeUIImage:(UIImage *)image;
/**
* GEN3码
*
* @param image UIImage
*
* @return nil
*/
+ (NSArray<TBDecodeResult*> *)overallDecodeUIImage:(UIImage *)image;
///
/// ⚠️⚠️ 由于不支持并发,以下方法都上了锁,等待其他解码器其他方法执行完再执行,所以以下不建议在主线程调用!!!!!!
///
// 算法配置。没有/nil 则默认算法,扫码初始化时调用
+ (void)startCameraWithConfig:(NSDictionary*)config;
///在 startCamera 之后设置,可以设置过滤规则及延迟策略
+ (void)setFilterConfig:(NSString *)filterConfig;
///< 支持动态调整二值化次序,
///< 每一帧用一种二值化:[ [0], [1], [2], [3], [4] ]
///< 或者每一帧用多种二值化: [ [0,1], [2,3], [3,4] ]
+ (void)setBinarizerOrder:(NSArray *)binarizerOrder;
///< 成功返回 1、失败返回 0
+ (int)registCodeDSL:(NSString *)codeDSL IsAlbum:(BOOL)isAlbum;
+ (int)unregistCodeDSLIsAlbum:(BOOL)isAlbum;
// 获取算法解码过程信息,避免性能问题,建议不要频繁调用
+ (NSDictionary *)getDecodeInfo;
// 内存紧张,需要降级
+ (void)downGradeSdkMemoryAllocate;
// 扫码结束时调用,回异步调用清除数据
+ (void)endCamera;
@end