iOS+Tensorflow实现相机识别

一、安装Homebrew

Homebrew: Mac os x 上包管理工具,具体使用方法可参考Doc

1

二、安装支持库

Homebrew安装好之后,依次安装三个辅助性编译工具:

1
2
3
$ brew  install  libtool   
$ brew  install  autoconf   
$ brew  install  automake

3个工具的含义,请参考:https://en.wikipedia.org/wiki/GNU_Libtool

三、 克隆TensorFlow

git clone https://github.com/tensorflow/tensorflow

四、 编译IOS静态库

tensorflow/contrib/makefile/build_all_ios.sh

这步编译非常耗时,花了大概 100分钟左右才编译完成,编译完成之后,生成 libtensorflow-core.a,将生成结果拷贝到 camera 工程目录下 

五、 下载模型

https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip

拷贝里面的2个文件imagenet_comp_graph_label_strings.txt 和tensorflow_inception_graph.pb/tensorflow/tensorflow/examples/ios/camera/data

用浏览器下载,大概50多M,亲测有效,之前下过其它模型,80多M的,结果后面编译出错,不支持DecodeJpeg算子

六、安装pod及各种坑

命令:pod setup

问题1:-bash: pod: command not found

解决:sudo gem install -n /usr/local/bin cocoapods 

问题2:error: RPC failed; curl 18 transfer closed with outstanding read data remaining

解决:git config --global http.postBuffer 524288000

问题3:[!] Unable to find a specification for `TensorFlow-experimental`

解决:pod repo remove master

问题4、

xcrun: error: SDK  "iphoneos"  cannot be located
xcrun: error: SDK  "iphoneos"  cannot be located
xcrun: error: unable to lookup item  'PlatformPath'  in  SDK  'iphoneos'

+ IPHONEOS_PLATFORM=


解决:sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

PS:安装pod会下载450M文件,亲测最好选择早上安装,下载速度200K~1M,而晚上安装只有20K左右,搞了好几个小时都没装好

问题解决后,继续执行

pod setup

pod install

七、 编译camera工程

1、打开tf_camera_example.xcworkspace,ios Deployment Target调到9.3(camera工程还是用的10以下的接口,10以上接口名字改变了)

2、连上真机,测试,我用的iphone6 plus,版本ios10.3

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值