学习OpenCV(中文版)随书源码
学习OpenCV(中文版)一书的随书源码
Learning OpenCV
Preface
1. Overview
What Is OpenCV?
Who Uses OpenCV?
What Is Computer Vision?
The Origin of OpenCV
Downloading and Installing OpenCV
Getting the Latest OpenCV via CVS
More OpenCV Documentation
OpenCV Structure and Content
Portability
Exercises
2. Introduction to OpenCV
Getting Started
First Program——Display a Picture
Second Program——AVI Video
Moving Around
A Simple Transformation
A Not-So-Simple Transformation
Input from a Camera
Writing to an AVI File
Onward
Exercises
3. Gettingto KnowOpenCV
OpenCV Primitive Data Types
CvMat Matrix Structure
IplImage Data Structure
Matrix and Image Operators
Drawing Things
Data Persistence
Integrated Performance Primitives
Summary
Exercises........
学习OpenCV(中文版)
出版前言
译者序
写在前面的话
前言
第1章 概述
什么是OpenCV
OpenCV的应用领域
什么是计算机视觉
OpenCV的起源
下载和安装OpenCV
通过SVN获取最新的OpenCV代码
更多OpenCV文档
OpenCV的结构和内容
移植性
练习
第2章 OpenCV入门
开始准备
初试牛刀—— 显示图像
第二个程序—— 播放AVI视频
视频播放控制
一个简单的变换
一个复杂一点的变换
从摄像机读入数据
写入AVI视频文件
小结
练习
第3章 初探OpenCV
OpenCV的基本数据类型
CvMat矩阵结构
IplImage数据结构
矩阵和图像操作
绘图
数据存储
集成性能基元
小结
练习
第4章 细说HighGUI
一个可移植的图形工具包
创建窗口
载入图像
显示图像
视频的处理
ConvertImage函数
练习
第5章 图像处理
综述
平滑处理
图像形态学
漫水填充算法
尺寸调整
图像金字塔
阈值化
练习
第6章 图像变换
概述
卷积
梯度和Sobel导数
拉普拉斯变换
Canny算子
霍夫变换
重映射
拉伸、收缩、扭曲和旋转
CartToPolar与PolarToCart
LogPolar
离散傅里叶变换(DFT)
离散余弦变换(DCT)
积分图像
距离变换
直方图均衡化
练习
第7章 直方图与匹配
直方图的基本数据结构
访问直方图
直方图的基本操作
一些更复杂的策略
练习
第8章 轮廓
内存
序列
查找轮廓
Freeman链码
轮廓例子
另一个轮廓例子
深入分析轮廓
轮廓的匹配
练习
第9章 图像局部与分割
局部与分割
背景减除
分水岭算法
用Inpainting修补图像
均值漂移分割
Delaunay三角剖分和Voronoi 划分
练习
第10章 跟踪与运动
跟踪基础
寻找角点
亚像素级角点
不变特征
光流
mean-shift和camshift跟踪
运动模板
预估器
condensation算法
练习
第11章 摄像机模型与标定
摄像机模型
标定
矫正
一次完成标定
罗德里格斯变换
练习
第12章 投影与三维视觉
投影
仿射变换和透视变换
POSIT:3D姿态估计
立体成像
来自运动的结构
二维和三维下的直线拟合
练习
第13章 机器学习
什么是机器学习
OpenCV机器学习算法
Mahalanobis距离
K均值
朴素贝叶斯分类
二叉决策树
boosting
随机森林
人脸识别和Haar分类器
其他机器学习算法
练习
第14章 OpenCV的未来
过去与未来
发展方向
OpenCV与艺术家
后记
参考文献
索引
关于作者和译者
封面图片
Windows.Internals.Part.2 6ed Russinovich Solomon Ionescu文字版
Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Chapter 8 I/O System 1
I/O System Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
The I/O Manager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Typical I/O Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Device Drivers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Types of Device Drivers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Structure of a Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Driver Objects and Device Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Opening Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
I/O Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Types of I/O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
I/O Request to a Single-Layered Driver. . . . . . . . . . . . . . . . . . . . . . . . 33
I/O Requests to Layered Drivers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
I/O Cancellation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
I/O Completion Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
I/O Prioritization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Container Notifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Driver Verifier. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Kernel-Mode Driver Framework (KMDF). . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Structure and Operation of a KMDF Driver. . . . . . . . . . . . . . . . . . . . . 68
KMDF Data Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
KMDF I/O Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
User-Mode Driver Framework (UMDF). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
The Plug and Play (PnP) Manager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Level of Plug and Play Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Driver Support for Plug and Play . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Driver Loading, Initialization, and Installation . . . . . . . . . . . . . . . . . . 84
Driver Installation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
The Power Manager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Power Manager Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Driver Power Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Driver and Application Control of Device Power. . . . . . . . . . . . . . . 105
Power Availability Requests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Processor Power Management (PPM). . . . . . . . . . . . . . . . . . . . . . . . 108
Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Chapter 9 Storage Management 125
Storage Terminology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Disk Devices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Rotating Magnetic Disks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Solid State Disks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Disk Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Winload. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Disk Class, Port, and Miniport Drivers. . . . . . . . . . . . . . . . . . . . . . . . 132
Disk Device Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Partition Manager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Volume Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Basic Disks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Dynamic Disks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Multipartition Volume Management. . . . . . . . . . . . . . . . . . . . . . . . . 147
The Volume Namespace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Volume I/O Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Virtual Disk Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Virtual Hard Disk Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Attaching VHDs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Nested File Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
BitLocker Drive Encryption. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Encryption Keys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Trusted Platform Module (TPM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
BitLocker Boot Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
BitLocker Key Recovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Full-Volume Encryption Driver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
BitLocker Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
BitLocker To Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Volume Shadow Copy Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Shadow Copies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
VSS Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
VSS Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Uses in Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Chapter 10 Memory Management 187
Introduction to the Memory Manager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Memory Manager Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Internal Synchronization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Examining Memory Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Services Provided by the Memory Manager. . . . . . . . . . . . . . . . . . . . . . . . 193
Large and Small Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Reserving and Committing Pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Commit Limit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Locking Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Allocation Granularity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Shared Memory and Mapped Files. . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Protecting Memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
No Execute Page Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Copy-on-Write. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Address Windowing Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Kernel-Mode Heaps (System Memory Pools) . . . . . . . . . . . . . . . . . . . . . . . 212
Pool Sizes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Monitoring Pool Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Look-Aside Lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Heap Manager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Types of Heaps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Heap Manager Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Heap Synchronization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
The Low Fragmentation Heap. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Heap Security Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Heap Debugging Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Pageheap. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Fault Tolerant Heap. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Virtual Address Space Layouts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
x86 Address Space Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
x86 System Address Space Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
x86 Session Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
System Page Table Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
64-Bit Address Space Layouts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
x64 Virtual Addressing Limitations. . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Dynamic System Virtual Address Space Management. . . . . . . . . . 242
System Virtual Address Space Quotas. . . . . . . . . . . . . . . . . . . . . . . . 245
User Address Space Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Address Translation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
x86 Virtual Address Translation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Translation Look-Aside Buffer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Physical Address Extension (PAE). . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
x64 Virtual Address Translation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
IA64 Virtual Address Translation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Page Fault Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Invalid PTEs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Prototype PTEs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
In-Paging I/O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Collided Page Faults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Clustered Page Faults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Page Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Commit Charge and the System Commit Limit . . . . . . . . . . . . . . . . 275
Commit Charge and Page File Size. . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
User Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Kernel Stacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
DPC Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Virtual Address Descriptors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Process VADs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Rotate VADs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
NUMA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Section Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Driver Verifier. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Page Frame Number Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Page List Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Page Priority. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
Modified Page Writer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
PFN Data Structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Physical Memory Limits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Windows Client Memory Limits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Working Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Demand Paging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Logical Prefetcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Placement Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Working Set Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Balance Set Manager and Swapper . . . . . . . . . . . . . . . . . . . . . . . . . . 333
System Working Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Memory Notification Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Proactive Memory Management (Superfetch) . . . . . . . . . . . . . . . . . . . . . . 338
Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Tracing and Logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Scenarios. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Page Priority and Rebalancing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Robust Performance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
ReadyBoost. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
ReadyDrive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Unified Caching. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Process Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Chapter 11 Cache Manager 355
Key Features of the Cache Manager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Single, Centralized System Cache. . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
The Memory Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Cache Coherency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Virtual Block Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Stream-Based Caching. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Recoverable File System Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Cache Virtual Memory Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Cache Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .361
Cache Virtual Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
Cache Working Set Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
Cache Physical Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
Cache Data Structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
Systemwide Cache Data Structures. . . . . . . . . . . . . . . . . . . . . . . . . . . 365
Per-File Cache Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
File System Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
Copying to and from the Cache. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Caching with the Mapping and Pinning Interfaces. . . . . . . . . . . . . 374
Caching with the Direct Memory Access Interfaces . . . . . . . . . . . . 375
Fast I/O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
Read-Ahead and Write-Behind. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Intelligent Read-Ahead. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Write-Back Caching and Lazy Writing. . . . . . . . . . . . . . . . . . . . . . . . 379
Write Throttling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
System Threads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Chapter 12 File Systems 391
Windows File System Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
CDFS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
UDF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
FAT12, FAT16, and FAT32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
exFAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
NTFS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
File System Driver Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Local FSDs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Remote FSDs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
File System Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
File System Filter Drivers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Troubleshooting File System Problems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Process Monitor Basic vs. Advanced Modes. . . . . . . . . . . . . . . . . . . 415
Process Monitor Troubleshooting Techniques. . . . . . . . . . . . . . . . . 416
Common Log File System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
NTFS Design Goals and Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
High-End File System Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . 424
Advanced Features of NTFS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
NTFS File System Driver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
NTFS On-Disk Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Volumes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Clusters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Master File Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
File Record Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
File Records. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
File Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
Resident and Nonresident Attributes. . . . . . . . . . . . . . . . . . . . . . . . . 453
Data Compression and Sparse Files. . . . . . . . . . . . . . . . . . . . . . . . . . 456
The Change Journal File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
Indexing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
Object IDs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Quota Tracking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Consolidated Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Reparse Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Transaction Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
NTFS Recovery Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Metadata Logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
NTFS Bad-Cluster Recovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Self-Healing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
Encrypting File System Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Encrypting a File for the First Time. . . . . . . . . . . . . . . . . . . . . . . . . . . 494
The Decryption Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
Backing Up Encrypted Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
Copying Encrypted Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
Chapter 13 Startup and Shutdown 499
Boot Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
BIOS Preboot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .499
The BIOS Boot Sector and Bootmgr. . . . . . . . . . . . . . . . . . . . . . . . . . 502
The UEFI Boot Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
Booting from iSCSI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
Initializing the Kernel and Executive Subsystems. . . . . . . . . . . . . . . 514
Smss, Csrss, and Wininit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
ReadyBoot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
Images That Start Automatically. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Troubleshooting Boot and Startup Problems . . . . . . . . . . . . . . . . . . . . . . . 529
Last Known Good. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Safe Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Windows Recovery Environment (WinRE). . . . . . . . . . . . . . . . . . . . . 534
Solving Common Boot Problems. . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Shutdown. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
Chapter 14 Crash Dump Analysis 547
Why Does Windows Crash?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
The Blue Screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
Causes of Windows Crashes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
Troubleshooting Crashes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
Crash Dump Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .553
Crash Dump Generation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
Windows Error Reporting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
Online Crash Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
Basic Crash Dump Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
Notmyfault. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
Basic Crash Dump Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Verbose Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
Using Crash Troubleshooting Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
Buffer Overruns, Memory Corruption, and Special Pool . . . . . . . . 569
Code Overwrite and System Code Write Protection. . . . . . . . . . . . 573
Advanced Crash Dump Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
Stack Trashes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
Hung or Unresponsive Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
When There Is No Crash Dump. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Analysis of Common Stop Codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
0xD1 - DRIVER_IRQL_NOT_LESS_OR_EQUAL. . . . . . . . . . . . . . . . . . 585
0x8E - KERNEL_MODE_EXCEPTION_NOT_HANDLED. . . . . . . . . . . 586
0x7F - UNEXPECTED_KERNEL_MODE_TRAP. . . . . . . . . . . . . . . . . . . 588
0xC5 - DRIVER_CORRUPTED_EXPOOL. . . . . . . . . . . . . . . . . . . . . . . . 590
Hardware Malfunctions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594
Appendix: Contents of Windows Internals, Sixth Edition, Part 1 595
Index 603
Windows.Internals.Part.1(6th,2012.3).Mark.E.Russinovich.文字版
Introduction. xvii
Chapter 1 Concepts and Tools 1
Windows Operating System Versions. 1
Foundation Concepts and Terms. 2
Windows API. 2
Services, Functions, and Routines. 4
Processes, Threads, and Jobs. 5
Virtual Memory . 15
Kernel Mode vs. User Mode. 17
Terminal Services and Multiple Sessions. 20
Objects and Handles. 21
Security . 22
Registry . 23
Unicode. 24
Digging into Windows Internals. 24
Performance Monitor. 25
Kernel Debugging. 26
Windows Software Development Kit. 31
Windows Driver Kit . 31
Sysinternals Tools. 32
Conclusion. 32
Chapter 2 System Architecture 33
Requirements and Design Goals . 33
Operating System Model. 34
Architecture Overview. 35
Portability. 37
Symmetric Multiprocessing. 38
Scalability. 40
Differences Between Client and Server Versions. 41
Checked Build. 45
Key System Components. 46
Environment Subsystems and Subsystem DLLs . 48
Ntdll.dll. 53
Executive. 54
Kernel. 57
Hardware Abstraction Layer. 60
Device Drivers. 63
System Processes. 68
Conclusion. 78
Chapter 3 System Mechanisms 79
Trap Dispatching. 79
Interrupt Dispatching . 81
Timer Processing. 112
Exception Dispatching. 123
System Service Dispatching. 132
Object Manager . 140
Executive Objects. 143
Object Structure. 145
Synchronization. 176
High-IRQL Synchronization. 178
Low-IRQL Synchronization. 183
System Worker Threads. 205
Windows Global Flags. 207
Advanced Local Procedure Call. 209
Connection Model. 210
Message Model . 211
Asynchronous Operation. 213
Views, Regions, and Sections. 214
Attributes. 215
Blobs, Handles, and Resources . 215
Security . 216
Performance. 217
Debugging and Tracing . 218
Kernel Event Tracing. 220
Wow64. 224
Wow64 Process Address Space Layout . 224
System Calls. 225
Exception Dispatching. 225
User APC Dispatching. 225
Console Support. 225
User Callbacks. 226
File System Redirection. 226
Registry Redirection . 227
I/O Control Requests. 227
16-Bit Installer Applications. 228
Printing. 228
Restrictions. 228
User-Mode Debugging. 229
Kernel Support. 229
Native Support. 230
Windows Subsystem Support . 232
Image Loader. 232
Early Process Initialization . 234
DLL Name Resolution and Redirection . 235
Loaded Module Database . 238
Import Parsing. 242
Post-Import Process Initialization. 243
SwitchBack. 244
API Sets . 245
Hypervisor (Hyper-V). 248
Partitions. 249
Parent Partition. 249
Child Partitions. 251
Hardware Emulation and Support . 254
Kernel Transaction Manager. 268
Hotpatch Support. 270
Kernel Patch Protection. 272
Code Integrity. 274
Conclusion. 276
Chapter 4 Management Mechanisms 277
The Registry. 277
Viewing and Changing the Registry. 277
Registry Usage. 278
Registry Data Types. 279
Registry Logical Structure. 280
Transactional Registry (TxR). 287
Monitoring Registry Activity. 289
Process Monitor Internals. 289
Registry Internals. 293
Services. 305
Service Applications. 305
The Service Control Manager . 321
Service Startup. 323
Startup Errors. 327
Accepting the Boot and Last Known Good. 328
Service Failures. 330
Service Shutdown. 331
Shared Service Processes. 332
Service Tags. 335
Unified Background Process Manager. 336
Initialization. 337
UBPM API . 338
Provider Registration. 338
Consumer Registration. 339
Task Host. 341
Service Control Programs. 341
Windows Management Instrumentation. 342
Providers. 344
The Common Information Model and the Managed
Object Format Language. 345
Class Association . 349
WMI Implementation. 351
WMI Security. 353
Windows Diagnostic Infrastructure . 354
WDI Instrumentation. 354
Diagnostic Policy Service. 354
Diagnostic Functionality. 356
Conclusion. 357
Chapter 5 Processes, Threads, and Jobs 359
Process Internals. 359
Data Structures. 359
Protected Processes. 368
Flow of CreateProcess. 369
Stage 1: Converting and Validating Parameters and Flags. 371
Stage 2: Opening the Image to Be Executed . 373
Stage 3: Creating the Windows Executive Process
Object (PspAllocateProcess). 376
Stage 4: Creating the Initial Thread and Its Stack and
Context. 381
Stage 5: Performing Windows Subsystem–Specific
Post-Initialization. 383
Stage 6: Starting Execution of the Initial Thread. 385
Stage 7: Performing Process Initialization in the Context
of the New Process . 386
Thread Internals . 391
Data Structures. 391
Birth of a Thread . 398
Examining Thread Activity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .398
Limitations on Protected Process Threads. 401
Worker Factories (Thread Pools) . 403
Thread Scheduling. 408
Overview of Windows Scheduling . 408
Priority Levels. 410
Thread States . 416
Dispatcher Database. 421
Quantum. 422
Priority Boosts. 430
Context Switching. 448
Scheduling Scenarios. 449
Idle Threads. 453
Thread Selection. 456
Multiprocessor Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .458
Thread Selection on Multiprocessor Systems. 467
Processor Selection. 468
Processor Share-Based Scheduling. 470
Distributed Fair Share Scheduling. 471
CPU Rate Limits . 478
Dynamic Processor Addition and Replacement . 479
Job Objects . 480
Job Limits. 481
Job Sets. 482
Conclusion. 485
Chapter 6 Security 487
Security Ratings. 487
Trusted Computer System Evaluation Criteria. . . . . . . . . . . . . . . . . .487
The Common Criteria. 489
Security System Components. 490
Protecting Objects. 494
Access Checks. 495
Security Identifiers. 497
Virtual Service Accounts. 518
Security Descriptors and Access Control. 522
The AuthZ API. 536
Account Rights and Privileges . 538
Account Rights. 540
Privileges. 540
Super Privileges . 546
Access Tokens of Processes and Threads. 547
Security Auditing. 548
Object Access Auditing. 549
Global Audit Policy . 552
Advanced Audit Policy Settings. 554
Logon. 555
Winlogon Initialization. 556
User Logon Steps. 558
Assured Authentication. 562
Biometric Framework for User Authentication. 563
User Account Control and Virtualization. 566
File System and Registry Virtualization. 566
Elevation . 573
Application Identification (AppID). 581
AppLocker . 583
Software Restriction Policies. 589
Conclusion. 590
Chapter 7 Networking 591
Windows Networking Architecture. 591
The OSI Reference Model. 592
Windows Networking Components. 594
Networking APIs. 597
Windows Sockets. 597
Winsock Kernel. 603
Remote Procedure Call. 605
Web Access APIs. 610
Named Pipes and Mailslots. 612
NetBIOS. 618
Other Networking APIs. 620
Multiple Redirector Support. 627
Multiple Provider Router . 627
Multiple UNC Provider. 630
Surrogate Providers. 632
Redirector. 633
Mini-Redirectors. 634
Server Message Block and Sub-Redirectors. 635
Distributed File System Namespace . 637
Distributed File System Replication. 638
Offline Files . 639
Caching Modes. 641
Ghosts . 643
Data Security. 643
Cache Structure . 643
BranchCache. 645
Caching Modes. 647
BranchCache Optimized Application Retrieval:
SMB Sequence. 651
BranchCache Optimized Application Retrieval:
HTTP Sequence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .653
Name Resolution. 655
Domain Name System. 655
Peer Name Resolution Protocol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .656
Location and Topology. 658
Network Location Awareness . 658
Network Connectivity Status Indicator . 659
Link-Layer Topology Discovery. 662
Protocol Drivers. 663
Windows Filtering Platform. 666
NDIS Drivers. 672
Variations on the NDIS Miniport. 677
Connection-Oriented NDIS. 677
Remote NDIS. 680
QoS. 682
Binding. 684
Layered Network Services. 685
Remote Access. 685
Active Directory. 686
Network Load Balancing. 688
Network Access Protection . 689
Direct Access. 695
Conclusion. 696
Index. 697
LINUX内核源代码情景分析(下)
七,基于socket的进程间的通信
八,设备驱动
九,多处理器SMP系统结构
十,系统引导和初始化
LINUX内核源代码情景分析(上)
第1章 预备知识
1.1 Linux内核简介.
1.2 Intel X86 CPU系列的寻址方式
1.3 i386的页式内存管理机制
1.4 Linux内核源代码中的C语言代码
1.5 Linux内核源代码中的汇编语言代码
第2章 存储管理
2.1 Linux内存管理的基本框架
2.2 地址映射的全过程
2.3 几个重要的数据结构和函数
2.4 越界访问
2.5 用户堆栈的扩展
2.6 物理页面的使用和周转
2.7 物理页面的分配
2.8 页面的定期换出
2.9 页面的换入
2.10 内核缓冲区的管理
2.11 外部设备存储空间的地址映射
2.12 系统调用brk()
2.13 系统调用mmap()
第3章 中断、异常和系统调用
3.1 X86 CPU对中断的硬件支持
3.2 中断向量表IDT的初始化
3.3 中断请求队列的初始化
3.4 中断的响应和服务
3.5 软中断与Bottom Half
3.6 页面异常的进入和返回
3.7 时钟中断
3.8 系统调用
3.9 系统调用号与跳转表
第4章 进程与进程调度
4.1 进程四要素
4.2 进程三部曲:创建、执行与消亡
4.3 系统调用fork()、vfork()与clone()
4.4 系统调用execve()
4.5 系统调用exit()与wait4()
4.6 进程的调度与切换
4.7 强制性调度
4.8 系统调用nanosleep()和pause()
4.9 内核中的互斥操作
第5章 文件系统
5.1 概述
5.2 从路径名到目标节点
5.3 访问权限与文件安全性
5.4 文件系统的安装和拆卸
5.5 文件的打开与关闭
5.6 文件的写与读
5.7 其他文件操作
5.8 特殊文件系统/proc
第6章 传统的Unix进程间通信
6.1 概述
6.2 管道和系统调用pipe()
6.3 命名管道
6.4 信号
6.5 系统调用ptrace()和进程跟踪
6.6 报文传递
6.7 共享内存
6.8 信号量
FreeBSD操作系统设计与实现
第一部分 综述
第1章 BSD系统的历史和目标
1.1 UNIX系统的历史
1.1.1 UNIX系统的起源
1.1.2 Research小组的UNIX系统
1.1.3 AT&T UNIX System III和System V
1.1.4 伯克利软件发布(BSD)
1.1.5 UNIX无处不在
1.2 BSD和其他系统
1.3 BSD向开放源代码的转变
1.3.1 Networking Release 2
1.3.2 法律诉讼
1.3.3 4.4BSD
1.3.4 4.4BSD-Lite Release 2
1.4 FreeBSD的开发模式
1.5 参考文献
第2章 FreeBSD设计概述
2.1 FreeBSD的功能和内核
2.2 内核结构
2.3 内核服务
2.4 进程管理
2.4.1 信号
2.4.2 进程组和会话
2.5 内存管理
2.5.1 BSD内存管理设计要点
2.5.2 内核中的内存管理
2.6 I/O系统
2.6.1 描述符与I/O
2.6.2 描述符管理
2.6.3 设备
2.6.4 套接口IPC
2.6.5 分散/聚集I/O
2.6.6 多文件系统支持
2.7 设备
2.8 文件系统
2.9 网络文件系统
2.10 终端
2.11 进程间通信
2.12 网络通信
2.13 网络实现
2.14 系统运行
2.15 复习题
2.16 参考文献
第3章 内核服务
3.1 内核结构
3.1.1 系统进程
3.1.2 系统入口
3.1.3 运行时刻的内核结构
3.1.4 内核的入口
3.1.5 从内核返回
3.2 系统调用
3.2.1 调用结果的处理
3.2.2 从系统调用返回
3.3 陷阱和中断
3.3.1 陷阱
3.3.2 I/O设备中断
3.3.3 软件中断
3.4 时钟中断
3.4.1 统计和进程调度
3.4.2 超时
3.5 内存管理服务
3.6 时间服务
3.6.1 真实时间
3.6.2 外部表示
3.6.3 调整时间
3.6.4 时间间隔
3.7 用户、用户组和其他身份标识
3.7.1 主机标识符
3.7.2 进程组和会话
3.8 资源服务
3.8.1 进程优先级
3.8.2 资源利用
3.8.3 资源限制
3.8.4 文件系统配额
3.9 系统运行服务
3.10 复习题
3.11 参考文献
第二部分 进程
第4章 进程管理
4.1 进程管理概述
4.1.1 多程序机制
4.1.2 调度
4.2 进程状态
4.2.1 进程结构
4.2.2 线程结构
4.3 上下文切换
4.3.1 线程状态
4.3.2 底层上下文切换
4.3.3 主动上下文切换
4.3.4 同步
4.3.5 互斥同步
4.3.6 锁管理器的锁
4.3.7 其他同步
4.4 线程调度
4.4.1 4.4BSD的调度程序
4.4.2 线程调度
4.4.3 线程优先级的计算
4.4.4 线程优先级例程
4.4.5 线程运行队列和上下文切换
4.4.6 ULE调度程序
4.5 创建进程
4.6 终止进程
4.7 信号
4.7.1 信号的历史
4.7.2 发送信号
4.7.3 接收信号
4.8 进程组和会话
4.8.1 会话
4.8.2 作业控制
4.9 监管环境
4.9.1 监管环境的语义
4.9.2 监管环境的实现
4.9.3 监管环境的限制
4.10 进程的调试
4.11 复习题
4.12 参考文献
第5章 存储管理
5.1 术语
5.1.1 进程与内存
5.1.2 调页机制
5.1.3 替换算法
5.1.4 工作集模型
5.1.5 交换机制
5.1.6 虚拟内存的优点
5.1.7 虚拟内存的硬件要求
5.2 FreeBSD虚拟内存系统概述
5.3 内核的存储管理
5.3.1 内核映射和子映射
5.3.2 内核地址空间的分配
5.3.3 内核的存储分配程序
5.3.4 内核的区域存储分配程序
5.4 进程独立拥有的资源
5.4.1 FreeBSD的进程虚拟地址空间
5.4.2 缺页处理
5.4.3 映射到对象
5.4.4 对象
5.4.5 对象到页面
5.5 共享存储
5.5.1 mmap模型
5.5.2 共享映射
5.5.3 私有映射
5.5.4 压缩影子链
5.5.5 私有快照
5.6 创建新进程
5.6.1 保留内核资源
5.6.2 复制用户地址空间
5.6.3 不通过复制创建新进程
5.7 执行一个文件
5.8 进程地址空间的操作
5.8.1 改变进程大小
5.8.2 文件映射
5.8.3 改变保护权限
5.9 终止进程
5.10 调页器接口
5.10.1 vnode调页器
5.10.2 设备调页器
5.10.3 物理内存调页器
5.10.4 交换调页器
5.11 调页机制
5.11.1 硬件高速缓存的设计
5.11.2 页面填色
5.12 页面替换
5.12.1 调页参数
5.12.2 pageout守护进程
5.12.3 交换机制
5.12.4 换入进程
5.13 可移植性
5.13.1 pmap模块的作用
5.13.2 初始化和启动
5.13.3 分配和释放映射
5.13.4 改变映射的访问和固定属性
5.13.5 管理页表的使用信息
5.13.6 初始化物理页面
5.13.7 管理内部数据结构
5.14 复习题
5.15 参考文献
第三部分 I/O系统
第6章 I/O系统概述
6.1 从用户到设备的I/O映射
6.1.1 设备驱动程序
6.1.2 I/O队列
6.1.3 中断处理
6.2 字符设备
6.2.1 原始设备和物理I/O
6.2.2 面向字符的设备
6.2.3 字符设备驱动程序的入口点
6.3 磁盘设备
6.3.1 块设备驱动程序的入口点
6.3.2 磁盘I/O请求的排序
6.3.3 磁盘标签
6.4 描述符的管理和服务
6.4.1 打开文件项
6.4.2 管理描述符
6.4.3 异步I/O
6.4.4 文件描述符的上锁机制
6.4.5 描述符上的多路I/O操作
6.4.6 select调用的实现
6.4.7 数据在内核中的转移
6.5 虚拟文件系统的接口
6.5.1 vnode的内容
6.5.2 对vnode的操作
6.5.3 路径名转换
6.5.4 文件系统的导出服务
6.6 与文件系统无关的服务
6.6.1 名字缓存
6.6.2 缓冲区管理
6.6.3 缓冲区管理的实现
6.7 可叠加的文件系统
6.7.1 简单的文件系统层
6.7.2 联合安装的文件系统
6.7.3 其他文件系统
6.8 复习题
6.9 参考文献
第7章 设备
7.1 设备概述
7.1.1 PC的I/O体系结构
7.1.2 FreeBSD海量存储I/O子系统的结构
7.1.3 设备的命名和访问
7.2 GEOM层
7.2.1 术语和拓扑规则
7.2.2 改变拓扑
7.2.3 运行
7.2.4 拓扑的灵活性
7.3 CAM层
7.3.1 SCSI子系统
7.3.2 I/O请求通过CAM子系统的路径
7.4 ATA层
7.5 配置设备
7.5.1 识别设备
7.5.2 自动配置数据结构
7.5.3 资源管理
7.6 复习题
7.7 参考文献
第8章 本地文件系统
8.1 文件系统的分层管理
8.2 inode的结构
8.2.1 inode格式的变化
8.2.2 扩展属性
8.2.3 文件系统的新功能
8.2.4 文件标志
8.2.5 动态的inode
8.2.6 管理inode
8.3 命名
8.3.1 目录
8.3.2 在目录中查找名字
8.3.3 路径名转换
8.3.4 链接
8.4 配额
8.5 文件上锁
8.6 软更新
8.6.1 文件系统中的更新依赖
8.6.2 依赖关系的数据结构
8.6.3 跟踪位映射表的依赖关系
8.6.4 跟踪inode的依赖关系
8.6.5 跟踪直接块的依赖关系
8.6.6 跟踪间接块的依赖关系
8.6.7 跟踪新间接块的依赖关系
8.6.8 跟踪新目录项的依赖关系
8.6.9 跟踪新目录的依赖关系
8.6.10 跟踪删除目录项时的依赖关系
8.6.11 截短文件
8.6.12 回收文件和目录的inode节点
8.6.13 跟踪目录项重命名时的依赖关系
8.6.14 跟踪删除文件时的依赖关系
8.6.15 fsync对软更新的要求
8.6.16 删除文件时对软更新的要求
8.6.17 fsck对软更新的要求
8.6.18 软更新的性能
8.7 文件系统的快照
8.7.1 创建文件系统快照
8.7.2 维护文件系统快照
8.7.3 大型文件系统的快照
8.7.4 快照性能
8.7.5 后台fsck
8.7.6 用户可见的快照
8.7.7 动态的转储
8.8 本地文件库
8.8.1 文件库概述
8.8.2 用户的文件I/O
8.9 伯克利快速文件系统
8.9.1 伯克利快速文件系统的组成
8.9.2 引导块
8.9.3 优化存储空间利用率
8.9.4 读写文件
8.9.5 布局策略
8.9.6 分配机制
8.9.7 将块组成簇
8.9.8 基于扩展的分配
8.10 复习题
8.11 参考文献
第9章 网络文件系统
9.1 历史和概述
9.2 NFS的结构和操作
9.2.1 NFS协议
9.2.2 FreeBSD的NFS实现
9.2.3 客户机/服务器的交互操作
9.2.4 RPC的传输问题
9.2.5 安全问题
9.3 提高性能的技术
9.3.1 租约
9.3.2 崩溃恢复
9.4 复习题
9.5 参考文献
第10章 终端处理
10.1 终端处理模式
10.2 行规程
10.3 用户接口
10.4 tty结构
10.5 进程组、会话和终端控制
10.6 C-list
10.7 RS-232和调制解调器控制
10.8 终端操作
10.8.1 打开终端
10.8.2 输出到行规程
10.8.3 终端的输出
10.8.4 终端的输入
10.8.5 ioctl例程
10.8.6 调制解调器转换
10.8.7 关闭终端设备
10.9 其他行规程
10.10 复习题
10.11 参考文献
第四部分 进程间通信
第11章 进程间通信
11.1 进程间通信的模型
11.2 实现的结构和概述
11.3 内存管理
11.3.1 mbuf
11.3.2 存储管理算法
11.3.3 mbuf工具例程
11.4 数据结构
11.4.1 通信域
11.4.2 套接口
11.4.3 套接口地址
11.4.4 锁
11.5 建立连接
11.6 传送数据
11.6.1 发送数据
11.6.2 接收数据
11.7 关闭套接口
11.8 本地进程间通信
11.8.1 信号量
11.8.2 消息队列
11.8.3 共享内存
11.9 复习题
11.10 参考文献
第12章 网络通信
12.1 内部结构
12.1.1 数据流
12.1.2 通信协议
12.1.3 网络接口
12.2 套接口到协议的接口
12.2.1 协议的用户请求例程
12.2.2 协议的控制输出例程
12.3 协议到协议的接口
12.3.1 pr_output
12.3.2 pr_input
12.3.3 pr_ctlinput
12.4 协议和网络的接口
12.4.1 发送数据包
12.4.2 接收数据包
12.5 路由选择
12.5.1 内核路由选择表
12.5.2 路由选择查找
12.5.3 路由选择重定向
12.5.4 路由选择表接口
12.5.5 用户级的路由选择策略
12.5.6 用户级路由选择接口:路由选择套接口
12.6 缓冲和拥塞控制
12.6.1 协议缓冲策略
12.6.2 队列限制
12.7 原始套接口
12.7.1 控制块
12.7.2 输入处理
12.7.3 输出处理
12.8 网络子系统的其他主题
12.8.1 带外数据
12.8.2 地址解析协议
12.9 复习题
12.10 参考文献
第13章 网络协议
13.1 IPv4网络协议
13.1.1 IPv4地址
13.1.2 广播地址
13.1.3 组播
13.1.4 端口与关联
13.1.5 协议控制块
13.2 UDP协议
13.2.1 初始化
13.2.2 输出
13.2.3 输入
13.2.4 控制操作
13.3 Internet协议(IP)
13.3.1 输出
13.3.2 输入
13.3.3 转发
13.4 TCP协议
13.4.1 TCP连接状态
13.4.2 序号变量
13.5 TCP算法
13.5.1 定时器
13.5.2 往返时间的估计
13.5.3 建立连接
13.5.4 SYN缓存
13.5.5 关闭连接
13.6 TCP输入处理
13.7 TCP输出处理
13.7.1 发送数据
13.7.2 避免糊涂窗口综合症
13.7.3 避免小数据包
13.7.4 确认延迟和窗口更新
13.7.5 重发状态
13.7.6 慢启动
13.7.7 源拥塞的处理
13.7.8 缓冲与窗口大小分配
13.7.9 使用慢启动避免拥塞
13.7.10 快速重发
13.8 ICMP协议
13.9 IPv6
13.9.1 IPv6地址
13.9.2 IPv6数据包格式
13.9.3 套接口API的调整
13.9.4 自动配置
13.10 安全
13.10.1 IPSec概述
13.10.2 安全协议
13.10.3 密钥管理
13.10.4 IPSec实现
13.10.5 密码子系统
13.11 复习题
13.12 参考文献
第五部分 系统运行
第14章 启动和关机
14.1 概述
14.2 引导
14.3 初始化内核
14.4 初始化内核模块
14.4.1 基本服务
14.4.2 初始化内核线程
14.4.3 初始化设备模块
14.4.4 内核的可加载模块
14.4.5 启动进程间通信
14.4.6 启动内核线程
14.5 用户级初始化
14.5.1 /sbin/init
14.5.2 系统的启动脚本
14.5.3 /usr/libexec/getty
14.5.4 /usr/bin/login
14.6 系统运行
14.6.1 内核的配置
14.6.2 系统关机与自动重启
14.6.3 系统调试
14.6.4 同内核传递信息
14.7 复习题
14.8 参考文献
术语表
Operating Systems Design & Implementation 3rd Edition(操作系统设计与实现)
Copyright
Preface xv
Chapter 1. Introduction 1
Section 1.1. What Is an Operating System? 4
Section 1.2. History of Operating Systems 6
Section 1.3. Operating System Concepts 19
Section 1.4. System Calls 26
Section 1.5. Operating System Structure 42
Section 1.6. Outline of the Rest of This Book 51
Section 1.7. Summary 51
Problems 52
Chapter 2. Processes 55
Section 2.1. Introduction to Processes 55
Section 2.2. Interprocess Communication 68
Section 2.3. Classical IPC Problems 88
Section 2.4. Scheduling 93
Section 2.5. Overview of Processes in MINIX 3 112
Section 2.6. Implementation of Processes in MINIX 3 125
Section 2.7. The System Task in MINIX 3 192
Section 2.8. The Clock Task in MINIX 3 204
Section 2.9. Summary 214
Problems 215
Chapter 3. Input/Output 221
Section 3.1. Principles of I/O Hardware 222
Section 3.2. Principles of I/O Software 229
Section 3.3. Deadlocks 237
Section 3.4. Overview of I/O in MINIX 3 252
Section 3.5. Block Devices in MINIX 3 261
Section 3.6. RAM Disks 271
Section 3.7. Disks 278
Section 3.8. Terminals 302
Section 3.9. Summary 366
Problems 367
Chapter 4. Memory Management 373
Section 4.1. Basic Memory Management 374
Section 4.2. Swapping 378
Section 4.3. Virtual Memory 383
Section 4.4. Page Replacement Algorithms 396
Section 4.5. Design Issues for Paging Systems 404
Section 4.6. Segmentation 410
Section 4.7. Overview of the MINIX 3 Process Manager 420
Section 4.8. Implementation of the MINIX 3 Process Manager447
Section 4.9. Summary 475
Problems 476
Chapter 5. File Systems 481
Section 5.1. Files 482
Section 5.2. Directories 491
Section 5.3. File System Implementation 497
Section 5.4. Security 526
Section 5.5. Protection Mechanisms 537
Section 5.6. Overview of the MINIX 3 File System 548
Section 5.7. Implementation of the MINIX 3 File System 566
Section 5.8. Summary 606
Problems 607
Chapter 6. Reading List and Bibliography 611
Section 6.1. Suggestions for Further Reading 611
Section 6.2. Alphabetical Bibliography 618
Appendix A. Installing MINIX 3 629
Section A.1. Preparation 629
Section A.2. Booting 631
Section A.3. Installing to the Hard Disk 632
Section A.4. Testing 634
Section A.5. Using a Simulator 636
Appendix B. The MINIX Source Code 637
Appendix C. Index to Files 1033
About the Authors 1053
About the MINIX 3 CD InsideBackCover
System Requirements InsideBackCover
Hardware InsideBackCover
Software InsideBackCover
Installation InsideBackCover
Product Support InsideBackCover
Index
The Design and Implementation of the FreeBSD Operating System
As in earlier Addison-Wesley books on the UNIX-based BSD operating system, Kirk McKusick and George Neville-Neil deliver here the most comprehensive, up-to-date, and authoritative technical information on the internal structure of open source FreeBSD. Readers involved in technical and sales support can learn the capabilities and limitations of the system; applications developers can learn effectively and efficiently how to interface to the system; system administrators can learn how to maintain, tune, and configure the system; and systems programmers can learn how to extend, enhance, and interface to the system. The authors provide a concise overview of FreeBSD's design and implementation. Then, while explaining key design decisions, they detail the concepts, data structures, and algorithms used in implementing the systems facilities. As a result, readers can use this book as both a practical reference and an in-depth study of a contemporary, portable, open source operating system. This book: * Details the many performance improvements in the virtual memory system * Describes the new symmetric multiprocessor support * Includes new sections on threads and their scheduling * Introduces the new jail facility to ease the hosting of multiple domains * Updates information on networking and interprocess communication Already widely used for Internet services and firewalls, high-availability servers, and general timesharing systems, the lean quality of FreeBSD also suits the growing area of embedded systems. Unlike Linux, FreeBSD does not require users to publicize any changes they make to the source code.
Unix操作系统设计
译者序
前言
第1章 系统概貌
1.1 历史
1.2 系统结构
1.3 用户看法
1.3.1 文件系统
1.3.2 处理环境
1.3.3 构件原语
1.4 操作系统服务
1.5 关于硬件的假设
1.5.1 中断与例外
1.5.2 处理机执行级
1.5.3 存储管理
1.6 本章小结
第2章 内核导言
2.1 UNIX操作系统的体系结构
2.2 系统概念介绍
2.2.1 文件子系统概貌
2.2.2 进程
2.3 内核数据结构
2.4 系统管理
2.5 本章小结
2.6 习题
第3章 数据缓冲区高速缓冲
3.1 缓冲头部
3.2 缓冲池的结构
3.3 缓冲区的检索
3.4 读磁盘块与写磁盘块
3.5 高速缓冲的优点与缺点
3.6 本章小结
3.7 习题
第4章 文件的内部表示
4.1 索引节点
4.1.1 定义
4.1.2 对索引节点的存取
4.1.3 释放索引节点
4.2 正规文件的结构
4.3 目录
4.4 路径名到索引节点的转换
4.5 超级块
4.6 为新文件分配索引节点
4.7 磁盘块的分配
4.8 其他文件类型
4.9 本章小结
4.10 习题
第5章 文件系统的系统调用
5.1 系统调用Open
5.2 系统调用read
5.3 系统调用write
5.4 文件和记录的上锁
5.5 文件的输入/输出位置的调整lseek
5.6 系统调用close
5.7 文件的建立
5.8 特殊文件的建立
5.9 改变目录及根
5.10 改变所有者及许可权方式
5.11 系统调用stat和fstat
5.12 管道
5.12.1 系统调用pipe
5.12.2 有名管道的打开
5.12.3 管道的读和写
5.12.4 管道的关闭
5.12.5 例
5.13 系统调用dup
5.14 文件系统的安装和拆卸
5.14.1 在文件路径名中跨越安装点
5.14.2 文件系统的拆卸
5.15 系统调用link
5.16 系统调用unlink
5.16.1 文件系统的一致性
5.16.2 竟争条件
5.17 文件系统的抽象
5.18 文件系统维护
5.19 本章小结
5.20 习题
第6章 进程结构
6.1 进程的状态和状态的转换
6.2 系统存储方案
6.2.1 区
6.2.2 页和页表
6.2.3 内核的安排
6.2.4 u区
6.3 进程的上下文
6.4 进程上下文的保存
6.4.1 中断和例外
6.4.2 系统调用的接口
6.4.3 上下文切换
6.4.4 为废弃返回(abortive return)而保存上下文
6.4.5 在系统和用户地址空间之间拷贝数据
6.5 进程地址空间的管理
6.5.1 区的上锁和解锁
6.5.2 区的分配
6.5.3 区附接到进程
6.5.4 区大小的改变
6.5.5 区的装入
6.5.6 区的释放
6.5.7 区与进程的断接
6.5.8 区的复制
6.6 睡眠
6.6.1 睡眠事件及其地址
6.6.2 算法sleep和wakeup
6.7 本章小结
6.8 习题
第7章 进程控制
7.1 进程的创建
7.2 软中断信号
7.2.1 软中断信号的处理
7.2.2 进程组
7.2.3 从进程发送软中断信号
7.3 进程的终止
7.4 等待进程的终止
7.5 对其他程序的引用
7.6 进程的用户标识号
7.7 改变进程的大小
7.8 Shell程序
7.9 系统自举和进程init
7.10 本章小结
7.11 习题
第8章 进程调度和时间
8.1 进程调度
8.1.1 算法
8.1.2 调度参数
8.1.3 进程调度的例子
8.1.4 进程优先权的控制
8.1.5 公平共享调度
8.1.6 实时处理
8.2 有关时间的系统调用
8.3 时钟
8.3.1 重新启动时钟
8.3.2 系统的内部定时
8.3.3 直方图分析
8.3.4 记帐和统计
8.3.5 计时
8.4 本章小结
8.5 习题
第9章 存储管理策略
9.1 对换
9.1.1 对换空间的分配
9.1.2 进程的换出
9.1.3 进程的换入
9.2 请求调页
9.2.1 请求调页的数据结构
9.2.2 偷页进程
9.2.3 页面错
9.2.4 在简单硬件支持下的请求调页系统
9.3 对换和请求调页的混合系统
9.4 本章小结
9.5 习题
第10章 输入输出子系统
10.1 驱动程序接口
10.1.1 系统配置
10.1.2 系统调用与驱动程序接口
10.1.3 中断处理程序
10.2 磁盘驱动程序
10.3 终端驱动程序
10.3.1 字符表Clist
10.3.2 标准方式下的终端驱动程序
10.3.3 原始方式下的终端驱动程序
10.3.4 终端探询
10.3.5 建立控制终端
10.3.6 间接终端驱动程序
10.3.7 注册到系统
10.4 流
10.4.1 流的详细的示例
10.4.2 对流的分析
10.5 本章小结
10.6 习题
第11章 进程间通信
11.1 进程跟踪
11.2 系统V IPC
11.2.1 消息
11.2.2 共享存储区
11.2.3 信号量
11.2.4 总的评价
11.3 网络通信
11.4 套接字
11.5 本章小结
11.6 习题
第12章 多处理机系统
12.1 多处理机系统的问题
12.2 主从处理机解决方法
12.3 信号量解决方法
12.3.1 信号量定义
12.3.2 信号量实现
12.3.3 几个算法
12.4 Tunis系统
12.5 性能局限性
12.6 习题
第13章 分布式UNIX系统
13.1 卫星处理机系统
13.2 纽卡斯尔连接
13.3 透明型分布式文件系统
13.4 无存根进程的透明分布式模型
13.5 本章小结
13.6 习题
附录A 系统调用
参考文献
索引
UNIX技术内幕
第1章 概论 1
1.1 历史背景 1
1.2 UNIX诞生的经过 1
1.3 UNIX版本6 2
1.4 各流派一览 2
1.5 为什么取得成功 3
1.5.1 简洁高效 3
1.5.2 健壮性 3
1.5.3 功能丰富 3
1.5.4 移植性 3
1.5.5 开放性 4
1.6 缩写及术语说明 4
第2章 UNIX综述 6
2.1 硬件平台 6
2.1.1 中断和自陷(Trap) 7
2.1.2 两种处理器模式 9
2.1.3 通用寄存器 10
2.1.4 I/O设备管理 10
2.1.5 栈(Stack) 11
2.1.6 常用指令 11
2.1.7 备注 19
2.2 UNIX内核综述 20
2.2.1 模块分类 20
2.2.2 各模块间的通信 20
2.2.3 源文件 21
2.2.4 语法规则和编码风格说明 23
2.3 思考题 27
第3章 虚拟内存 28
3.1 简介 28
3.2 虚拟内存的优点 29
3.2.1 安全性 29
3.2.2 提高空间利用率 30
3.2.3 多进程的支持 30
3.3 PDP11/40的虚拟内存机制 30
3.3.1 页地址寄存器(PAR) 32
3.3.2 页描述寄存器(PDR) 32
3.3.3 活动页寄存器地址 33
3.3.4 虚拟地址向物理地址的映射过程 33
3.3.5 异常处理 35
3.3.6 和现代页式虚存的比较 36
3.4 UNIX的虚存实现 36
3.4.1 进程空间分布 36
3.4.2 用户活动页寄存器设置函数estabur 37
3.4.3 用户空间映射函数sureg 41
3.5 内存管理 42
3.5.1 内核内存管理 42
3.5.2 用户内存管理 47
3.6 思考题 56
第4章 启动模块 57
4.1 操作流程 57
4.2 中断向量 58
4.3 启动函数start 60
4.4 备注 65
4.4.1 为什么需要引导程序和装入程序 65
4.4.2 0地址处指令分析 65
4.4.3 为什么要使用汇编语言 66
4.4.4 Windows启动过程浅析 66
4.5 思考题 67
第5章 进程管理和调度 68
5.1 程序员眼中的虚拟机 68
5.2 系统资源 68
5.3 进程上下文 70
5.4 进程调度 72
5.5 UNIX实现 73
5.5.1 进程上下文 73
5.5.2 进程的两种状态 80
5.5.3 调度过程 82
5.5.4 备注 128
5.6 思考题 134
第6章 中断处理过程 136
6.1 PSW寄存器 136
6.2 中断处理流程 136
6.3 中断向量 138
6.4 PDP 11/40的中断类型 139
6.4.1 电传终端接口输入中断 139
6.4.2 电传终端接口输出中断 140
6.4.3 纸带打孔机输入中断 140
6.4.4 纸带打孔机输出中断 140
6.4.5 时钟中断 140
6.4.6 行打印机中断 140
6.4.7 磁盘读写中断 140
6.5 一些常用函数 140
6.5.1 特殊指令 140
6.5.2 fubyte(fuibyte) 141
6.5.3 fuword(fuiword) 143
6.5.4 subyte(suibyte) 143
6.5.5 suword(suiword) 144
6.5.6 clearseg 144
6.5.7 copyseg 145
6.5.8 copyin/copyout 146
6.5.9 dpadd 148
6.5.10 ldiv/lrem/lshift 148
6.6 call函数 149
6.7 时钟中断 151
6.7.1 基本概念 151
6.7.2 处理过程 152
6.8 call函数调用分派切换器的理由 163
6.9 内核定时器 164
6.9.1 数据结构 164
6.9.2 定时器的创建 165
6.9.3 定时器的触发 167
6.10 一些例子 168
6.10.1 进程优先级的调整 168
6.10.2 进程分派切换实例 174
6.11 备注 178
6.11.1 中断服务函数中为什么不使用互斥锁 178
6.11.2 中断服务函数中为什么不访问u变量 178
6.11.3 关于内存管理违例自陷的处理过程 179
6.11.4 调度标志runrun和runin 179
6.12 思考题 179
第7章 自陷 180
7.1 自陷原理 180
7.2 自陷向量 180
7.3 PDP11/40的自陷类型 180
7.3.1 系统出错自陷 180
7.3.2 系统调用自陷 182
7.3.3 调试自陷 182
7.3.4 自陷优先级 183
7.4 自陷处理过程 184
7.4.1 汇编函数_trap 184
7.4.2 C函数trap 186
7.4.3 backup函数 191
第8章 文件系统 211
8.1 概述 211
8.2 框架 212
8.2.1 文件存储的实现 212
8.2.2 UNIX文件系统 219
8.2.3 UNIX文件系统的详细实现 224
8.3 文件访问接口 229
8.3.1 文件创建接口creat 230
8.3.2 文件打开接口open 235
8.3.3 文件关闭接口close 236
8.3.4 文件读接口read 237
8.3.5 文件写接口write 238
8.3.6 文件定位接口seek 239
8.3.7 特殊文件创建接口mknod 242
8.3.8 文件链接接口link 244
8.3.9 取消文件链接接口unlink 246
8.3.10 设备加载接口smount 248
8.3.11 设备卸载接口sumount 251
8.4 节点和块管理 253
8.4.1 节点缓存 253
8.4.2 块缓存 255
8.4.3 块访问接口 263
8.4.4 节点访问接口 294
8.5 块设备驱动 322
8.5.1 概述 322
8.5.2 根设备——rk11磁盘 326
8.6 备注 335
8.6.1 FAT16文件系统 335
8.6.2 多进程访问文件的问题 338
8.6.3 进程间同步 339
8.6.4 文件的删除 340
8.6.5 设备驱动的扩展 340
8.7 总结 341
8.8 思考题 341
第9章 字符设备驱动 342
9.1 交互终端——电传打字机(teletypewriter) 342
9.1.1 设备特性 343
9.1.2 操作寄存器 343
9.1.3 驱动框架 345
9.1.4 驱动函数 351
9.1.5 shell应用举例 378
9.1.6 内核打印接口 379
9.2 PC-11纸带打孔机 383
9.2.1 设备特性 383
9.2.2 操作寄存器 384
9.2.3 驱动框架 385
9.2.4 驱动函数 387
9.2.5 读取器状态转换图 392
9.3 LP-11行打印机 393
9.3.1 设备特性 393
9.3.2 操作寄存器 393
9.3.3 驱动框架 394
9.3.4 驱动函数 396
9.4 现代打印机 401
9.4.1 并口 401
9.4.2 和内核挂接 403
9.4.3 简单的打印程序 406
9.4.4 CUPS 408
9.5 其他字符设备 408
9.5.1 内存 409
9.5.2 磁盘 411
9.6 网络驱动程序 415
9.7 综合示例 416
9.8 总结 417
9.9 思考题 418
第10章 进程交换过程 419
10.1 概述 419
10.2 具体实现 421
10.2.1 进程换出函数xswap 422
10.2.2 程序段内存释放函数xccdec 423
10.2.3 交换函数swap 424
10.2.4 调用实例 425
10.3 综合示例 426
10.4 思考题 430
第11章 UNIX可执行文件 431
11.1 .out文件 431
11.1.1 可执行头 431
11.1.2 程序段 432
11.1.3 数据段 432
11.1.4 程序和数据重定向表 432
11.1.5 符号表 434
11.1.6 示例 437
11.2 动态链接过程* 442
11.2.1 静态共享 443
11.2.2 动态共享 446
11.2.3 GOT/PLT表和位置无关代码(PIC) 446
11.2.4 动态加载过程分析 450
第12章 系统调用 457
12.1 概述 457
12.2 系统调用的实现 457
12.2.1 用户实现 459
12.2.2 系统调用表和trap自陷 459
12.2.3 内核实现 469
12.3 各系统调用的实现 469
12.3.1 文件相关调用 471
12.3.2 进程相关调用 491
12.3.3 信号相关调用 538
12.3.4 调试功能调用 558
12.3.5 用户/组ID调用 586
12.3.6 时间相关调用 589
12.3.7 终端相关调用 591
第13章 进程间通信 596
13.1 概述 596
13.2 管道 596
13.2.1 相关系统调用 596
13.2.2 管道实现过程分析 602
13.2.3 应用示例 603
13.2.4 采用内存文件实现管道 608
13.2.5 思考题 610
13.3 文件 610
13.4 有名管道 611
13.5 进程间同步 611
13.5.1 信号量 612
13.5.2 互斥体 621
13.5.3 事件 622
13.6 死锁 634
13.7 其他进程间数据传输方式 636
13.7.1 消息(message) 636
13.7.2 信箱(mailbox) 648
13.7.3 共享内存 671
第14章 多线程的实现 686
14.1 概述 686
14.2 线程和经典进程的比较 686
14.3 线程的示例实现 686
14.3.1 相关数据结构 686
14.3.2 实现方案 689
14.3.3 线程创建调用CreateThread 691
14.3.4 内核改动 695
14.3.5 线程退出调用ExitThread 711
14.3.6 线程id获得调用gettid 712
14.3.7 线程挂起调用SuspendThread 712
14.3.8 线程恢复调用ResumeThread 714
14.3.9 线程终止调用TerminateThread 715
14.3.10 线程ID查询调用GetThreadID 719
14.3.11 线程名查询调用GetThreadName 720
14.3.12 使用示例 721
14.3.13 思考题 723
第15章 网络多用户 724
15.1 系统初始化过程 724
15.1.1 init进程 724
15.1.2 getty程序 725
15.1.3 login程序 725
15.2 telnet程序 730
15.2.1 工作原理 730
15.2.2 常用配置 731
15.3 NFS(网络文件系统) 732
15.3.1 基本原理 733
15.3.2 RPC(远程过程调用) 734
15.3.3 各过程的实现 737
15.3.4 简单示例 741
附录A 参考书目及资源 742
附录B 思考题答案 743
UNIX网络编程 卷2:进程间通信
第一部分 简介
第1章 简介 2
1.1 概述 2
1.2 进程、线程与信息共享 3
1.3 IPC对象的持续性 4
1.4 名字空间 5
1.5 fork、exec和exit对IPC对象的影响 7
1.6 出错处理:包裹函数 8
1.7 Unix标准 9
1.8 书中IPC例子索引表 11
1.9 小结 13
习题 13
第2章 Posix IPC 14
2.1 概述 14
2.2 IPC名字 14
2.3 创建与打开IPC通道 16
2.4 IPC权限 18
2.5 小结 19
习题 19
第3章 System V IPC 20
.3.1 概述 20
3.2 key_t键和ftok函数 20
3.3 ipc_perm结构 22
3.4 创建与打开IPC通道 22
3.5 IPC权限 24
3.6 标识符重用 25
3.7 ipcs和ipcrm程序 27
3.8 内核限制 27
3.9 小结 28
习题 29
第二部分 消息传递
第4章 管道和FIFO 32
4.1 概述 32
4.2 一个简单的客户-服务器例子 32
4.3 管道 32
4.4 全双工管道 37
4.5 popen和pclose函数 39
4.6 FIFO 40
4.7 管道和FIFO的额外属性 44
4.8 单个服务器,多个客户 46
4.9 对比迭代服务器与并发服务器 50
4.10 字节流与消息 51
4.11 管道和FIFO限制 55
4.12 小结 56
习题 57
第5章 Posix消息队列 58
5.1 概述 58
5.2 mq_open、mq_close和mq_unlink函数 59
5.3 mq_getattr和mq_setattr函数 61
5.4 mq_send和mq_receive函数 64
5.5 消息队列限制 67
5.6 mq_notify函数 68
5.7 Posix实时信号 78
5.8 使用内存映射I/O实现Posix消息队列 85
5.9 小结 101
习题 101
第6章 System V消息队列 103
6.1 概述 103
6.2 msgget函数 104
6.3 msgsnd函数 104
6.4 msgrcv函数 105
6.5 msgctl函数 106
6.6 简单的程序 107
6.7 客户-服务器例子 112
6.8 复用消息 113
6.9 消息队列上使用select和poll 121
6.10 消息队列限制 122
6.11 小结 124
习题 124
第三部分 同步
第7章 互斥锁和条件变量 126
7.1 概述 126
7.2 互斥锁:上锁与解锁 126
7.3 生产者-消费者问题 127
7.4 对比上锁与等待 131
7.5 条件变量:等待与信号发送 132
7.6 条件变量:定时等待和广播 136
7.7 互斥锁和条件变量的属性 136
7.8 小结 139
习题 139
第8章 读写锁 140
8.1 概述 140
8.2 获取与释放读写锁 140
8.3 读写锁属性 141
8.4 使用互斥锁和条件变量实现读写锁 142
8.5 线程取消 148
8.6 小结 153
习题 153
第9章 记录上锁 154
9.1 概述 154
9.2 对比记录上锁与文件上锁 157
9.3 Posix fcntl记录上锁 158
9.4 劝告性上锁 162
9.5 强制性上锁 164
9.6 读出者和写入者的优先级 166
9.7 启动一个守护进程的唯一副本 170
9.8 文件作锁用 171
9.9 NFS上锁 173
9.10 小结 173
习题 174
第10章 Posix信号量 175
10.1 概述 175
10.2 sem_open、sem_close和sem_
unlink函数 179
10.3 sem_wait和sem_trywait函数 180
10.4 sem_post和sem_getvalue函数 180
10.5 简单的程序 181
10.6 生产者-消费者问题 186
10.7 文件上锁 190
10.8 sem_init和sem_destroy函数 191
10.9 多个生产者,单个消费者 193
10.10 多个生产者,多个消费者 19
UNIX网络编程 卷1:套接字联网API
第一部分 简介和TCP/IP
第1章 简介
第2章 传输层:TCP、UDP和SCTP
第二部分 基本套接字编程
第3章 套接字编程简介
第4章 基本TCP套接字编程
第5章 TCP客户/服务器程序示例
第6章 I/O复用:select和poll函数
第7章 套接字选项
第8章 基本UDP套接字编程
第9章 基本SCTP套接字编程
第10章 SCTP客户/服务器程序例子
第11章 名字与地址转换
第三部分 高级套接字编程
第12章 IPv4与IPv6的互操作性
第13章 守护进程和inetd超级服务器
第14章 高级I/O函数
第15章 Unix域协议
第16章 非阻塞式I/O
第17章 ioctl操作
第18章 路由套接字
第19章 密钥管理套接字
第20章 广播
第21章 多播
第22章 高级UDP套接字编程
第23章 高级SCTP套接字编程
第24章 带外数据
第25章 信号驱动式I/O
第26章 线程
第27章 IP选项
第28章 原始套接字
第29章 数据链路访问
第30章 客户/服务器程序设计范式
第31章 流
附录A IPv4、IPv6、ICMPv4和ICMPv6
附录B 虚拟网络
附录C 调试技术
附录D 杂凑的源代码
附录E 精选习题答案
参考文献
索引
操作系统设计与实现 第3版 下
第1章 引言
1.1 什么是操作系统
1.2 操作系统的发展历史
1.3 操作系统概念
1.4 系统调用
1.5 操作系统结构
1.6 剩余各章内容简介
1.7 小结
习题
第2章 进程
2.1 进程介绍
2.2 进程间通信
2.3 经典IPC问题
2.4 进程调度
2.5 MINIX3进程概述
2.6 MINIX3中进程的实现
2.7 MINIX3的系统任务
2.8 MINIX3的时钟任务
2.9 小结
习题
第3章 输入/输出系统
3.1 I/O硬件原理
3.2 I/O软件原理
3.3 死锁
3.4 MINIX3中的I/O概述
3.5 MINIX3中的块设备
3.6 RAM盘
3.7 磁盘
3.8 终端
3.9 小结
习题
第4章 存储管理
4.1 基本的存储管理
4.2 交换技术
4.3 虚拟存储管理
4.4 页面置换算法
4.5 页式存储管理中的设计问题
4.6 段式存储管理
4.7 MINIX3进程管理器概述
4.8 MINIX3进程管理器的实现
4.9 小结
习题
第5章 文件系统
5.1 文件
5.2 目录
5.3 文件系统的实现
5.4 文件系统的安全性
5.5 保护机制
5.6 MINIX3文件系统概述
5.7 MINIX3文件系统的实现
5.8 小结
习题
第6章 阅读材料和参考文献
6.1 推荐的进一步阅读材料
6.2 按字母顺序排列的参考文献
索引
操作系统设计与实现 第3版 上
第1章 引言
1.1 什么是操作系统
1.2 操作系统的发展历史
1.3 操作系统概念
1.4 系统调用
1.5 操作系统结构
1.6 剩余各章内容简介
1.7 小结
习题
第2章 进程
2.1 进程介绍
2.2 进程间通信
2.3 经典IPC问题
2.4 进程调度
2.5 MINIX3进程概述
2.6 MINIX3中进程的实现
2.7 MINIX3的系统任务
2.8 MINIX3的时钟任务
2.9 小结
习题
第3章 输入/输出系统
3.1 I/O硬件原理
3.2 I/O软件原理
3.3 死锁
3.4 MINIX3中的I/O概述
3.5 MINIX3中的块设备
3.6 RAM盘
3.7 磁盘
3.8 终端
3.9 小结
习题
第4章 存储管理
4.1 基本的存储管理
4.2 交换技术
4.3 虚拟存储管理
4.4 页面置换算法
4.5 页式存储管理中的设计问题
4.6 段式存储管理
4.7 MINIX3进程管理器概述
4.8 MINIX3进程管理器的实现
4.9 小结
习题
第5章 文件系统
5.1 文件
5.2 目录
5.3 文件系统的实现
5.4 文件系统的安全性
5.5 保护机制
5.6 MINIX3文件系统概述
5.7 MINIX3文件系统的实现
5.8 小结
习题
第6章 阅读材料和参考文献
6.1 推荐的进一步阅读材料
6.2 按字母顺序排列的参考文献
索引
深入解析Windows操作系统(Microsoft.Windows.Internals)中文第四版
第一章 概念和工具
第二章 系统结构
第三章 系统机制
第四章 管理机制
第五章 启动和停机
第六章 进程、线程和作业
第七章 内存管理
第八章 安全性
第九章 I/O系统
第十章 存储管理
第十一章 缓存管理器
第十二章 文件系统
第十三章 网络
第十四章 崩溃转储分析
深入理解Linux内核(完整版)中文版
前言
第一章绪论
Linux与其他类Unix内核的比较
硬件的依赖性
Linux版本
操作系统基本概念
Unix文件系统概述
Unix内核概述
第二章内存寻址
内存地址
硬件中的分段
Linux中的分段
硬件中的分页
Linux中的分页
第三章进程
进程、轻量级进程和线程
进程描述符
进程切换
创建进程
撤消进程
第四章中断和异常
中断信号的作用
中断和异常
中断和异常处理程序的嵌套执行
初始化中断描述符表
异常处理
中断处理
软中断及tasklet
工作队列
从中断和异常返回
第五章内核同步
内核如何为不同的请求提供服务
同步原语
对内核数据结构的同步访问
避免竞争条件的实例
第六章定时测量
时钟和定时器电路
Linux计时体系结构
更新时间和日期
更新系统统计数
软定时器和延迟函数
与定时测量相关的系统调用
第七章进程调度
调度策略
调度算法
调度程序所使用的数据结构
调度程序所使用的函数
多处理器系统中运行队列的平衡
与调度相关的系统调用
第八章内存管理
页框管理
内存区管理
非连续内存区管理
第九章进程地址空间
进程的地址空间
内存描述符
线性区
缺页异常处理程序
创建和删除进程的地址空间
堆的管理
第十章系统调用
POSIXAPI和系统调用
系统调用处理程序及服务例程
进入和退出系统调用
参数传递
内核封装例程
第十一章信号
信号的作用
产生信号
传递信号
与信号处理相关的系统调用
第十二章虚拟文件系统
虚拟文件系统(VFS)的作用
VFS的数据结构
文件系统类型
文件系统处理
路径名查找
VFS系统调用的实现
文件加锁
第十三章I/O体系结构和设备驱动程序
I/O体系结构
设备驱动程序模型
设备文件
设备驱动程序
字符设备驱动程序
第十四章块设备驱动程序
块设备的处理
通用块层
I/O调度程序
块设备驱动程序
打开块设备文件
第十五章页高速缓存
页高速缓存
把块存放在页高速缓存中
把脏页写入磁盘
sync()、fsync()和fdatasync()系统调用
第十六章访问文件
读写文件
内存映射
直接I/O传送
异步I/O
第十七章回收页框
页框回收算法
反向映射
PFRA实现
交换
第十八章Ext2和Ext3文件系统
Ext2的一般特征
Ext2磁盘数据结构
Ext2的内存数据结构
创建Ext2文件系统
Ext2的方法
管理Ext2磁盘空间
Ext3文件系统
第十九章进程通信
管道
FIFO
SystemVIPC
POSIX消息队列
第二十章程序的执行
可执行文件
可执行格式
执行域
exec函数
附录一系统启动
附录二模块
参考文献
源代码索引
深入理解linux内核中文第三版
前言
第一章绪论
第二章内存寻址
第三章进程
第四章中断和异常
第五章内核同步
第六章定时测量
第七章进程调度
第八章内存管理
第九章进程地址空间
第十章系统调用
第十一章信号
第十二章虚拟文件系统
第十三章I/O体系结构和设备驱动程序
第十四章块设备驱动程序
第十五章页调高速缓存
第十六章访问文件
第十七章回收页框
第十八章Ext2和Ext3文件系统
第十九章进程通信
第二十章程序的执行
附录一系统启动
附录二模块
参考文献
源代码索引
推荐系统实践
第1章 好的推荐系统 1
1.1 什么是推荐系统 1
1.2 个性化推荐系统的应用 4
1.2.1 电子商务 4
1.2.2 电影和视频网站 8
1.2.3 个性化音乐网络电台 10
1.2.4 社交网络 12
1.2.5 个性化阅读 15
1.2.6 基于位置的服务 16
1.2.7 个性化邮件 17
1.2.8 个性化广告 18
1.3 推荐系统评测 19
1.3.1 推荐系统实验方法 20
1.3.2 评测指标 23
1.3.3 评测维度 34
第2章 利用用户行为数据 35
2.1 用户行为数据简介 36
2.2 用户行为分析 39
2.2.1 用户活跃度和物品流行度的分布 39
2.2.2 用户活跃度和物品流行度的关系 41
2.3 实验设计和算法评测 41
2.3.1 数据集 42
2.3.2 实验设计 42
2.3.3 评测指标 42
2.4 基于邻域的算法 44
2.4.1 基于用户的协同过滤算法 44
2.4.2 基于物品的协同过滤算法 51
2.4.3 UserCF和ItemCF的综合比较 59
2.5 隐语义模型 64
2.5.1 基础算法 64
2.5.2 基于LFM的实际系统的例子 70
2.5.3 LFM和基于邻域的方法的比较 72
2.6 基于图的模型 73
2.6.1 用户行为数据的二分图表示 73
2.6.2 基于图的推荐算法 73
第3章 推荐系统冷启动问题 78
3.1 冷启动问题简介 78
3.2 利用用户注册信息 79
3.3 选择合适的物品启动用户的兴趣 85
3.4 利用物品的内容信息 89
3.5 发挥专家的作用 94
第4章 利用用户标签数据 96
4.1 UGC标签系统的代表应用 97
4.1.1 Delicious 97
4.1.2 CiteULike 98
4.1.3 Last,fm 98
4.1.4 豆瓣 99
4.1.5 Hulu 99
4.2 标签系统中的推荐问题 100
4.2.1 用户为什么进行标注 100
4.2.2 用户如何打标签 101
4.2.3 用户打什么样的标签 102
4.3 基于标签的推荐系统 103
4.3.1 实验设置 104
4.3.2 一个最简单的算法 105
4.3.3 算法的改进 107
4.3.4 基于图的推荐算法 110
4.3.5 基于标签的推荐解释 112
4.4 给用户推荐标签 115
4.4.1 为什么要给用户推荐标签 115
4.4.2 如何给用户推荐标签 115
4.4.3 实验设置 116
4.4.4 基于图的标签推荐算法 119
4.5 扩展阅读 119
第5章 利用上下文信息 121
5.1 时间上下文信息 122
5.1.1 时间效应简介 122
5.1.2 时间效应举例 123
5.1.3 系统时间特性的分析 125
5.1.4 推荐系统的实时性 127
5.1.5 推荐算法的时间多样性 128
5.1.6 时间上下文推荐算法 130
5.1.7 时间段图模型 134
5.1.8 离线实验 136
5.2 地点上下文信息 139
5.3 扩展阅读 143
第6章 利用社交网络数据 144
6.1 获取社交网络数据的途径 144
6.1.1 电子邮件 145
6.1.2 用户注册信息 146
6.1.3 用户的位置数据 146
6.1.4 论坛和讨论组 146
6.1.5 即时聊天工具 147
6.1.6 社交网站 147
6.2 社交网络数据简介 148社交网络数据中的长尾分布 149
6.3 基于社交网络的推荐 150
6.3.1 基于邻域的社会化推荐算法 151
6.3.2 基于图的社会化推荐算法 152
6.3.3 实际系统中的社会化推荐算法 153
6.3.4 社会化推荐系统和协同过滤推荐系统 155
6.3.5 信息流推荐 156
6.4 给用户推荐好友 159
6.4.1 基于内容的匹配 161
6.4.2 基于共同兴趣的好友推荐 161
6.4.3 基于社交网络图的好友推荐 161
6.4.4 基于用户调查的好友推荐算法对比 164
6.5 扩展阅读 165
第7章 推荐系统实例 166
7.1 外围架构 166
7.2 推荐系统架构 167
7.3 推荐引擎的架构 171
7.3.1 生成用户特征向量 172
7.3.2 特征?物品相关推荐 173
7.3.3 过滤模块 174
7.3.4 排名模块 174
7.4 扩展阅读 178
第8章 评分预测问题 179
8.1 离线实验方法 180
8.2 评分预测算法 180
8.2.1 平均值 180
8.2.2 基于邻域的方法 184
8.2.3 隐语义模型与矩阵分解模型 186
8.2.4 加入时间信息 192
8.2.5 模型融合 193
8.2.6 Netflix Prize的相关实验结果 195
后记 196[1]
人工神经网络实用教程
目录
前言
第1章 人工神经网络概述
1.1 神经网络的基本概念
1.1.1 生物神经元的结构与功能特点
1.1.2 人工神经元模型
1.1.3 神经网络的结构及工作方式
1.1.4 神经网络的学习
1.2 神经网络的特点及其应用
1.2.1 神经网络的特点
1.2.2 神经网络的应用领域
练习题
第2章 实用神经网络模型与学习算法
2.1 MATLAB快速入门
2.1.1 MATLAB界面组成
2.1.2 MATLAB基本运算
2.1.3 MATLAB绘图函数
2.2 感知器神经网络模型与学习算法
2.2.1 单层感知器
2.2.2 单层感知器的学习算法
2.2.3 单层感知器的MATLAB实现
2.2.4 多层感知器
2.3 线性神经网络模型与学习算法
2.3.1 线性神经元网络模型
2.3.2 线性神经网络的学习算法
2.3.3 线性神经网络的MATLAB实现
2.4 BP神经网络模型与学习算法
2.4.1 BP神经网络模型
2.4.2 BP网络的标准学习算法
2.4.3 BP神经网络学习算法的MATLAB实现
2.5 径向基函数神经网络模型与学习算法
2.5.1 RBF神经网络模型
2.5.2 RBF网络的学习算法
2.5.3 RBF网络学习算法的MATLAB实现
2.6 自组织神经网络模型与学习算法
2.6.1 自组织特征映射神经网络结构
2.6.2 自组织特征映射网络的学习算法
2.6.3 自组织网络学习算法的MATLAB实现
2.7 学习向量量化(LVQ)神经网络模型与学习算法
2.7.1 LVQ神经网络结构
2.7.2 LVQ神经网络的学习算法
2.7.3 LVQ神经网络学习算法的MATLAB实现
2.8 Elman神经网络算法模型与学习算法
2.8.1 Elman神经网络结构
2.8.2 Elman神经网络学习算法
2.8.3 Elman神经网络学习算法的MATLAB实现
2.9 Hopfield神经网络模型与学习算法
2.9.1 离散Hopfield神经网络
2.9.2 连续Hopfield神经网络
2.9.3 Hopfield神经网络的MATLAB实现
2.10 Boltzmann神经网络模型与学习算法
2.10.1 Boltzmann机的网络结构
2.10.2 Boltzmann机学习算法
2.11 模糊神经网络
2.11.1 模糊神经网络主要形式
2.11.2 模糊神经网络模型
2.11.3 模糊神经网络学习方法
2.11.4 模糊逻辑MATLAB函数
练习题
第3章 神经网络优化方法
3.1 BP网络学习算法的改进
3.1.1 消除样本输入顺序影响的改进算法
3.1.2 附加动量的改进算法
3.1.3 采用自适应调整参数的改进算法
……
第4章 nnToolKit神经网络工具包
第5章 MATLAB混合编程技术
第6章 混合编程案例
附录 2NDN神经网络建模仿真工具
参考文献
精通MATLAB神经网络.朱凯,王正林.高清
第一篇 MATLAB入门篇
第1章 MATLAB概述
1.1 MATLAB的产生与发展
1.2 MATLAB的优势与特点
1.3 MATLAB系统的构成
1.4 MATLAB桌面操作环境
1.4.1 MATLAB启动和退出
1.4.2 MATLAB主菜单及功能
1.4.3 MATLAB命令窗口
1.4.4 MATLAB工作空间
1.4.5 M文件编辑/调试器
1.4.6 图形窗口
1.4.7 MATLAB文件管理
1.4.8 MATLAB帮助
1.5 MATLAB的工具箱
1.6 小结
第2章 MATLAB计算基础
2.1 MATLAB数值类型
2.2 关系运算和逻辑运算
2.3 矩阵及其运算
2.3.1 矩阵的创建
2.3.2 矩阵的运算
2.4 复数及其运算
2.4.1 复数表示
2.4.2 复数绘图
2.4.3 复数操作函数
2.5 符号运算
2.5.1 符号运算概述
2.5.2 常用的符号运算
2.6 小结
第3章 MATLAB绘图入门
3.1 MATLAB中绘图的基本步骤
3.2 在工作空间直接绘图
3.3 利用绘图函数绘图
3.3.1 二维图形
3.3.2 三维图形
3.4 图形的修饰
3.5 小结
第4章 MATLAB编程入门
4.1 MATLAB编程概述
4.2 MATLAB程序设计原则
4.3 M文件
4.4 MATLAB程序流程控制
4.5 MATLAB中的函数及调用
4.5.1 函数类型
4.5.2 函数参数传递
4.6 函数句柄
4.7 MATLAB程序调试
4.7.1 常见程序错误
4.7.2 调试方法
4.7.3 调试工具
4.7.4 M文件分析工具
4.7.5 Profiler分析工具
4.8 MATLAB程序设计技巧
4.8.1 嵌套计算
4.8.2 循环计算
4.8.3 使用例外处理机制
4.8.4 使用全局变量
4.8.5 通过varargin传递参数
4.9 小结
第5章 Simulink仿真入门
5.1 Simulink仿真概述
5.1.1 Simulink的启动与退出
5.1.2 Simulink模块库
5.2 Simulink仿真模型及仿真过程
5.3 Simulink模块的处理
5.3.1 Simulink模块参数设置
5.3.2 Simulink模块基本操作
5.3.3 Simulink模块连接
5.4 Simulink仿真设置
5.4.1 仿真器参数设置
5.4.2 工作空间数据导入/导出
5.4.2 设置
5.5 Simulink仿真举例
5.6 小结
第二篇 神经网络提高篇
第6章 MATLAB神经网络工具箱概述
第7章 MATLAB神经网络GUI工具
第8章 感知器神经网络
第9章 线性神经网络
第10章 BP神经网络
第11章 径向基神经网络
第12章 自组织神经网络
第13章 反馈神经网络
第三篇 神经网络综合实战篇
第14章 神经网络优化
第15章 神经网络控制
第16章 神经网络故障诊断
第17章 神经网络预测
第18章 Simulink中的神经网络设计
第19章 自定义神经网络
附录A 工具箱函数列表
参考文献
MATLAB神经网络30个案例分析源码
《MATLAB神经网络30个案例分析》一书源码!
MATLAB神经网络30个案例分析
第1章 P神经网络的数据分类——语音特征信号分类
第2章 BP神经网络的非线性系统建模——非线性函数拟合
第3章 遗传算法优化BP神经网络——非线性函数拟合
第4章 神经网络遗传算法函数极值寻优——非线性函数极值寻优
第5章 基于BP_Adaboost的强分类器设计——公司财务预警建模
第6章 PID神经元网络解耦控制算法——多变量系统控制
第7章 RBF网络的回归——非线性函数回归的实现
第8章 GRNN的数据预测——基于广义回归神经网络的货运量预测
第9章 离散Hopfield神经网络的联想记忆——数字识别
第10章 离散Hopfield神经网络的分类——高校科研能力评价
第11章 连续Hopfield神经网络的优化——旅行商问题优化计算
第12章 SVM的数据分类预测——意大利葡萄酒种类识别
第13章 SVM的参数优化——如何更好的提升分类器的性能
第14章 SVM的回归预测分析——上证指数开盘指数预测
第15章 SVM的信息粒化时序回归预测——上证指数开盘指数变化趋势和变化空间预测
第16章 自组织竞争网络在模式分类中的应用——患者癌症发病预测
第17章SOM神经网络的数据分类——柴油机故障诊断
第18章Elman神经网络的数据预测——电力负荷预测模型研究
第19章 概率神经网络的分类预测——基于PNN的变压器故障诊断
第20章 神经网络变量筛选——基于BP的神经网络变量筛选
第21章 LVQ神经网络的分类——乳腺肿瘤诊断
第22章 LVQ神经网络的预测——人脸朝向识别
第23章 小波神经网络的时间序列预测——短时交通流量预测
第24章 模糊神经网络的预测算法——嘉陵江水质评价
第25章 广义神经网络的聚类算法——网络入侵聚类
第26章 粒子群优化算法的寻优算法——非线性函数极值寻优
第27章 遗传算法优化计算——建模自变量降维
第28章 基于灰色神经网络的预测算法研究——订单需求预测
第29章 基于Kohonen网络的聚类算法——网络入侵聚类
第30章 神经网络GUI的实现——基于GUI的神经网络拟合、模式识别、聚类
神经网络理论与MATLAB7实现
第1章 概述
1.1 MATLAB语言简介
1.1.1 MATLAB概述
1.1.2 MATLAB语言特点
1.1.3 MATLAB 7的安装
1.1.4 MATLAB 7的新特点
1.1.5 MATLAB 7的新产品及更新产品
1.1.6 Simulink 6.0的新特点
1.2 MATLAB快速入门
1.2.1 命令行窗口
1.2.2 其他重要窗口
1.2.3 Editor/Debugger窗口
1.2.4 MATLAB帮助系统
1.2.5 神经网络工具箱快速入门
1.3 神经网络发展史
1.3.1 初期阶段
1.3.2 停滞期
1.3.3 黄金时期
1.3.4 发展展望
1.4 神经网络模型
1.4.1 神经元结构模型
1.4.2 神经网络的互连模式
1.5 神经网络的特性及实现
1.6 小结
第2章 神经网络工具箱函数及实例
2.1 概述
2.2 神经网络工具箱中的通用函数
2.2.1 神经网络仿真函数sim
2.2.2 神经网络训练及学习函数
2.2.3 神经网络初始化函数
2.2.4 神经网络输入函数
2.2.5 神经网络传递函数
2.2.6 其他重要函数
2.3 感知器的神经网络工具箱函数
2.3.1 感知器创建函数
2.3.2 显示函数
2.3.3 性能函数
2.4 BP网络的神经网络工具箱函数
2.4.1 BP网络创建函数
2.4.2 神经元上的传递函数
2.4.3 BP网络学习函数
2.4.4 BP网络训练函数
2.4.5 性能函数
2.4.6 显示函数
2.5 线性网络的神经网络工具箱函数
2.5.1 线性网络创建和设计函数
2.5.2 学习函数
2.6 自组织竞争网络的神经网络工具箱函数
2.6.1 神经网络创建函数
2.6.2 传递函数
2.6.3 距离函数
2.6.4 学习函数
2.6.5 初始化函数
2.6.6 权值函数
2.6.7 显示函数
2.6.8 结构函数
2.7 径向基网络的神经网络工具箱函数
2.7.1 神经网络创建函数
2.7.2 转换函数
2.7.3 传递函数
2.8 反馈网络的神经网络工具箱函数
2.8.1 Hopfield网络的工具箱函数
2.8.2 Elman网络的工具箱函数
2.9 小结
第3章 前向型神经网络理论及MATLAB实现
3.1 感知器网络及MATLAB实现
3.1.1 单层感知器网络
3.1.2 多层感知器
3.2 BP网络及MATLAB实现
3.2.1 BP网络理论
3.2.2 BP网络的MATLAB设计
3.3 线性神经网络及MATLAB实现
3.3.1 线性神经网络的结构
3.3.2 线性神经网络的学习
3.3.3 线性网络的MATLAB仿真
3.4 径向基函数网络及MATLAB实现
3.4.1 径向基网络结构
3.4.2 径向基函数的学习过程
3.4.3 RBF网络应用实例
3.4.4 基于RBF网络的非线性滤波
3.4.5 基于GRNN的函数逼近
3.4.6 基于概率神经网络的分类
3.5 GMDH网络及MATLAB实现
3.5.1 GMDH网络理论
3.5.2 GMDH网络的训练
3.5.3 基于GMDH网络的预测
3.6 小结
第4章 反馈型神经网络理论及MATLAB实现
4.1 Elman神经网络及应用
4.1.1 Elman神经网络结构
4.1.2 Elman神经网络的学习过程
4.1.3 Elman神经网络的工程应用
4.1.4 基于Elman网络的空调负荷预测
4.2 Hopfield神经网络及MATLAB实现
4.2.1 Hopfield网络描述
4.2.2 Hopfield网络的学习过程
4.2.3 几个重要结论
4.2.4 Hopfield网络的MATLAB开发
4.2.5 基于Hopfield网络的数字识别
4.3 CG网络模型及应用
4.3.1 CG神经网络理论
4.3.2 基于CG网络的有限元分析
4.4 盒中脑(BSB)模型及MATLAB实现
4.4.1 BSB神经网络模型描述
4.4.2 BSB的MATLAB实现
4.5 双向联想记忆(BAM)及MATLAB实现
4.5.1 Kosko型BAM网络模型
4.5.2 BAM网络的实例分析
4.6 回归BP网络及应用
4.6.1 回归BP网络概述
4.6.2 基于回归BP网络的房价预测
4.7 Boltzmann机网络及仿真
4.7.1 BM网络的基本结构
4.7.2 BM模型的工作规则和学习规则
4.7.3 BM网络的MATLAB仿真
4.8 小结
第5章 自组织与LVQ神经网络
人工神经网络导论
目录
第一章 引言
1.1 人工神经网络的提出
1.1.1 智能与人工智能
1.1.2 物理符号系统
1.1.3 联接主义观点
1.1.4 两种模型的比较
1.2 人工神经网络的特点
1.2.1 人工神经网络的概念
1.2.2 学习能力
1.2.3 基本特征的自动提取
1.2.4 信息的分布存放
1.2.5 适用性问题
1.3 历史回顾
1.3.1 萌芽期
1.3.2 第一高潮期
1.3.3 反思期
1.3.4 第二高潮期
1.3.5 再认识与应用研究期
练习题
第二章 人工神经网络基础
2.1 生物神经网络
2.2 人工神经元
2.2.1 人工神经元的基本构成
2.2.2 激活函数(ActivationFunction)
2.2.3 M-P模型
2.3 A.工神经网络的拓扑特性
2.3.1 联接模式
2.3.2 网络的分层结构
2.4 存储与映射
2.5 人工神经网络的训练。
2.5.1 无导师学习
2.5.2 有导师学习
练习题
第三章 感知器
3.1 感知器与人工神经网络的早期发展
3.2 感知器的学习算法
3.2.1 离散单输出感知器训练算法
3.2.2 离散多输出感知器训练算法
3.2.3 连续多输出感知器训练算法
3.3 线性不可分问题
3.3.1 异或(Exclusive-0R)问题
3.3.2 线性不可分问题的克服
练习题
第四章 BP网络
4.1 概述
4.2 基本BP算法
4.2.1 网络的构成
4.2.2 训练过程概述
4.2.3 误差传播分析
4.2.4 基本的BP算法
4.3 算法的改进
4.4 算法的实现
4.5 算法的理论基础
4.6 几个问题的讨论
练习题
第五章 对传网
5.1 网络结构
5.2 网络的正常运行
5.2.1 Kohonen层
5.2.2 Grossberg层
5.3 Kohonen层的训练
5.3.1 输入向量的预处理
5.3.2 训练
5.4 Kohonen层联接权的初始化方法
5.5 Grossberg层的训练
5.6 补充说明
练习题
第六章 非确定方法
6.1 基本的非确定训练算法
6.2 模拟退火算法
6.3 Cauchy训练
6.4 相关的几个问题
练习题一
第七章 循环网络
7.1 循环网络的组织
7.2 稳定性分析
7.3 统计Hopfield网与Boltzmann机
7.4 双联存储器的结构
7.5 异相联存储
7.6 其他的双联存储器
7.7 Hopfield网用于解决TSP问题
练习题
第八章 自适应共振理论
8.1 ART的结构
8.2 ART的初始化
8.2.1 T的初始化
8.2.2 B的初始化
8.2.3 p的初始化
8.3 ART的实现
练习题
参考文献
神经网络原理
第1章 导言
第2章 学习过程
第3章 单层感知器
第4章 多层感知器
第5章 径向基函数网络
第6章 支持向量机
第7章 委员会机器
第8章 主分量分析
第9章 自组织映射
第10章 信息论模型
第11章 植根于统计力学的随机机器和它们的逼近
第12章 神经动态规划
第13章 使用前馈网络的时序处理
第14章 神经动力学
第15章 动态驱动的递归网络
后记
参考文献
索引
神经网络设计
第1章 绪论
1.1 目的
1.2 历史
1.3 应用
1.4 生物学的启示
参考文献
第2章 神经元模型和网络结构
2.1 目的
2.1 理论和实例
2.2.1 符号
2.2.2 神经元模型
2.2.3 网络结构
2.3 小结
2.4 例题
2.5 结束语
习题
第3章 一个说明性实例
3.1 目的
3.2 理论和实例
3.2.1 问题描述
.3.2.2 感知机
3.2.3 hamming网络
3.2.4 hopfield网络
3.3 结束语
习题
第4章 感知机学习规则
4.1 目的
4. 2 理论和实例
4.2.1 学习规则
4.2.2 感知机的结构
4.2.3 感知机学习规则
4.2.4 收敛性证明
4.3 小结
4.4 例题
4.5 结束语
参考文献
习题
第5章 信号和权值向量空间
5.1 目的
5.2 理论和实例
5.2.1 线性向量空间
5.2.2 线性无关
5.2.3 生成空间
5.2.4 内积
5.2.5 范数
5.2.6 正交性
5.2.7 向量展开式
5.3 小结
5.4 例题
5.5 结束语
参考文献
习题
第6章 神经网络中的线性变换
6. 1 目的
6.2 理论和实例
6.2.1 线性变换
6.2.2 矩阵表示
6.2. 3 基变换
6.2. 4 特征值和特征向量
6.3 小结
6.4 例题
6.5 结束语
参考文献
习题
第7章 有监督的hebb学习
7.1 目的
7.2 理论和实例
7.2.1 线性联想器
7.2.2 hebb规则
7.2.3 仿逆规则
7.2.4 应用
7.2.5 hebb学习的变形
7.3 小结
7.4 例题
7.5 结束语
参考文献
习题
第8章 性能曲面和最优点
8.1 目的
8.2 理论和实例
8.2.1 泰勒级数
8.2.2 方向导数
8.2.3 极小点
8.2.4 优化的必要条件
8.2.5 二次函数
8.3 小结
8.4 例题
8.5 结束语
参考文献
习题
第9章 性能优化
9.1 目的
9.2 理论和实例
9.2.1 最速下降法
9.2.2 牛顿法
9.2.3 共扼梯度法
9.3 小结
9.4 例题
9.5 结束语
参考文献
习题
第10章 widrow-hoff学习算法
10.1 目的
10.2 理论和实例
10.2.1 adaline网络
10.2.2 均方误差
10.2.3 lms算法
10.2.4 收敛性分析
10.2.5 自适应滤波
10.3 小结
10.4 例题
10.5 结束语
参考文献
习题
第11章 反向传播
11.1 目的
11.2 理论和实例
11.2.1 多层感知机
11.2.2 反向传播算法
11.2.3 例子
11.2.4 反向传播
11.3 小结
11.4 例题
11.5 结束语
参考文献
习题
第12章 反向传播算法的变形
12.1 目的
12.2 理论和实例
12.2.1 bp算法的缺点
12.2.2 bp算法的启发式改进
12.2.3 数值优化技术
12.3 小结
12.4 例题
12.5 结束语
参考文献
习题
第13章 联想学习
13.1 目的
13.2 理论和实例
13.2.1 简单联想网络
13.2.2 无监督的hebb规则
13.2.3 简单的识别网络
13.2.4 instar规则
13.2.5 简单回忆网络
13.2.6 outstar规则
13.3 小结
13.4 例题
13.5 结束语
参考文献
习题
第14章 竞争网络
14.1 目的
14.2 理论和实例
14.2.1 hamming网络
14.2.2 竞争层
14.2.3 生物学意义上的竞争层
14.2.4 自组织特征图
14.2.5 学习向量量化
14.3 小结
14.4 例题
14.5 结束语
参考文献
习题
第15章 grossberg网络
15.1 目的
15.2 理论和实例
15. 2.1 生物学的启发:视觉
15.2.2 基本非线性模型
15.2.3 两层竞争网络
15.2.4 与kohonen规则的关系
15.3 小结
15.4 例题
15.5 结束语
参考文献
习题
第16章 自适应谐振理论
16.1 目的
16. 2 理论和实例
16.2.1 自适应谐振概述
16.2.2 第一层
16.2.3 第二层
16.2.4 调整子系统
16.2.5 学习规则:l1-l2
16.2.6 学习规则:l2-l1
16.2.7 art1算法小结
16.2.8 其他art体系结构
16.3 小结
16.4 例题
16.5 结束语
参考文献
习题
第17章 稳定性
17.1 目的
17.2 理论和实例
17.2.1 递归网络
17.2.2 稳定性概念
17.2.3 lyapunov稳定性定理
17.2.4 单摆例子
17.2.5 lasdlle不变性定理
17.3 小结
17.4 例题
17.5 结束语
参考文献
习题
第18章 hopfield网络
18.1 目的
18.2 理论和实例
18.2.1 hopfield模型
18.2.2 lyapunov函数
18.2.3 增益效应
18.2.4 hopfield网络设计
18.3 小结
18. 4 例题
18.5 结束语
参考文献
习题
第19章 结束语
19.1 目的
19.2 理论和实例
19.2.1 前馈和联想网络
19.2.2 竞争网络
19。2.3 动态联想存储器网络
19.2.4 神经网络的经典基础
19.2.5 参考书目和杂志
19.3 结束语
参考文献
附录a 文献目录
附录b 符号
附录c 软件
索引
神经网络与机器学习(原书第3版)
神经网络是计算智能和机器学习的重要分支,在诸多领域都取得了很大的成功。在众多神经网络著作中,影响最为广泛的是Simon Haykin的《神经网络原理》(第3版更名为《神经网络与机器学习》)。在本书中,作者结合近年来神经网络和机器学习的最新进展,从理论和实际应用出发,全面、系统地介绍了神经网络的基本模型、方法和技术,并将神经网络和机器学习有机地结合在一起。
本书不但注重对数学分析方法和理论的探讨,而且也非常关注神经网络在模式识别、信号处理以及控制系统等实际工程问题的应用。本书的可读性非常强,作者举重若轻地对神经网络的基本模型和主要学习理论进行了深入探讨和分析,通过大量的试验报告、例题和习题来帮助读者更好地学习神经网络。
本版在前一版的基础上进行了广泛修订,提供了神经网络和机器学习这两个越来越重要的学科的最新分析。
本书特色:
1. 基于随机梯度下降的在线学习算法;小规模和大规模学习问题。
2. 核方法,包括支持向量机和表达定理。
3. 信息论学习模型,包括连接、独立分量分析(ICA)、一致独立分量分析和信息瓶颈。
4. 随机动态规划,包括逼近和神经动态规划。
5. 逐次状态估计算法,包括卡尔曼和粒子滤波器。
6. 利用逐次状态估计算法训练递归神经网络。
7. 富有洞察力的面向计算机的试验。
出版者的话
译者序
前言
缩写和符号
术语
第0章 导言1
0.1 什么是神经网络1
0.2 人类大脑4
0.3 神经元模型7
0.4 被看作有向图的神经网络10
0.5 反馈11
0.6 网络结构13
0.7 知识表示14
0.8 学习过程20
0.9 学习任务22
0.10 结束语27
注释和参考文献27
第1章 Rosenblatt感知器28
1.1 引言28
1.2 感知器28
1.3 感知器收敛定理29
1.4 高斯环境下感知器与贝叶斯分类器的关系33
1.5 计算机实验:模式分类36
1.6 批量感知器算法38
1.7 小结和讨论39
注释和参考文献39
习题40
第2章 通过回归建立模型28
2.1 引言41
2.2 线性回归模型:初步考虑41
2.3 参数向量的最大后验估计42
2.4 正则最小二乘估计和MAP估计之间的关系46
2.5 计算机实验:模式分类47
2.6 最小描述长度原则48
2.7 固定样本大小考虑50
2.8 工具变量方法53
2.9 小结和讨论54
注释和参考文献54
习题55
第3章 最小均方算法56
3.1 引言56
3.2 LMS算法的滤波结构56
3.3 无约束最优化:回顾58
3.4 维纳滤波器61
3.5 最小均方算法63
3.6 用马尔可夫模型来描画LMS算法和维纳滤波器的偏差64
3.7 朗之万方程:布朗运动的特点65
3.8 Kushner直接平均法66
3.9 小学习率参数下统计LMS学习理论67
3.10 计算机实验Ⅰ:线性预测68
3.11 计算机实验Ⅱ:模式分类69
3.12 LMS算法的优点和局限71
3.13 学习率退火方案72
3.14 小结和讨论73
注释和参考文献74
习题74
第4章 多层感知器77
4.1 引言77
4.2 一些预备知识78
4.3 批量学习和在线学习79
4.4 反向传播算法81
4.5 异或问题89
4.6 改善反向传播算法性能的试探法90
4.7 计算机实验:模式分类94
4.8 反向传播和微分95
4.9 Hessian矩阵及其在在线学习中的规则96
4.10 学习率的最优退火和自适应控制98
4.11 泛化102
4.12 函数逼近104
4.13 交叉验证107
4.14 复杂度正则化和网络修剪109
4.15 反向传播学习的优点和局限113
4.16 作为最优化问题看待的监督学习117
4.17 卷积网络126
4.18 非线性滤波127
4.19 小规模和大规模学习问题131
4.20 小结和讨论136
注释和参考文献137
习题138
第5章 核方法和径向基函数网络144
5.1 引言144
5.2 模式可分性的Cover定理144
5.3 插值问题148
5.4 径向基函数网络150
5.5 K-均值聚类152
5.6 权向量的递归最小二乘估计153
5.7 RBF网络的混合学习过程156
5.8 计算机实验:模式分类157
5.9 高斯隐藏单元的解释158
5.10 核回归及其与RBF网络的关系160
5.11 小结和讨论162
注释和参考文献164
习题165
第6章 支持向量机168
6.1 引言168
6.2 线性可分模式的最优超平面168
6.3 不可分模式的最优超平面173
6.4 使用核方法的支持向量机176
6.5 支持向量机的设计178
6.6 XOR问题179
6.7 计算机实验:模式分类181
6.8 回归:鲁棒性考虑184
6.9 线性回归问题的最优化解184
6.10 表示定理和相关问题187
6.11 小结和讨论191
注释和参考文献192
习题193
第7章 正则化理论197
7.1 引言197
7.2 良态问题的Hadamard条件198
7.3 Tikhonov正则化理论198
7.4 正则化网络205
7.5 广义径向基函数网络206
7.6 再论正则化最小二乘估计209
7.7 对正则化的附加要点211
7.8 正则化参数估计212
7.9 半监督学习215
7.10 流形正则化:初步的考虑216
7.11 可微流形217
7.12 广义正则化理论220
7.13 光谱图理论221
7.14 广义表示定理222
7.15 拉普拉斯正则化最小二乘算法223
7.16 用半监督学习对模式分类的实验225
7.17 小结和讨论227
注释和参考文献228
习题229
第8章 主分量分析232
8.1 引言232
8.2 自组织原则232
8.3 自组织的特征分析235
8.4 主分量分析:扰动理论235
8.5 基于Hebb的最大特征滤波器241
8.6 基于Hebb的主分量分析247
8.7 计算机实验:图像编码251
8.8 核主分量分析252
8.9 自然图像编码中的基本问题256
8.10 核Hebb算法257
8.11 小结和讨论260
注释和参考文献262
习题264
第9章 自组织映射268
9.1 引言268
9.2 两个基本的特征映射模型269
9.3 自组织映射270
9.4 特征映射的性质275
9.5 计算机实验Ⅰ:利用SOM解网格动力学问题280
9.6 上下文映射281
9.7 分层向量量化283
9.8 核自组织映射285
9.9 计算机实验Ⅱ:利用核SOM解点阵动力学问题290
9.10 核SOM和相对熵之间的关系291
9.11 小结和讨论293
注释和参考文献294
习题295
第10章 信息论学习模型299
10.1 引言299
10.2 熵300
10.3 最大熵原则302
10.4 互信息304
10.5 相对熵306
10.6 系词308
10.7 互信息作为最优化的目标函数310
10.8 最大互信息原则311
10.9 最大互信息和冗余减少314
10.10 空间相干特征316
10.11 空间非相干特征318
10.12 独立分量分析320
10.13 自然图像的稀疏编码以及与ICA编码的比较324
10.14 独立分量分析的自然梯度学习326
10.15 独立分量分析的最大似然估计332
10.16 盲源分离的最大熵学习334
10.17 独立分量分析的负熵最大化337
10.18 相关独立分量分析342
10.19 速率失真理论和信息瓶颈347
10.20 数据的最优流形表达350
10.21 计算机实验:模式分类354
10.22 小结和讨论354
注释和参考文献356
习题361
第11章 植根于统计力学的随机方法366
11.1 引言366
11.2 统计力学367
11.3 马尔可夫链368
11.4 Metropolis算法374
11.5 模拟退火375
11.6 Gibbs抽样377
11.7 Boltzmann机378
11.8 logistic信度网络382
11.9 深度信度网络383
11.10 确定性退火385
11.11 和EM算法的类比389
11.12 小结和讨论390
注释和参考文献390
习题392
第12章 动态规划396
12.1 引言396
12.2 马尔可夫决策过程397
12.3 Bellman最优准则399
12.4 策略迭代401
12.5 值迭代402
12.6 逼近动态规划:直接法406
12.7 时序差分学习406
12.8 Q学习410
12.9 逼近动态规划:非直接法412
12.10 最小二乘策略评估414
12.11 逼近策略迭代417
12.12 小结和讨论419
注释和参考文献421
习题422
第13章 神经动力学425
13.1 引言425
13.2 动态系统426
13.3 平衡状态的稳定性428
13.4 吸引子432
13.5 神经动态模型433
13.6 作为递归网络范例的吸引子操作435
13.7 Hopfield模型435
13.8 Cohen-Grossberg定理443
13.9 盒中脑状态模型445
13.10 奇异吸引子和混沌448
13.11 混沌过程的动态重构452
13.12 小结和讨论455
注释和参考文献457
习题458
第14章 动态系统状态估计的贝叶斯滤波461
14.1 引言461
14.2 状态空间模型462
14.3 卡尔曼滤波器464
14.4 发散现象及平方根滤波469
14.5 扩展的卡尔曼滤波器474
14.6 贝叶斯滤波器477
14.7 数值积分卡尔曼滤波器:基于卡尔曼滤波器480
14.8 粒子滤波器484
14.9 计算机实验:扩展的卡尔曼滤波器和粒子滤波器对比评价490
14.10 大脑功能建模中的
卡尔曼滤波493
14.11 小结和讨论494
注释和参考文献496
习题497
第15章 动态驱动递归网络501
15.1 引言501
15.2 递归网络体系结构502
15.3 通用逼近定理505
15.4 可控性和可观测性507
15.5 递归网络的计算能力510
15.6 学习算法511
15.7 通过时间的反向传播512
15.8 实时递归学习515
15.9 递归网络的消失梯度519
15.10 利用非线性逐次状态估计的递归网络监督学习框架521
15.11 计算机实验:Mackay-Glass吸引子的动态重构526
15.12 自适应考虑527
15.13 实例学习:应用于神经控制的模型参考529
15.14 小结和讨论530
注释和参考文献533
习题534
参考文献538
OpenCV2计算机视觉编程手册源码
《OpenCV2计算机视觉编程手册》一书源码
OpenCV for Secret Agents
Table of Contents
Preface 1
Chapter 1: Preparing for the Mission 7
Setting up a development machine 8
Windows 10
OpenCV on Windows with binary installers 12
OpenCV on Windows with CMake and compilers 12
Mac 15
Mac with MacPorts 16
Mac with Homebrew 18
Debian Wheezy and its derivatives, including Raspbian,
Ubuntu, and Linux Mint 20
Fedora and its derivatives, including RHEL and CentOS 22
openSUSE and its derivatives 22
Tegra Android Development Pack 23
Building OpenCV Android sample projects with Eclipse 25
Unity 34
Setting up Raspberry Pi 34
Setting up the Raspberry Pi Camera Module 39
Finding OpenCV documentation, help, and updates 40
Alternatives to Raspberry Pi 41
Summary 42
Chapter 2: Searching for Luxury Accommodations Worldwide 43
Planning the Luxocator app 44
Creating, comparing, and storing histograms 45
Training the classifier with reference images 52
Acquiring images from the Web 53
Acquiring images from Bing image search 55
Preparing images and resources for the app 60
Building Luxocator for distribution 71
Summary 74
Chapter 3: Training a Smart Alarm to Recognize the
Villain and His Cat 75
Understanding machine learning in general 77
Planning the Interactive Recognizer app 78
Understanding Haar cascades and LBPH 80
Implementing the Interactive Recognizer app 84
Planning the cat detection model 98
Implementing the training script for the cat detection model 100
Planning the Angora Blue app 114
Implementing the Angora Blue app 115
Building Angora Blue for distribution 122
Further fun with finding felines 122
Summary 122
Chapter 4: Controlling a Phone App with Your Suave Gestures 123
Planning the Goldgesture app 124
Understanding optical flow 126
Setting up the Eclipse Workspace 129
Getting a cascade file and audio files 138
Specifying the app's requirements 138
Laying out a camera preview as the main view 139
Tracking back and forth gestures 140
Playing audio clips as questions and answers 143
Capturing images and tracking faces in an activity 147
Summary 164
Chapter 5: Equipping Your Car with a Rearview
Camera and Hazard Detection 165
Planning The Living Headlights app 167
Detecting lights as blobs 169
Estimating distances (a cheap approach) 172
Implementing The Living Headlights app 175
Testing The Living Headlights app at home 189
Testing The Living Headlights app in a car 193
Summary 199
Amplifying Camera 201
Planning the Lazy Eyes app 203
Understanding what Eulerian video magnification can do 205
Extracting repeating signals from video using the
Fast Fourier Transform (FFT) 206
Choosing and setting up an FFT library 207
Compositing two images using image pyramids 210
Implementing the Lazy Eyes app 211
Configuring and testing the app for various motions 220
Seeing things in another light 228
Summary 229
Chapter 7: Creating a Physics Simulation Based on a
Pen and Paper Sketch 231
Planning the Rollingball app 233
Detecting circles and lines 236
Setting up OpenCV for Unity 239
Configuring and building the Unity project 242
Creating the Rollingball scene in Unity 244
Creating Unity assets and adding them to the scene 247
Writing shaders and creating materials 247
Creating physics materials 250
Creating prefabs 252
Writing our first Unity script 256
Writing the main Rollingball script 258
Tidying up and testing 278
Summary 279
Index 281
OpenCV Essentials
Chapter 1, Getting Started, deals with the basic installation steps and
introduces the essential concepts of the OpenCV API. The first examples to
read/write images and video and capture them from a camera are also
provided.
Chapter 2, Something We Look At – Graphical User Interfaces, covers user
interface capabilities for our OpenCV-based applications.
Chapter 3, First Things First – Image Processing, covers the most useful
image processing techniques available in OpenCV.
Chapter 4, What's in the Image? Segmentation, tackles the all-important
problem of image segmentation in OpenCV.
Chapter 5, Focusing on the Interesting 2D Features, covers the functions
available for extracting keypoints and descriptors from an image.
Chapter 6, Where's Wally? Object Detection, describes that object detection is
a central problem in computer vision. This chapter explains the functionality
available for object detection.
Chapter 7, What Is He Doing? Motion, considers more than just a single static
image. This chapter deals with motion and tracking in OpenCV.
Chapter 8, Advanced Topics, focuses on some advanced topics such as
machine learning and GPU-based acceleration.
Instant OpenCV for IOS
Table of Contents
Preface 1
Instant OpenCV for iOS 5
Getting started with iOS (Simple) 5
Displaying an image from resources (Simple) 10
Linking OpenCV to an iOS project (Simple) 15
Detecting faces with Cascade Classifier (Intermediate) 21
Printing a postcard (Intermediate) 24
Working with images in Gallery (Intermediate) 30
Applying a retro effect (Intermediate) 37
Taking photos from camera (Intermediate) 41
Creating a static library (Intermediate) 46
Capturing a video from camera (Simple) 50
Control advanced camera settings (Advanced) 55
Applying effects to live video (Intermediate) 60
Saving video from camera (Simple) 63
Optimizing performance with ARM NEON (Advanced) 65
Detecting facial features (Advanced) 72
Using the Accelerate framework (Advanced) 77
Building OpenCV for iOS from sources (Advanced) 81
Android.Application.Programming.with.OpenCV
Preface 1
Chapter 1: Setting Up OpenCV 7
System requirements 8
Setting up a development environment 8
Getting a ready-made development environment – Tegra Android Development Pack (TAPD) 9
Assembling a development environment piece-by-piece 11
Getting the prebuilt OpenCV4Android 14
Building OpenCV4Android from source 14
Building the OpenCV samples with Eclipse 16
Finding documentation and help 30
Summary 30
Chapter 2: Working with Camera Frames 31
Designing our app – Second Sight 31
Creating the Eclipse project 34
Enabling camera and disk access in the manifest 38
Creating menu and string resources 40
Previewing and saving photos in CameraActivity 42
Deleting, editing, and sharing photos in LabActivity 52
Summary 55
Chapter 3: Applying Image Effects 57
Adding files to the project 57
Defining the Filter interface 59
Mixing color channels 60
Making subtle color shifts with curves 64
Processing a neighborhood of pixels with convolution filters 69
Adding the filters to CameraActivity 71
Summary 76
Chapter 4: Recognizing and Tracking Images 77
Adding files to the project 77
Understanding image tracking 79
Writing an image tracking filter 81
Adding the tracker filters to CameraActivity 87
Summary 92
Chapter 5: Combining Image Tracking with 3D Rendering 93
Adding files to the project 93
Defining the ARFilter interface 94
Building projection matrices in CameraProjectionAdapter 95
Modifying ImageDetectionFilter for 3D tracking 99
Rendering the cube in ARCubeRenderer 104
Adding 3D tracking and rendering to CameraActivity 108
Learning more about 3D graphics on Android 112
Summary 112
Index 113
A Practical Introduction to Computer Vision with OpenCV
Contents
Preface xiii
1 Introduction 1
1.1 A Difficult Problem 1
1.2 The Human Vision System 2
1.3 Practical Applications of Computer Vision 3
1.4 The Future of Computer Vision 5
1.5 Material in This Textbook 6
1.6 Going Further with Computer Vision 7
2 Images 9
2.1 Cameras 9
2.1.1 The Simple Pinhole Camera Model 9
2.2 Images 10
2.2.1 Sampling 11
2.2.2 Quantisation 11
2.3 Colour Images 13
2.3.1 Red–Green–Blue (RGB) Images 14
2.3.2 Cyan–Magenta–Yellow (CMY) Images 17
2.3.3 YUV Images 17
2.3.4 Hue Luminance Saturation (HLS) Images 18
2.3.5 Other Colour Spaces 20
2.3.6 Some Colour Applications 20
2.4 Noise 22
2.4.1 Types of Noise 23
2.4.2 Noise Models 25
2.4.3 Noise Generation 26
2.4.4 Noise Evaluation 26
2.5 Smoothing 27
2.5.1 Image Averaging 27
2.5.2 Local Averaging and Gaussian Smoothing 28
2.5.3 Rotating Mask 30
2.5.4 Median Filter 31
3 Histograms 35
3.1 1D Histograms 35
3.1.1 Histogram Smoothing 36
3.1.2 Colour Histograms 37
3.2 3D Histograms 39
3.3 Histogram/Image Equalisation 40
3.4 Histogram Comparison 41
3.5 Back-projection 43
3.6 k-means Clustering 44
4 Binary Vision 49
4.1 Thresholding 49
4.1.1 Thresholding Problems 50
4.2 Threshold Detection Methods 51
4.2.1 Bimodal Histogram Analysis 52
4.2.2 Optimal Thresholding 52
4.2.3 Otsu Thresholding 54
4.3 Variations on Thresholding 56
4.3.1 Adaptive Thresholding 56
4.3.2 Band Thresholding 57
4.3.3 Semi-thresholding 58
4.3.4 Multispectral Thresholding 58
4.4 Mathematical Morphology 59
4.4.1 Dilation 60
4.4.2 Erosion 62
4.4.3 Opening and Closing 63
4.4.4 Grey-scale and Colour Morphology 65
4.5 Connectivity 66
4.5.1 Connectedness: Paradoxes and Solutions 66
4.5.2 Connected Components Analysis 67
5 Geometric Transformations 71
5.1 Problem Specification and Algorithm 71
5.2 Affine Transformations 73
5.2.1 Known Affine Transformations 74
5.2.2 Unknown Affine Transformations 75
5.3 Perspective Transformations 76
5.4 Specification of More Complex Transformations 78
5.5 Interpolation 78
5.5.1 Nearest Neighbour Interpolation 79
5.5.2 Bilinear Interpolation 79
5.5.3 Bi-Cubic Interpolation 80
5.6 Modelling and Removing Distortion from Cameras 80
5.6.1 Camera Distortions 81
5.6.2 Camera Calibration and Removing Distortion 82
6 Edges 83
6.1 Edge Detection 83
6.1.1 First Derivative Edge Detectors 85
6.1.2 Second Derivative Edge Detectors 92
6.1.3 Multispectral Edge Detection 97
6.1.4 Image Sharpening 98
6.2 Contour Segmentation 99
6.2.1 Basic Representations of Edge Data 99
6.2.2 Border Detection 102
6.2.3 Extracting Line Segment Representations of Edge Contours 105
6.3 Hough Transform 108
6.3.1 Hough for Lines 109
6.3.2 Hough for Circles 111
6.3.3 Generalised Hough 112
7 Features 115
7.1 Moravec Corner Detection 117
7.2 Harris Corner Detection 118
7.3 FAST Corner Detection 121
7.4 SIFT 122
7.4.1 Scale Space Extrema Detection 123
7.4.2 Accurate Keypoint Location 124
7.4.3 Keypoint Orientation Assignment 126
7.4.4 Keypoint Descriptor 127
7.4.5 Matching Keypoints 127
7.4.6 Recognition 127
7.5 Other Detectors 129
7.5.1 Minimum Eigenvalues 130
7.5.2 SURF 130
8 Recognition 131
8.1 Template Matching 131
8.1.1 Applications 131
8.1.2 Template Matching Algorithm 133
8.1.3 Matching Metrics 134
8.1.4 Finding Local Maxima or Minima 135
8.1.5 Control Strategies for Matching 137
8.2 Chamfer Matching 137
8.2.1 Chamfering Algorithm 137
8.2.2 Chamfer Matching Algorithm 139
8.3 Statistical Pattern Recognition 140
8.3.1 Probability Review 142
8.3.2 Sample Features 143
8.3.3 Statistical Pattern Recognition Technique 149
8.4 Cascade of Haar Classifiers 152
8.4.1 Features 154
8.4.2 Training 156
8.4.3 Classifiers 156
8.4.4 Recognition 158
8.5 Other Recognition Techniques 158
8.5.1 Support Vector Machines (SVM) 158
8.5.2 Histogram of Oriented Gradients (HoG) 159
8.6 Performance 160
8.6.1 Image and Video Datasets 160
8.6.2 Ground Truth 161
8.6.3 Metrics for Assessing Classification Performance 162
8.6.4 Improving Computation Time 165
9 Video 167
9.1 Moving Object Detection 167
9.1.1 Object of Interest 168
9.1.2 Common Problems 168
9.1.3 Difference Images 169
9.1.4 Background Models 171
9.1.5 Shadow Detection 179
9.2 Tracking 180
9.2.1 Exhaustive Search 181
9.2.2 Mean Shift 181
9.2.3 Dense Optical Flow 182
9.2.4 Feature Based Optical Flow 185
9.3 Performance 186
9.3.1 Video Datasets (and Formats) 186
9.3.2 Metrics for Assessing Video Tracking Performance 187
10 Vision Problems 189
10.1 Baby Food 189
10.2 Labels on Glue 190
10.3 O-rings 191
10.4 Staying in Lane 192
10.5 Reading Notices 193
10.6 Mailboxes 194
10.7 Abandoned and Removed Object Detection 195
10.8 Surveillance 196
10.9 Traffic Lights 197
10.10 Real Time Face Tracking 198
10.11 Playing Pool 199
10.12 Open Windows 200
10.13 Modelling Doors 201
10.14 Determining the Time from Analogue Clocks 202
10.15 Which Page 203
10.16 Nut/Bolt/Washer Classification 204
10.17 Road Sign Recognition 205
10.18 License Plates 206
10.19 Counting Bicycles 207
10.20 Recognise Paintings 208
References 209
Index 213
Algorithms for Image Processing and Computer Vision
Preface xxi
Chapter 1 Practical Aspects of a Vision System — Image Display,
Input/Output, and Library Calls 1
OpenCV 2
The Basic OpenCV Code 2
The IplImage Data Structure 3
Reading and Writing Images 6
Image Display 7
An Example 7
Image Capture 10
Interfacing with the AIPCV Library 14
Website Files 18
References 18
Chapter 2 Edge-Detection Techniques 21
The Purpose of Edge Detection 21
Traditional Approaches and Theory 23
Models of Edges 24
Noise 26
Derivative Operators 30
Template-Based Edge Detection 36
Edge Models: The Marr-Hildreth Edge Detector 39
The Canny Edge Detector 42
The Shen-Castan (ISEF) Edge Detector 48
A Comparison of Two Optimal Edge Detectors 51
Color Edges 53
Source Code for the Marr-Hildreth Edge Detector 58
Source Code for the Canny Edge Detector 62
Source Code for the Shen-Castan Edge Detector 70
Website Files 80
References 82
Chapter 3 Digital Morphology 85
Morphology Defined 85
Connectedness 86
Elements of Digital Morphology—Binary Operations 87
Binary Dilation 88
Implementing Binary Dilation 92
Binary Erosion 94
Implementation of Binary Erosion 100
Opening and Closing 101
MAX—A High-Level Programming Language for
Morphology 107
The ‘‘Hit-and-Miss’’ Transform 113
Identifying Region Boundaries 116
Conditional Dilation 116
Counting Regions 119
Grey-Level Morphology 121
Opening and Closing 123
Smoothing 126
Gradient 128
Segmentation of Textures 129
Size Distribution of Objects 130
Color Morphology 131
Website Files 132
References 135
Chapter 4 Grey-Level Segmentation 137
Basics of Grey-Level Segmentation 137
Using Edge Pixels 139
Iterative Selection 140
The Method of Grey-Level Histograms 141
Using Entropy 142
Fuzzy Sets 146
Minimum Error Thresholding 148
Sample Results From Single Threshold Selection 149
The Use of Regional Thresholds 151
Chow and Kaneko 152
Modeling Illumination Using Edges 156
Implementation and Results 159
Comparisons 160
Relaxation Methods 161
Moving Averages 167
Cluster-Based Thresholds 170
Multiple Thresholds 171
Website Files 172
References 173
Chapter 5 Texture and Color 177
Texture and Segmentation 177
A Simple Analysis of Texture in Grey-Level Images 179
Grey-Level Co-Occurrence 182
Maximum Probability 185
Moments 185
Contrast 185
Homogeneity 185
Entropy 186
Results from the GLCM Descriptors 186
Speeding Up the Texture Operators 186
Edges and Texture 188
Energy and Texture 191
Surfaces and Texture 193
Vector Dispersion 193
Surface Curvature 195
Fractal Dimension 198
Color Segmentation 201
Color Textures 205
Website Files 205
References 206
Chapter 6 Thinning 209
What Is a Skeleton? 209
The Medial Axis Transform 210
Iterative Morphological Methods 212
The Use of Contours 221
Choi/Lam/Siu Algorithm 224
Treating the Object as a Polygon 226
Triangulation Methods 227
Force-Based Thinning 228
Definitions 229
Use of a Force Field 230
Subpixel Skeletons 234
Source Code for Zhang-Suen/Stentiford/Holt Combined
Algorithm 235
Website Files 246
References 247
Chapter 7 Image Restoration 251
Image Degradations—The Real World 251
The Frequency Domain 253
The Fourier Transform 254
The Fast Fourier Transform 256
The Inverse Fourier Transform 260
Two-Dimensional Fourier Transforms 260
Fourier Transforms in OpenCV 262
Creating Artificial Blur 264
The Inverse Filter 270
The Wiener Filter 271
Structured Noise 273
Motion Blur—A Special Case 276
The Homomorphic Filter—Illumination 277
Frequency Filters in General 278
Isolating Illumination Effects 280
Website Files 281
References 283
Chapter 8 Classification 285
Objects, Patterns, and Statistics 285
Features and Regions 288
Training and Testing 292
Variation: In-Class and Out-Class 295
Minimum Distance Classifiers 299
Distance Metrics 300
Distances Between Features 302
Cross Validation 304
Support Vector Machines 306
Multiple Classifiers—Ensembles 309
Merging Multiple Methods 309
Merging Type 1 Responses 310
Evaluation 311
Converting Between Response Types 312
Merging Type 2 Responses 313
Merging Type 3 Responses 315
Bagging and Boosting 315
Bagging 315
Boosting 316
Website Files 317
References 318
Chapter 9 Symbol Recognition 321
The Problem 321
OCR on Simple Perfect Images 322
OCR on Scanned Images—Segmentation 326
Noise 327
Isolating Individual Glyphs 329
Matching Templates 333
Statistical Recognition 337
OCR on Fax Images—Printed Characters 339
Orientation—Skew Detection 340
The Use of Edges 345
Handprinted Characters 348
Properties of the Character Outline 349
Convex Deficiencies 353
Vector Templates 357
Neural Nets 363
A Simple Neural Net 364
A Backpropagation Net for Digit Recognition 368
The Use of Multiple Classifiers 372
Merging Multiple Methods 372
Results From the Multiple Classifier 375
Printed Music Recognition—A Study 375
Staff Lines 376
Segmentation 378
Music Symbol Recognition 381
Source Code for Neural Net Recognition System 383
Website Files 390
References 392
Chapter 10 Content-Based Search — Finding Images by Example 395
Searching Images 395
Maintaining Collections of Images 396
Features for Query by Example 399
Color Image Features 399
Mean Color 400
Color Quad Tree 400
Hue and Intensity Histograms 401
Comparing Histograms 402
Requantization 403
Results from Simple Color Features 404
Other Color-Based Methods 407
Grey-Level Image Features 408
Grey Histograms 409
Grey Sigma—Moments 409
Edge Density—Boundaries Between Objects 409
Edge Direction 410
Boolean Edge Density 410
Spatial Considerations 411
Overall Regions 411
Rectangular Regions 412
Angular Regions 412
Circular Regions 414
Hybrid Regions 414
Test of Spatial Sampling 414
Additional Considerations 417
Texture 418
Objects, Contours, Boundaries 418
Data Sets 418
Website Files 419
References 420
Systems 424
Chapter 11 High-Performance Computing for Vision and Image
Processing 425
Paradigms for Multiple-Processor Computation 426
Shared Memory 426
Message Passing 427
Execution Timing 427
Using clock() 428
Using QueryPerformanceCounter 430
The Message-Passing Interface System 432
Installing MPI 432
Using MPI 433
Inter-Process Communication 434
Running MPI Programs 436
Real Image Computations 437
Using a Computer Network—Cluster Computing 440
A Shared Memory System—Using the PC Graphics
Processor 444
GLSL 444
OpenGL Fundamentals 445
Practical Textures in OpenGL 448
Shader Programming Basics 451
Vertex and Fragment Shaders 452
Required GLSL Initializations 453
Reading and Converting the Image 454
Passing Parameters to Shader Programs 456
Putting It All Together 457
Speedup Using the GPU 459
Developing and Testing Shader Code 459
Finding the Needed Software 460
Website Files 461
References 461
Index 465
Emgu CV Essential
Preface 1
Chapter 1: Introduction to Emgu CV 5
What is Emgu CV? 5
Comparing image-processing libraries 6
License agreement 6
Documentation and other material 7
Ease of use 7
Performance 8
Summary of the comparison 9
Advantages of Emgu CV 9
Cross-platform 9
Cross-language support with examples 9
Other advantages 10
Summary 10
Chapter 2: Installing Emgu CV 11
Downloading Emgu CV 11
Installing Emgu CV 11
Installing on Windows 11
Installing on Linux 16
Getting the dependency 16
Building Emgu CV from source 17
Installing on OS X 18
Getting the dependency 19
Building Emgu CV from source 19
Troubleshooting 20
Windows 20
Linux 21
OS X 22
Summary 22
Chapter 3: Hello World 23
Hello World in C# 23
Creating a new project 24
Designing our form 27
Coding 27
Output 29
Hello World in VB.NET 30
Hello World in C++ 31
Summary 32
Chapter 4: Wrapping OpenCV 33
Architecture overview 33
OpenCV 33
Emgu CV 34
Function mapping 36
Structure mapping 36
Enumeration mapping 37
Summary 37
Chapter 5: Working with Images 39
Digital image representation 39
Pixels and data 39
Pixel resolution 40
Color image representation 41
Color depth 43
Working with images 44
Creating an image 44
Loading an image from a file 46
Operations with pixels 47
Method naming rules 49
Using operator overload 50
Generic operations support 51
Garbage collection 51
XML serialization 52
Summary 53
Chapter 6: Working with Matrices 55
Matrix and the Image class 55
Definition and parameters 56
Working with matrices 56
Creating a matrix 57
Operations with elements 58
Summary 59
Chapter 7: Shape Detection 61
Canny Edge Detector 61
Hough transforms 63
Hough Line transform 63
Hough Circle transform 65
Contour 67
Contour finding 68
Representation of contours 68
Sequences of vertexes 68
Free chain codes 69
Drawing contours 69
Polygon approximations 70
A contours example 70
Summary 72
Chapter 8: Face Detection 73
Biometric systems 73
Camera captures 75
Machine learning 76
Face detection or the Haar classifier 77
Boosting theory and supervised learning 78
Haar-like features 78
Code for face detection 81
Summary 83
Chapter 9: License Plate Recognition 85
License Plate Recognition 85
Algorithms for LPR 86
OCR 87
Tesseract-OCR 88
Code for License Plate Recognition 88
Assumption 89
Source code 89
GetWhitePixelMask 90
DetectLicensePlate 91
FindLicensePlate 92
Output 93
Summary 93
Chapter 10: Image Stitching 95
Image stitching 95
Algorithms for image stitching 96
Image matching 96
Image calibration 97
Image blending 97
Code 98
Summary 99
Index 101
Mastering OpenCV with Practical Computer Vision Projects
Preface 1
Chapter 1: Cartoonifier and Skin Changer for Android 7
Accessing the webcam 9
Main camera processing loop for a desktop app 10
Generating a black-and-white sketch 11
Generating a color painting and a cartoon 12
Generating an "evil" mode using edge filters 14
Generating an "alien" mode using skin detection 16
Skin-detection algorithm 16
Showing the user where to put their face 17
Implementation of the skin-color changer 19
Porting from desktop to Android 24
Setting up an Android project that uses OpenCV 24
Color formats used for image processing on Android 25
Input color format from the camera 25
Output color format for display 26
Adding the cartoonifier code to the Android NDK app 28
Reviewing the Android app 30
Cartoonifying the image when the user taps the screen 31
Saving the image to a file and to the Android picture gallery 33
Showing an Android notification message about a saved image 36
Changing cartoon modes through the Android menu bar 37
Reducing the random pepper noise from the sketch image 40
Showing the FPS of the app 43
Using a different camera resolution 43
Customizing the app 44
Summary 45
Chapter 2: Marker-based Augmented Reality on iPhone or iPad 47
Creating an iOS project that uses OpenCV 48
Adding OpenCV framework 49
Including OpenCV headers 51
Application architecture 52
Marker detection 62
Marker identification 64
Grayscale conversion 64
Image binarization 65
Contours detection 66
Candidates search 67
Marker code recognition 72
Reading marker code 72
Marker location refinement 74
Placing a marker in 3D 76
Camera calibration 76
Marker pose estimation 78
Rendering the 3D virtual object 82
Creating the OpenGL rendering layer 82
Rendering an AR scene 85
Summary 92
References 92
Chapter 3: Marker-less Augmented Reality 93
Marker-based versus marker-less AR 94
Using feature descriptors to find an arbitrary image on video 95
Feature extraction 95
Definition of a pattern object 98
Matching of feature points 98
PatternDetector.cpp 99
Outlier removal 100
Cross-match filter 101
Ratio test 101
Homography estimation 102
Homography refinement 104
Putting it all together 107
Pattern pose estimation 108
PatternDetector.cpp 108
Obtaining the camera-intrinsic matrix 110
Pattern.cpp 113
Application infrastructure 114
ARPipeline.hpp 115
ARPipeline.cpp 115
Enabling support for 3D visualization in OpenCV 116
Video capture using OpenCV 118
Rendering augmented reality 119
ARDrawingContext.hpp 119
ARDrawingContext.cpp 120
Demonstration 122
main.cpp 123
Summary 126
References 127
Chapter 4: Exploring Structure from Motion Using OpenCV 129
Structure from Motion concepts 130
Estimating the camera motion from a pair of images 132
Point matching using rich feature descriptors 132
Point matching using optical flow 134
Finding camera matrices 139
Reconstructing the scene 143
Reconstruction from many views 147
Refinement of the reconstruction 151
Visualizing 3D point clouds with PCL 155
Using the example code 158
Summary 159
References 160
Chapter 5: Number Plate Recognition Using SVM and
Neural Networks 161
Introduction to ANPR 161
ANPR algorithm 163
Plate detection 166
Segmentation 167
Classification 173
Plate recognition 176
OCR segmentation 177
Feature extraction 178
OCR classification 181
Evaluation 185
Summary 188
Chapter 6: Non-rigid Face Tracking 189
Overview 191
Utilities 191
Object-oriented design 191
Data collection: Image and video annotation 193
Training data types 194
Annotation tool 198
Pre-annotated data (The MUCT dataset) 198
Geometrical constraints 199
Procrustes analysis 202
Linear shape models 205
A combined local-global representation 207
Training and visualization 209
Facial feature detectors 212
Correlation-based patch models 214
Learning discriminative patch models 214
Generative versus discriminative patch models 218
Accounting for global geometric transformations 219
Training and visualization 222
Face detection and initialization 224
Face tracking 228
Face tracker implementation 229
Training and visualization 231
Generic versus person-specific models 232
Summary 233
References 233
Chapter 7: 3D Head Pose Estimation Using AAM and POSIT 235
Active Appearance Models overview 236
Active Shape Models 238
Getting the feel of PCA 240
Triangulation 245
Triangle texture warping 247
Model Instantiation – playing with the Active Appearance Model 249
AAM search and fitting 250
POSIT 253
Diving into POSIT 253
POSIT and head model 256
Tracking from webcam or video file 257
Summary 259
References 260
Chapter 8: Face Recognition using Eigenfaces or Fisherfaces 261
Introduction to face recognition and face detection 261
Step 1: Face detection 263
Implementing face detection using OpenCV 264
Loading a Haar or LBP detector for object or face detection 265
Accessing the webcam 266
Detecting an object using the Haar or LBP Classifier 266
Detecting the face 268
Step 2: Face preprocessing 270
Eye detection 271
Eye search regions 272
Step 3: Collecting faces and learning from them 281
Collecting preprocessed faces for training 283
Training the face recognition system from collected faces 285
Viewing the learned knowledge 287
Average face 289
Eigenvalues, Eigenfaces, and Fisherfaces 290
Step 4: Face recognition 292
Face identification: Recognizing people from their face 292
Face verification: Validating that it is the claimed person 292
Finishing touches: Saving and loading files 295
Finishing touches: Making a nice and interactive GUI 295
Drawing the GUI elements 297
Checking and handling mouse clicks 306
Summary 308
References 309
Index 311
Practical OpenCV
About the Author ...............................................................................................................xiii
About the Technical Reviewer ............................................................................................ xv
Acknowledgments ............................................................................................................ xvii
■■Part 1: Getting Comfortable .......................................................................... 1
■■Chapter 1: Introduction to Computer Vision and OpenCV ..................................................3
Why Was This Book Written? .........................................................................................................3
OpenCV ..........................................................................................................................................4
History of OpenCV ..................................................................................................................................................4
Built-in Modules ....................................................................................................................................................4
Summary .......................................................................................................................................5
■■Chapter 2: Setting up OpenCV on Your Computer ..............................................................7
Operating Systems ........................................................................................................................7
Ubuntu ...................................................................................................................................................................7
Windows ..............................................................................................................................................................12
Mac OSX ..............................................................................................................................................................12
Summary .....................................................................................................................................12
■■Chapter 3: CV Bling—OpenCV Inbuilt Demos ..................................................................13
Camshift ......................................................................................................................................13
Stereo Matching ..........................................................................................................................16
Homography Estimation in Video ................................................................................................16
Circle and Line Detection ............................................................................................................18
Image Segmentation ...................................................................................................................19
Bounding Box and Circle .............................................................................................................21
Image Inpainting .........................................................................................................................21
Summary .....................................................................................................................................22
■■Chapter 4: Basic Operations on Images and GUI Windows ..............................................23
Displaying Images from Disk in a Window ..................................................................................23
The cv::Mat Structure ..................................................................................................................24
Creating a cv::Mat ...............................................................................................................................................25
Accessing elements of a cv::Mat ......................................................................................................................... 25
Expressions with cv::Mat ..................................................................................................................................... 25
Converting Between Color-spaces ..............................................................................................26
GUI Track-Bars and Callback Functions ......................................................................................27
Callback Functions .............................................................................................................................................27
ROIs: Cropping a Rectangular Portion out of an Image ...............................................................30
Region of Interest in an Image ............................................................................................................................ 30
Accessing Individual Pixels of an Image .....................................................................................33
Exercise ...............................................................................................................................................................33
Videos ..........................................................................................................................................34
Displaying the Feed from Your Webcam or USB Camera/File .............................................................................. 34
Writing Videos to Disk ..........................................................................................................................................36
Summary .....................................................................................................................................37
■■ Part 2: Advanced Computer Vision Problems and Coding
Them in OpenCV ......................................................................................... 39
■■Chapter 5: Image Filtering ...............................................................................................41
Image Filters ...............................................................................................................................41
Blurring Images ...................................................................................................................................................45
Resizing Images—Up and Down ......................................................................................................................... 48
Eroding and Dilating Images ................................................................................................................................ 49
Detecting Edges and Corners Efficiently in Images ............................................................................................. 51
Edges ...................................................................................................................................................................51
Canny Edges ........................................................................................................................................................56
Corners ................................................................................................................................................................57
Object Detector App ....................................................................................................................60
Morphological Opening and Closing of Images to Remove Noise ...............................................63
Summary .....................................................................................................................................65
■■Chapter 6: Shapes in Images ...........................................................................................67
Contours ......................................................................................................................................67
Point Polygon Test ...............................................................................................................................................70
Hough Transform .........................................................................................................................74
Detecting Lines with Hough Transform ................................................................................................................ 74
Detecting Circles with Hough Transform ............................................................................................................. 77
Generalized Hough Transform .....................................................................................................80
RANdom Sample Consensus (RANSAC) .......................................................................................80
Bounding Boxes and Circles ........................................................................................................91
Convex Hulls ................................................................................................................................92
Summary .....................................................................................................................................93
■■Chapter 7: Image Segmentation and Histograms ............................................................95
Image Segmentation ...................................................................................................................95
Simple Segmentation by Thresholding ................................................................................................................ 96
Floodfill ..............................................................................................................................................................100
Watershed Segmentation .................................................................................................................................. 103
GrabCut Segmentation ......................................................................................................................................110
Histograms ................................................................................................................................111
Equalizing Histograms .......................................................................................................................................111
Histogram Backprojections ............................................................................................................................... 113
Meanshift and Camshift ....................................................................................................................................116
Summary ...................................................................................................................................117
■■Chapter 8: B asic Machine Learning and Object D etection Based on Keypoints ............119
Keypoints and Keypoint Descriptors: Introduction and Terminology .........................................119
General Terms ....................................................................................................................................................120
How Does the Keypoint-Based Method Work? .................................................................................................. 120
SIFT Keypoints and Descriptors ................................................................................................121
Keypoint Detection and Orientation Estimation ................................................................................................. 121
SIFT Keypoint Descriptors ................................................................................................................................. 125
Matching SIFT Descriptors ................................................................................................................................ 125
SURF Keypoints and Descriptors ...............................................................................................131
SURF Keypoint Detection ...................................................................................................................................131
SURF Descriptor ................................................................................................................................................134
ORB (Oriented FAST and Rotated BRIEF) ...................................................................................136
Oriented FAST Keypoints ...................................................................................................................................137
BRIEF Descriptors ..............................................................................................................................................137
Basic Machine Learning ............................................................................................................140
SVMs ..................................................................................................................................................................141
Object Categorization ................................................................................................................142
Strategy .............................................................................................................................................................142
Organization ......................................................................................................................................................143
Summary ...................................................................................................................................153
■■ Chapter 9: Affine and Perspective Transformations and Their Applications
to Image Panoramas .....................................................................................................155
Affine Transforms ......................................................................................................................155
Applying Affine Transforms ................................................................................................................................ 156
Estimating Affine Transforms ............................................................................................................................. 158
Perspective Transforms .............................................................................................................161
Panoramas ................................................................................................................................166
Summary ...................................................................................................................................172
■■Chapter 10: 3D Geometry and Stereo Vision .................................................................173
Single Camera Calibration .........................................................................................................173
OpenCV Implementation of Single Camera Calibration ...................................................................................... 176
Stereo Vision .............................................................................................................................179
Triangulation ......................................................................................................................................................179
Calibration .........................................................................................................................................................180
Rectification and Disparity by Matching ............................................................................................................ 186
Summary ...................................................................................................................................200
■■ Chapter 11: Embedded Computer Vision: Running OpenCV Programs
on the Raspberry Pi ................................................................................................................. 201
Raspberry Pi ..............................................................................................................................202
Setting Up Your New Raspberry Pi ............................................................................................202
Installing Raspbian on the Pi ............................................................................................................................. 203
Initial Settings ....................................................................................................................................................204
Installing OpenCV ...............................................................................................................................................205
Camera board ............................................................................................................................206
Camera Board vs. USB Camera ......................................................................................................................... 207
Frame-Rate Comparisons .................................................................................................................................. 214
Usage Examples ........................................................................................................................215
Color-based Object Detector .............................................................................................................................. 216
ORB Keypoint-based Object Detector ................................................................................................................ 217
Summary ...................................................................................................................................218
Index .................................................................................................................................219
OpenCV 2 Computer Vision Application Programming Cookbook
Table of Contents
Preface 1
Chapter 1: Playing with Images 7
Introduction 7
Installing the OpenCV library 8
Creating an OpenCV project with MS Visual C++ 11
Creating an OpenCV project with Qt 19
Loading, displaying, and saving images 26
Creating a GUI application using Qt 30
Chapter 2: Manipulating the Pixels 37
Introduction 37
Accessing pixel values 38
Scanning an image with pointers 41
Scanning an image with iterators 49
Writing efficient image scanning loops 51
Scanning an image with neighbor access 55
Performing simple image arithmetic 59
Defining regions of interest 63
Chapter 3: Processing Images with Classes 69
Introduction 69
Using the Strategy pattern in algorithm design 70
Using a Controller to communicate with processing modules 76
Using the Singleton design pattern 80
Using the Model-View-Controller architecture to design an application 82
Converting color spaces 85
Chapter 4: Counting the Pixels with Histograms 89
Introduction 89
Computing the image histogram 89
Applying look-up tables to modify image appearance 96
Equalizing the image histogram 101
Backprojecting a histogram to detect specific image content 103
Using the mean shift algorithm to find an object 108
Retrieving similar images using histogram comparison 112
Chapter 5: Transforming Images with Morphological Operations 117
Introduction 117
Eroding and dilating images using morphological filters 118
Opening and closing images using morphological filters 122
Detecting edges and corners using morphological filters 125
Segmenting images using watersheds 131
Extracting foreground objects with the GrabCut algorithm 137
Chapter 6: Filtering the Images 141
Introduction 141
Filtering images using low-pass filters 142
Filtering images using a median filter 147
Applying directional filters to detect edges 148
Computing the Laplacian of an image 156
Chapter 7: Extracting Lines, Contours, and Components 163
Introduction 163
Detecting image contours with the Canny operator 164
Detecting lines in images with the Hough transform 167
Fitting a line to a set of points 178
Extracting the components' contours 182
Computing components' shape descriptors 186
Chapter 8: Detecting and Matching Interest Points 191
Introduction 191
Detecting Harris corners 192
Detecting FAST features 203
Detecting the scale-invariant SURF features 206
Describing SURF features 212
Chapter 9: Estimating Projective Relations in Images 217
Introduction 217
Calibrating a camera 219
Computing the fundamental matrix of an image pair 228
Matching images using random sample consensus 233
Computing a homography between two images 242
Chapter 10: Processing Video Sequences 247
Introduction 247
Reading video sequences 248
Processing the video frames 251
Writing video sequences 261
Tracking feature points in video 266
Extracting the foreground objects in video 272
Index 279