读《OpenCV By Example》

在学长的建议下开始阅读《OpenCV By Example》这本书,熟悉一下OpenCV的基本用法。前面七八个章节基本上都是认认真真看过了,也跟着书上的代码试着去实现,后面的几个章节由于找不到相关的具体代码,书上只有一个大概思想,自己没有具体去实现,简单了解了一下实现的思路,三个月的时间,零零散散的把这本书算是看完了吧,简单做一下总结,方便以后再次翻阅这本书。

这本书的编程语言为C++,基于OpenCV3.0,共有11个章节:

  1. Getting Started with OpenCV
  2. An Introduction to the Basics of OpenCV
  3. Learning the Graphical User Interface and Basic Filtering
  4. Delving into Histograms and Filters
  5. Automated Optical Inspection, Object Segmentation, and Detection
  6. Learning Object Classification
  7. Detecting Face Parts and Overlaying Masks
  8. Video Surveillance, Background Modeling, and Morphological Operations
  9. Learning Object Tracking
  10. Developing Segmentation Algorithms for Text Recognition
  11. Text Recognition with Tesseract

具体每一章节总结如下,有的根据章节里每一小节内容介绍,有的将根据章节后面的Summary来写:

1.Getting Started with OpenCV

这个章节介绍了人类视觉系统是如何处理视觉数据,以及机器为什么难以做到像人类视觉系统一样处理视觉信息。然后介绍了在不同系统中如何安装OpenCV。

2.An Introduction to the Basics of OpenCV

这个章节介绍了CMake的配置文件、通过CMake创建OpenCV程序、图像数据在OpenCV中用矩阵Mat来存储(单通道/多通道)、如何读写图像、读取视频或摄像头信息、OpenCV中一些基本的对象类型(Vec、Scalar、Point、Size、Rect、RotatedRect)。

基本的矩阵操作。常见的类型有CV_8UC1、CV_8UC3、CV_8UC4、CV_32FC1、CV_32FC3、CV_32FC4。常见的矩阵有零矩阵(Mat::zeros(5, 5, CV_32F))、全一矩阵(Mat::ones(5, 5, CV_32F))、单位矩阵(Mat::eye(5, 5, CV_32F)。

数据的持久化存储,将数据保存到XML/YAML文件中,如何从其他应用中读取这些信息。

3.Learning the Graphical User Interface and Basic Filtering

OpenCV用户交互界面。OpenCV拥有跨平台的用户交互,并提供了两种选择:

扫描二维码关注公众号,回复: 2192222 查看本文章
  • 一种基于本地用户接口的基本接口,如OS X的Cocoa或Carbon和Linux中的GTK或Windows图形用户界面,这是OpenCV的默认选择。
  • 基于跨平台的qt库的稍微高级的接口。在编译OpenCV之前,必须在cmake中手动启用qt选项。

本章节介绍了通过OpenCV的基本用户交互、利用QT的图像化用户交互、在界面上添加滑动条和鼠标事件以及按钮。通过OpenGL创建不同类型的用户交互界面来展示二维图像或三维图像。

4.Delving into Histograms and Filters

首先创建CMake编译脚本文件,然后创建用户交互界面。介绍了如何计算图像的直方图、创建查找表、基于直方图的图像均衡化、为图像添加LOMO效果或漫画效果。

In this chapter, we learned how to create a complete project that manipulates images
after applying different effects. We also split a color image in multiple matrices in
order to apply effects to only one channel. We learned how to create look up tables,
merge multiple matrices in one, use a canny and bilateral filter, draw circles, and
multiply images to perform halo effects.

5.Automated Optical Inspection, Object Segmentation, and Detection

这个章节介绍目标检测,涉及了去除噪声(中值滤波)、基本的消除背景(最简单的为用检测得到的图像直接减去背景图像,受光照以及摄像机角度影响)、二值化操作、目标连通域检测(四邻域或八邻域)、通过找轮廓来分割目标。

消除背景简易方法分减法和除法:

  • R= L-I
  • R= 255*(1-(I/L))

6.Learning Object Classification

介绍如何为独立出来的对象分类。首先介绍机器学习的概念,然后介绍了计算机视觉与机器学习的工作流。


这个章节通过一个示例使用SVM对物体进行分类。

1、对于每一张训练的图像:图像预处理、图像分割

2、对于图像中的每一个对象:提取特征、将训练特征和标签添加到向量中

3、创建SVM模型

4、使用训练特征向量训练SVM模型

5、预处理一张要分类的输入图像

6、分割输入图像

7、对于每一个检测到的目标:提取特征、使用SVM预测、在输出图像中画出结果

这里提取目标特征可以考虑以下几点:

  • 目标的面积
  • 纵横比(the width divided by the height of the bounding rectangle)
  • 洞的数量
  • 轮廓边的数量

7.Detecting Face Parts and Overlaying Masks

这个章节讨论面部检测以及在视频中为脸部添加有趣的遮罩效果。

主要有以下几个主题:

  • 学习Haar级联
  • 积分图像以及我们为什么需要它们
  • 建立一个面部检测程序
  • 检测和跟踪面部特征,如摄像头中检测眼睛、耳朵、鼻子和嘴等
  • 在视频中为脸部添加有趣的遮罩物、眼镜、鼻子等

 In this chapter, we discussed Haar cascades and integral images. We learned how the face detection pipeline is built. We learned how to detect and track faces in a live video stream. We discussed how to use the face detection framework to detect various face parts, such as eyes, ears, nose, and mouth. We also learned how to overlay masks on top on the input image using the results of the face parts detection.

8.Video Surveillance, Background Modeling, and Morphological Operations

首先介绍消除背景。最简单的是将新图像减去背景图像,得到新进入背景的物体,这种方法不实际,很容易受到噪声影响,而且无法将新进入视线中的物体作为背景处理最新进入的物体。然后介绍帧差法,这种方法通过后一帧的图像减去前一帧的图像,得到新加入的物体,这种方法能很快适应光照改变以及摄像机的移动。但如果一个物体进入图像并停留下来,将无法检测到。这种方法主要关心的是检测彩色不均匀的物体,这个方法只能检测到其边缘部分。之后介绍MOG(Mixture of Gaussians)。

最后介绍了一些形态学处理方法。介绍了腐蚀、膨胀、开(先腐蚀再膨胀)操作、闭(先膨胀后腐蚀)操作、提取边缘(通过梯度)、White Top-Hat transform、Black Top-Hat transform。看过这一小节后感觉自己需要去看看《数字图像处理》这本书。

9.Learning Object Tracking

这个章节主要介绍目标追踪。首先介绍根据物体颜色对物体进行追踪,然后介绍Continuously Adaptive Meanshift方法来追踪物体、通过Harris角点检测感兴趣点来追踪物体、Shi-Tomasi Corner Detector、基于目标物体特征的追踪以及基于光流场的目标检测方法

 In this chapter, we learned about object tracking. We learned how to use the HSV colorspace to track colored objects. We discussed clustering techniques used for object tracking and how we can build an interactive object tracker using the CAMShift algorithm. We learned about corner detectors and how to track corners in a live video. We discussed how to track features in a video using optical flow. We also learned the concepts behind Lucas-Kanade and Farneback algorithms and implemented them as well.

10.Developing Segmentation Algorithms for Text Recognition

这个章节介绍光学字符识别的过程。首先对输入图像二值化处理,然后对其进行膨胀操作,然后检测连通域并进行分类,处理连通域,提取出类似文字格式的连通域,然后将连通域进行方向矫正,最后通过Tesseract程序进行字符识别。

In this chapter, we presented a brief introduction to OCR applications. We saw that the preprocessing phase of such systems must be adjusted according to the type of documents that we are planning to identify. We learned the common operations while preprocessing text files, such as thresholding, cropping, skewing, and text region segmentation. Finally, we learned how to install and use Tesseract OCR to convert our image to text.

11.Text Recognition with Tesseract
最后一个章节主要介绍的Tesseract程序的主要用法。自己对人脸识别比较感兴趣,所以这里暂时没有仔细去看。

准备写这篇的时候,感觉自己有很多很多东西想写,但真正开始写的时候发现自己能写出来的东西真的是太少了。不过,通过写这篇文章,自己快速重新翻阅了一遍这本书,感觉自己还是学到了一些东西。

猜你喜欢

转载自blog.csdn.net/u014657795/article/details/79241339
今日推荐