<|start_filename|>IdcardQuality.framework/Headers/IdcardQualityAdaptor.h<|end_filename|>
//
//  IdcardQualityAdaptor.h
//  IdcardQuality
//
//  Created by Yan,Xiangda on 2017/4/17.
//  Copyright © 2017年 Baidu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#include "idcard_quality.h"

typedef NS_ENUM(NSInteger, IdcardQualityImageStatus) {
    
    IdcardQualityImageStatusNormal = 0,
    IdcardQualityImageStatusWrongLocation,
    IdcardQualityImageStatusBlurred,
    IdcardQualityImageStatusOverExposure,
    IdcardQualityImageStatusReversedSide
};

@interface IdcardQualityModel : NSObject

@property (assign ,nonatomic) idcard_quality::ImageStatusType image_status;
@property (assign ,nonatomic) idcard_quality::IdCardQualityErrorType errorType;
@property (assign ,nonatomic) bool has_warpped_image;
@property (assign ,nonatomic) unsigned char *warpped_image_data;
@property (assign ,nonatomic) int warped_image_width;
@property (assign ,nonatomic) int warped_image_height;
@property (assign ,nonatomic) int warped_image_channel;


@end

@interface IdcardQualityAdaptor : NSObject

- (void)initWithAPIKey:(NSString *)apiKey andLocalLicenceFile:(NSString *)localLicencePath;

- (BOOL)initWithToken:(NSString *)token;

- (BOOL)canWork;

- (IdcardQualityModel *)process:(UIImage *)image width:(int)width height:(int)height channel:(int)channel cardType:(idcard_quality::IdCardType)type;

//QA 测试接口
- (IdcardQualityModel *)processIsMoving:(UIImage *)image width:(int)width height:(int)height channel:(int)channel cardType:(idcard_quality::IdCardType)type;

- (IdcardQualityModel *)processWithoutIsMoving:(UIImage *)image width:(int)width height:(int)height channel:(int)channel cardType:(idcard_quality::IdCardType)type;

- (void)releaseIdcardQuality;

@end


<|start_filename|>leastOCR/AipOcrSdk/AipOcrService.h<|end_filename|>
//
// Created by chenxiaoyu on 17/2/21.
// Copyright (c) 2017 baidu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


@interface AipOcrService : NSObject


/**
 * 使用授权文件授权(推荐)
 * @param licenseFileContent 授权文件内容
 */
- (void) authWithLicenseFileData: (NSData *)licenseFileContent;


/**
 * 使用Api Key, Secret Key授权
 */
- (void) authWithAK: (NSString *)ak andSK: (NSString *)sk;

/**
 * 获取身份证检测Token
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */

- (void )getTokenSuccessHandler:(void (^)(NSString *token))successHandler
                    failHandler:(void (^)(NSError *error))failHandler;


/**
 * 通用文字识别（含位置信息）
 * @param image 需要识别的图片
 * @param options direction, language ... 详见开发者文档
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void) detectTextFromImage: (UIImage*)image
                 withOptions: (NSDictionary *)options
              successHandler: (void (^)(id result))successHandler
                 failHandler: (void (^)(NSError* err))failHandler;


/**
 * 通用文字识别(不含位置信息版)
 * @param image 需要识别的图片
 * @param options direction, language ... 详见开发者文档
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void) detectTextBasicFromImage: (UIImage*)image
                      withOptions: (NSDictionary *)options
                   successHandler: (void (^)(id result))successHandler
                      failHandler: (void (^)(NSError* err))failHandler;

/**
 * 通用文字识别（含生僻字版）
 * @param image 需要识别的图片
 * @param options direction, language ... 详见开发者文档
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void) detectTextEnhancedFromImage: (UIImage*)image
                         withOptions: (NSDictionary *)options
                      successHandler: (void (^)(id result))successHandler
                         failHandler: (void (^)(NSError* err))failHandler;



/**
 * 通用文字识别，高精度，带位置信息
 * @param image 图像
 * @param options 可选参数
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void) detectTextAccurateFromImage: (UIImage*)image
                         withOptions: (NSDictionary *)options
                      successHandler: (void (^)(id result))successHandler
                         failHandler: (void (^)(NSError* err))failHandler;


/**
 * 通用文字识别，高精度，不带位置信息
 * @param image 图像
 * @param options 可选参数
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void)detectTextAccurateBasicFromImage:(UIImage *)image
                             withOptions:(NSDictionary *)options
                          successHandler:(void (^)(id result))successHandler
                             failHandler:(void (^)(NSError *err))failHandler;

- (void) detectIdCardFromImage: (UIImage*)image
                   withOptions: (NSDictionary *)options
                successHandler: (void (^)(id result))successHandler
                   failHandler: (void (^)(NSError* err))failHandler;

/**
 * 身份证正面识别
 * @param image 需要识别的图片
 * @param options 参数，详见开发者文档
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void)detectIdCardFrontFromImage:(UIImage *)image
                       withOptions:(NSDictionary *)options
                    successHandler:(void (^)(id result))successHandler
                       failHandler:(void (^)(NSError *err))failHandler;

/**
 * 身份证背面识别
 * @param image 需要识别的图片
 * @param options 参数，详见开发者文档
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void)detectIdCardBackFromImage:(UIImage *)image
                      withOptions:(NSDictionary *)options
                   successHandler:(void (^)(id result))successHandler
                      failHandler:(void (^)(NSError *err))failHandler;

/**
 * 银行卡识别
 * @param image 需要识别的图片
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void) detectBankCardFromImage: (UIImage*)image
                  successHandler: (void (^)(id result))successHandler
                     failHandler: (void (^)(NSError* err))failHandler;


/**
 * 网图识别
 * @param image 需要识别的图片
 * @param options 额外参数
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void)detectWebImageFromImage:(UIImage *)image
                    withOptions:(NSDictionary *)options
                 successHandler:(void (^)(id result))successHandler
                    failHandler:(void (^)(NSError *err))failHandler;

/**
 * 驾驶证识别
 * @param image 需要识别的图片
 * @param options 额外参数
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void) detectDrivingLicenseFromImage: (UIImage *)image
                           withOptions: (NSDictionary *)options
                        successHandler: (void (^)(id result))successHandler
                           failHandler: (void (^)(NSError* err))failHandler;

/**
 * 行驶证证识别
 * @param image 需要识别的图片
 * @param options 额外参数
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void) detectVehicleLicenseFromImage: (UIImage *)image
                           withOptions: (NSDictionary *)options
                        successHandler: (void (^)(id result))successHandler
                           failHandler: (void (^)(NSError* err))failHandler;

/**
 * 车牌证识别
 * @param image 需要识别的图片
 * @param options 额外参数
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void)detectPlateNumberFromImage:(UIImage *)image
                       withOptions:(NSDictionary *)options
                    successHandler:(void (^)(id result))successHandler
                       failHandler: (void (^)(NSError* err))failHandler;



/**
 * 营业执照识别
 * @param image 图像
 * @param options 可选参数
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void) detectBusinessLicenseFromImage: (UIImage *)image
                            withOptions: (NSDictionary *)options
                         successHandler: (void (^)(id result))successHandler
                            failHandler: (void (^)(NSError* err))failHandler;


/**
 * 票据识别
 * @param image 图像
 * @param options 可选参数
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void) detectReceiptFromImage: (UIImage *)image
                    withOptions: (NSDictionary *)options
                 successHandler: (void (^)(id result))successHandler
                    failHandler: (void (^)(NSError* err))failHandler;


/**
 * 清空验证缓存
 * 出现验证过期等特殊情况调用
 */
- (void) clearCache;

+ (NSError *)aipErrorWithCode:(NSInteger)code andMessage:(NSString *)message;

+ (instancetype)shardService;

@end


<|start_filename|>IdcardQuality.framework/Headers/idcard_quality.h<|end_filename|>
/**
 * idcard_quality.h
 *
 * Author: wangjianfeng01(<EMAIL>)
 * Created on: 2017-04-11
 *
 * Copyright (c) Baidu.com, Inc. All Rights Reserved
 *
 */

#pragma once

#include <stdlib.h>
#include <vector>

#ifdef ANDROID
#include <android/asset_manager.h>

#define	BDIDL_DECL(func, ...)	func(AAssetManager *aassetmanager, __VA_ARGS__)
#define	BDIDL_CALL(func, ...)	func(aassetmanager, __VA_ARGS__)
#else /* !ANDROID */
#define	BDIDL_DECL(func, ...)	func(__VA_ARGS__)
#define	BDIDL_CALL(func, ...)	func(__VA_ARGS__)
#endif /* ANDROID */

namespace idcard_quality {

enum IdCardQualityErrorType {
    IDCQ_NO_ERROR = 0,
    IDCQ_NO_AUTHORITY = -1,
    IDCQ_PATH_ERROR = -2, /* path is null or does not exist */
    IDCQ_FILE_ERROR = -3, /* reading file error */
    IDCQ_MODEL_INIT_ERROR = -4,
    IDCQ_MODEL_RUNTIME_ERROR = -5,
    IDCQ_IMAGE_ERROR = -6,
    IDCQ_MEMORY_ERROR = -7,
    IDCQ_NOT_IMPLEMENTED_ERROR = -8,
    IDCQ_UNKNOWN_ERROR = -10
};

/*
 * IDCARD_INCOMPLETE: incomplete idcard
 * IDCARD_TOO_SMALL: idcard for small proportion in pic
 *                   or rotated idcard
 * IDCARD_WRONG_LOCATION: way too small, way too large,
 *                        rotated or not an idcard
 */
enum ImageStatusType {
    IDCARD_NORMAL = 0,
    IDCARD_WRONG_LOCATION = 1, // non_idcard, way_too_small, way_too_large
    IDCARD_BLURRED = 2,
    IDCARD_OVER_EXPOSURE = 3,
    IDCARD_REVERSED_SIDE = 4,
    IDCARD_MOVING  = 5,
    IDCARD_TOO_SMALL  = 6,
    IDCARD_INCOMPLETE = 7
};

enum IdCardType {
    IDCARD_FRONT_SIDE = 1,
    IDCARD_BACK_SIDE = 2
};

struct IdCardQualityResult {
    ImageStatusType image_status;
    bool has_warped_image;
    unsigned char* warped_image_data;
    int warped_image_width;
    int warped_image_height;
    int warped_image_channel;

    std::vector<unsigned char*> cropped_image_data;
    std::vector<int> cropped_image_width;
    std::vector<int> cropped_image_height;
    std::vector<int> cropped_image_channel;

    IdCardQualityResult() : image_status(IDCARD_WRONG_LOCATION),
            has_warped_image(false), warped_image_data(NULL),
            warped_image_width(0), warped_image_height(0), warped_image_channel(0) {
    }
    ~IdCardQualityResult() {
        if (warped_image_data != NULL) {
            free(warped_image_data);
            warped_image_data = NULL;
        }
        for (size_t i = 0; i < cropped_image_data.size(); i++) {
            if (cropped_image_data[i] != NULL) {
                free(cropped_image_data[i]);
                cropped_image_data[i] = NULL;
            }
        }
    }
};

} // namespace idcard_quality


<|start_filename|>IdcardQuality.framework/Headers/IdcardQuality.h<|end_filename|>
//
//  IdcardQuality.h
//  IdcardQuality
//
//  Created by Yan,Xiangda on 2017/4/17.
//  Copyright © 2017年 Baidu. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for IdcardQuality.
FOUNDATION_EXPORT double IdcardQualityVersionNumber;

//! Project version string for IdcardQuality.
FOUNDATION_EXPORT const unsigned char IdcardQualityVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <IdcardQuality/PublicHeader.h>

#import <IdcardQuality/IdcardQualityAdaptor.h>
#import <IdcardQuality/idcard_quality.h>


<|start_filename|>AipBase.framework/Headers/AipTokenManager.h<|end_filename|>
//
// Created by chenxiaoyu on 17/8/29.
// Copyright (c) 2017 baidu. All rights reserved.
//
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


@interface AipTokenManager : NSObject

- (instancetype) init __attribute__((unavailable(
"Use 'initWithLicenseFileData' or 'initWithAK:andSK' instead")));

- (instancetype) initWithLicenseFileData: (NSData *)licenseFileContent;

- (instancetype) initWithAK: (NSString *)ak andSK: (NSString *)sk;

//- (instancetype) initWithToken: (NSString *)token;

/**
 * 获取身份证前端检测Token
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void)getIdcardTokenWithSuccessHandler:(void (^)(NSString *token))successHandler
                             failHandler:(void (^)(NSError *error))failHandler;


/**
 * 获取Token。回调可能在mainQueue或其他子线程中
 * @param successHandler 成功回调
 * @param failHandler 失败回调
 */
- (void)getTokenWithSuccessHandler:(void (^)(NSString *token))successHandler
                       failHandler:(void (^)(NSError *error))failHandler;

/**
 * 清空cache
 */
- (void) clearCache;

/**
 * 设置验证服务器地址前缀，包含protocol
 * 如 https://verify.baidubce.com:80
 * 若设置为http，需设置NSAppTransportSecurity
 */
- (void)setAuthHost:(NSString *)host;

@end
