Skip to Content
Swift游戏开发经典实例
book

Swift游戏开发经典实例

by Jonathon Manning, Paris Buttfield-Addison
January 2020
Intermediate to advanced
356 pages
6h 4m
Chinese
China Electric Power Press Ltd.
Content preview from Swift游戏开发经典实例
288
9
9.
在真机上测试
app
。你将看到摄像头中的内容显示;当你点击屏幕,控制台中
会打印出拍到的
JPEG
图片的大小。
讨论
AVCaptureSession
类让我们从较低级别访问
iOS
设备上的媒体录制硬件。
AVCaptureSession
十分强大,你可以利用设备内置的各种硬件录制视频、静态图
片和音频,然后根据自己的方式使用这些数据。
AVCaptureSession
AVCaptureInput
AVCaptureOutput
之间充当了联系人的角
色。在本例中的
input
就是前置广角相机,输出则是一个静态图片处理程序,当然
也可以是其他,如视频输出和视频编码器。
AVCaptureVideoPreviewLayer
类允许我们预览来自相机的输入。它不是
UIView
而是
CALayer
—— 一种低级组件,你可以将它添加到
UIView
从而显示某些内容。
9.15
导入
Core ML
模型
问题
你想引入一个训练过的
Core ML
机器学习模型,以便用它来做某些预测。
解决方案
首先,你需要有一个
Core ML
模型。如果没有,苹果的
CoreML
网站上放得有大
量常见的模型,地址是:
http://developer.apple.com/machine-learning/
另外一个
Core ML
模型的来源是
http://coreml.store
,上面放有一些针对文本
和图像识别的有趣模型。
将模型下载下来,将它拖到项目导航窗口,添加到你的项目中。
Xcode
会识别该模
型,你就可以在代码中使用它了(具体的例子请参考 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

精通機器學習

精通機器學習

Aurélien Géron
FreeBSD® Unleashed

FreeBSD® Unleashed

Brian Tiemann, Michael C. Urban
深入淺出代數

深入淺出代數

Tracey Pilone, Dan Pilone
Swift学习手册

Swift学习手册

Jon Manning, Paris Buttfield-Addison, Tim Nugent

Publisher Resources

ISBN: 9787519840129