百度智能(文本识别),API传图OC代码与SDK使用
百度智能中的文本识别中的身份证识别,有API方式和SDK方式
API方式

百度智能(文本识别),百度API传图没有提供OC的示例,这里提供一下
- (void)OCTest:(NSString*)token {
//***********post请求********************//
NSString *testURL =[NSString stringWithFormat:@"https://aip.baidubce.com/rest/2.0/ocr/v1/idcard?access_token=%@",token];
testURL = [testURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSURL *url = [NSURL URLWithString:testURL];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
//设置请求方法
request.HTTPMethod = @"POST";
//设置请求体
UIImage *testImage = [UIImage imageNamed:@"test.jpg"];
NSData *imageData = UIImagePNGRepresentation(testImage);
NSString *baseStr = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
NSString *urlEncode= (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
NULL,
(__bridge CFStringRef)baseStr,
NULL,
(CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",
CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)));
NSLog(@"urlEncode is %@",urlEncode);
NSString *str =[NSString stringWithFormat:@"image=%@&id_card_side=%@",urlEncode,@"front"];
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
request.HTTPBody = data;
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
//
if (error) {
NSLog(@"error is %@",error);
}else
{
NSLog(@"data is %@",data);
NSDictionary *dic= [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSLog(@"解析得出的dic is %@",dic);
}
}];
[dataTask resume];
}
如果UI没设计拍照UI,这里建议大家使用SDK,稳定性好,效率高。
SDK方式

真机运行报错的话,把lib中的模拟器都移掉。
真机运行报错、Archive/IPA/Upload AppStore 时报错"Unsupported Architecture. Your executable contains unsupported architecture '[x86_64, i386]..."
为了方便开发者调试,AipBase.framework合并了模拟器和真机架构,上线前,使用lipo工具移除相关架构即可,参考:
cd lib
# 使用lipo -info 可以查看包含的架构
lipo -info AipBase.framework/AipBase # Architectures in the fat file: AipBase are: i386 x86_64 armv7 armv7s arm64
# 移除x86_64, i386
lipo -remove x86_64 AipBase.framework/AipBase -o AipBase.framework/AipBase
lipo -remove i386 AipBase.framework/AipBase -o AipBase.framework/AipBase
lipo -remove x86_64 AipOcrSdk.framework/AipOcrSdk -o AipOcrSdk.framework/AipOcrSdk
lipo -remove i386 AipOcrSdk.framework/AipOcrSdk -o AipOcrSdk.framework/AipOcrSdk
# 再次查看
lipo -info AipBase.framework/AipBase # Architectures in the fat file: AipBase are: armv7 armv7s arm64
如果想修改SDK的UI,可以使用AipOrcSdk中的源码,站在巨人的肩膀上编程,也很香!
百度智能(文本识别),API传图OC代码与SDK使用的更多相关文章
- 百度OCR文字识别API使用心得===com.baidu.ocr.sdk.exception.SDKError[283604]
异常com.baidu.ocr.sdk.exception.SDKError[283604]App identifier unmatch.错误的packname或bundleId.logId::303 ...
- 百度AI文本审核API使用说明
虽然,虽然,虽然,今天: 百度发布了2019年第一季度未经审计的财务报告.本季度百度营收241亿元人民币(约合35.9亿美元),同比增长15%,移除业务拆分收入影响,同比增长21%.低于市场预期242 ...
- 百度云人脸识别API人脸对比
from urllib import request import base64 import requests import re import json import urllib import ...
- 百度云人脸识别API人脸库管理
from urllib import request import base64 import requests import re import json import urllib impor ...
- wordpress百度熊掌号“搜索结果出图”改造代码
<?php if(is_single()||is_page()){ echo '<script type="application/ld+json">{ &quo ...
- 转《trackingjs+websocket+百度人脸识别API,实现人脸签到》流程
先用websocket与后台建立通讯:用trackingjs在页面调用电脑摄像头,监听人脸,发现有人脸进入屏幕了,就把图片转成base64字符串,通过websocket发送到后端:后端拿到图片,调用百 ...
- trackingjs+websocket+百度人脸识别API,实现人脸签到
在公司做了个年会的签到.抽奖系统.用java web做的,用公司的办公app扫二维码码即可签到,扫完码就在大屏幕上显示这个人的照片.之后领导让我改得高大上一点,用人脸识别来签到,就把扫二维码的步骤改成 ...
- 免费人脸识别APi
今天对应一些免费的人脸识别的api 做了一下简单的对比,觉得百度开发出来的人脸识别接口还是最符合的我的要求,简单易用,容易上手. 据说百度的一些门禁也使用上了人脸识别的功能了,功能很强大,而且能识别出 ...
- 百度智能云平台调用食物识别api Java实现
纪录一下我小学期2天花了20小时写的菜品识别java程序. 1.2. 百度智能云简介 1.2.1 百度图像识别服务 百度图像识别服务,基于深度学习及大规模图像训练,准确识别图片中的物体类别.位置.置信 ...
随机推荐
- PCANBasic开发(二)
使用Peak的PCan转换器开发,使用其中的PCanBasic.dll // PCANBasic.cs // // ~~~~~~~~~~~~ // // PCAN-Basic API // // ~~ ...
- Trie 练习记录
蒟蒻以前写的逊爆讲解 Trie CF665E Beautiful Subarrays 代码 把之前每个前缀和放进 trie 树里,然后 trie 树上查询即可. CF37C Old Berland L ...
- AcWing 332. 股票交易
大型补档计划 题目链接 \(f[i][j]\) 表示前 \(i\) 天,手里有 \(j\) 个股票挣得最多钱 买股票.枚举 \(u < i - W\) \(f[i][j] = max(f[u][ ...
- Linux 上安装 mysql
1.通过 yum 命令安装 mysql 可以先通过 yum list |grep mysql 方式查看有哪些版本的 mysql 2.安装 mysql yum install mysql-server ...
- Redis5 压力测试结果反馈报告
Redis 相信很多人都用过了,关于性能啥的,网上一堆报告,闲得蛋痛,又随便测测写写一些狗屁文章,来刷存在感了. 安装最新Redis5.0.10 Redis 官方地址 下载页默认是redis6.0,5 ...
- postgresql修改postgres用户密码
[postgres@pg01 ~]$ psql -Upostgres -dpostgres postgres=# alter user postgres with password 'postgres ...
- 新手入门 : Windows Phone 8.1 开发 视频学习地址
本视频资源来自Microsoft Virtual Academy http://www.microsoftvirtualacademy.com/ 下面为视频下载地址! 新手入门 : Windows P ...
- windows10 64位下安装oracle 11g和PL/SQL Developer
一.材料准备: oracle11g安装包(64位) oracle11g客户端(32位) PL\SQL Developer安装包(32位) 1.下载Oracle 11g链接:http://www.ora ...
- 题解 P1579 【哥德巴赫猜想(升级版)】
蒟蒻AC代码,讲解请看题解中. 1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cmath> / ...
- 闭关修炼180天--手写IOC和AOP(xml篇)
闭关修炼180天--手写IOC和AOP(xml篇) 帝莘 首先先分享一波思维导图,涵盖了一些Spring的知识点,当然这里并不全面,后期我会持续更新知识点. 在手写实现IOC和AOP之前(也就是打造一 ...