<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>arthur的blog</title>
    <description>Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
</description>
    <link>http://liuious.github.io/</link>
    <atom:link href="http://liuious.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Thu, 19 Dec 2019 07:27:30 +0000</pubDate>
    <lastBuildDate>Thu, 19 Dec 2019 07:27:30 +0000</lastBuildDate>
    <generator>Jekyll v3.8.5</generator>
    
      <item>
        <title>pod库的创建</title>
        <description>&lt;h1 id=&quot;1准备工作&quot;&gt;1.准备工作&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;查看 &lt;a href=&quot;http://www.cnblogs.com/zxs-19920314/p/4985476.html?utm_source=tuicool&amp;amp;utm_medium=referral&quot;&gt;最新版CocoaPods的安装流程&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;git创建一个开源项目 &lt;a href=&quot;http://www.cnblogs.com/skying555/p/5226186.html&quot;&gt;github 创建新项目&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;2&quot;&gt;2.&lt;/h1&gt;
</description>
        <pubDate>Wed, 17 Aug 2016 01:38:49 +0000</pubDate>
        <link>http://liuious.github.io/2016/08/17/pod%E5%BA%93%E5%88%9B%E5%BB%BA.html</link>
        <guid isPermaLink="true">http://liuious.github.io/2016/08/17/pod%E5%BA%93%E5%88%9B%E5%BB%BA.html</guid>
        
        <category>iOS</category>
        
        
      </item>
    
      <item>
        <title>OpenCV模块说明</title>
        <description>&lt;p&gt;文章出自：&lt;a href=&quot;http://blog.csdn.net/poem_qianmo/article/details/19925819&quot;&gt;http://blog.csdn.net/poem_qianmo/article/details/19925819&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;官方介绍：&lt;a href=&quot;http://docs.opencv.org/2.4/modules/refman.html&quot;&gt;http://docs.opencv.org/2.4/modules/refman.html&lt;/a&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;cm&quot;&gt;/*
 *      ** File generated automatically, do not modify **
 *
 * This file defines the list of modules available in current build configuration
 *
 *
*/&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;#define HAVE_OPENCV_CALIB3D  
#define HAVE_OPENCV_CONTRIB  
#define HAVE_OPENCV_CORE  
#define HAVE_OPENCV_FEATURES2D  
#define HAVE_OPENCV_FLANN  
#define HAVE_OPENCV_GPU  
#define HAVE_OPENCV_HIGHGUI  
#define HAVE_OPENCV_IMGPROC  
#define HAVE_OPENCV_LEGACY  
#define HAVE_OPENCV_ML  
#define HAVE_OPENCV_NONFREE  
#define HAVE_OPENCV_OBJDETECT  
#define HAVE_OPENCV_OCL  
#define HAVE_OPENCV_PHOTO  
#define HAVE_OPENCV_STITCHING  
#define HAVE_OPENCV_SUPERRES  
#define HAVE_OPENCV_TS  
#define HAVE_OPENCV_VIDEO  
#define HAVE_OPENCV_VIDEOSTAB &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;【calib3d】&lt;/strong&gt;——其实就是就是Calibration（校准）加3D这两个词的组合缩写。这个模块主要是相机校准和三维重建相关的内容。基本的多视角几何算法，单个立体摄像头标定，物体姿态估计，立体相似性算法，3D信息的重建等等。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【contrib】&lt;/strong&gt;——也就是Contributed/Experimental Stuf的缩写， 该模块包含了一些最近添加的不太稳定的可选功能，不用去多管。2.4.8里的这个模块有新型人脸识别，立体匹配，人工视网膜模型等技术。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【core】&lt;/strong&gt;——核心功能模块，包含如下内容：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;OpenCV基本数据结构&lt;/li&gt;
  &lt;li&gt;动态数据结构&lt;/li&gt;
  &lt;li&gt;绘图函数&lt;/li&gt;
  &lt;li&gt;数组操作相关函数&lt;/li&gt;
  &lt;li&gt;辅助功能与系统函数和宏&lt;/li&gt;
  &lt;li&gt;与OpenGL的互操作&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;【imgproc】&lt;/strong&gt;——Image和Processing这两个单词的缩写组合。图像处理模块，这个模块包含了如下内容：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;线性和非线性的图像滤波&lt;/li&gt;
  &lt;li&gt;图像的几何变换&lt;/li&gt;
  &lt;li&gt;其它（Miscellaneous）图像转换&lt;/li&gt;
  &lt;li&gt;直方图相关&lt;/li&gt;
  &lt;li&gt;结构分析和形状描述&lt;/li&gt;
  &lt;li&gt;运动分析和对象跟踪&lt;/li&gt;
  &lt;li&gt;特征检测&lt;/li&gt;
  &lt;li&gt;目标检测等内容&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;【features2d】&lt;/strong&gt; ——也就是Features2D， 2D功能框架 ，包含如下内容：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;特征检测和描述&lt;/li&gt;
  &lt;li&gt;特征检测器（Feature Detectors）通用接口&lt;/li&gt;
  &lt;li&gt;描述符提取器（Descriptor Extractors）通用接口&lt;/li&gt;
  &lt;li&gt;描述符匹配器（Descriptor Matchers）通用接口&lt;/li&gt;
  &lt;li&gt;通用描述符（Generic Descriptor）匹配器通用接口&lt;/li&gt;
  &lt;li&gt;关键点绘制函数和匹配功能绘制函数&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;【flann】&lt;/strong&gt;—— Fast Library for Approximate Nearest Neighbors，高维的近似近邻快速搜索算法库，包含两个部分：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;快速近似最近邻搜索&lt;/li&gt;
  &lt;li&gt;聚类&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;【gpu】&lt;/strong&gt;——运用GPU加速的计算机视觉模块&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【highgui】&lt;/strong&gt;——也就是high gui，高层GUI图形用户界面，包含媒体的I / O输入输出，视频捕捉、图像和视频的编码解码、图形交互界面的接口等内容&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【legacy】&lt;/strong&gt;——一些已经废弃的代码库，保留下来作为向下兼容，包含如下相关的内容：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;运动分析&lt;/li&gt;
  &lt;li&gt;期望最大化&lt;/li&gt;
  &lt;li&gt;直方图&lt;/li&gt;
  &lt;li&gt;平面细分（C API）&lt;/li&gt;
  &lt;li&gt;特征检测和描述（Feature Detection and Description）&lt;/li&gt;
  &lt;li&gt;描述符提取器（Descriptor Extractors）的通用接口&lt;/li&gt;
  &lt;li&gt;通用描述符（Generic Descriptor Matchers）的常用接口&lt;/li&gt;
  &lt;li&gt;匹配器&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;【ml】&lt;/strong&gt;——Machine Learning，机器学习模块， 基本上是统计模型和分类算法，包含如下内容：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;统计模型 （Statistical Models）&lt;/li&gt;
  &lt;li&gt;一般贝叶斯分类器 （Normal Bayes Classifier）&lt;/li&gt;
  &lt;li&gt;K-近邻 （K-NearestNeighbors）&lt;/li&gt;
  &lt;li&gt;支持向量机 （Support Vector Machines）&lt;/li&gt;
  &lt;li&gt;决策树 （Decision Trees）&lt;/li&gt;
  &lt;li&gt;提升（Boosting）&lt;/li&gt;
  &lt;li&gt;梯度提高树（Gradient Boosted Trees）&lt;/li&gt;
  &lt;li&gt;随机树 （Random Trees）&lt;/li&gt;
  &lt;li&gt;超随机树 （Extremely randomized trees）&lt;/li&gt;
  &lt;li&gt;期望最大化 （Expectation Maximization）&lt;/li&gt;
  &lt;li&gt;神经网络 （Neural Networks）&lt;/li&gt;
  &lt;li&gt;MLData&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;【nonfree】&lt;/strong&gt;，也就是一些具有专利的算法模块 ，包含特征检测和GPU相关的内容。最好不要商用，可能会被告哦。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【objdetect】&lt;/strong&gt;——目标检测模块，包含Cascade Classification（级联分类）和Latent SVM这两个部分。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【ocl】&lt;/strong&gt;——即OpenCL-accelerated Computer Vision，运用OpenCL加速的计算机视觉组件模块&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【photo】&lt;/strong&gt;——也就是Computational Photography，包含图像修复和图像去噪两部分&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【stitching】&lt;/strong&gt;——images stitching，图像拼接模块，包含如下部分：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;拼接流水线&lt;/li&gt;
  &lt;li&gt;特点寻找和匹配图像&lt;/li&gt;
  &lt;li&gt;估计旋转&lt;/li&gt;
  &lt;li&gt;自动校准&lt;/li&gt;
  &lt;li&gt;图片歪斜&lt;/li&gt;
  &lt;li&gt;接缝估测&lt;/li&gt;
  &lt;li&gt;曝光补偿&lt;/li&gt;
  &lt;li&gt;图片混合&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;【superres】&lt;/strong&gt;——SuperResolution，超分辨率技术的相关功能模块&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【ts】&lt;/strong&gt;——opencv测试相关代码，不用去管他&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【video】&lt;/strong&gt;——视频分析组件，该模块包括运动估计，背景分离，对象跟踪等视频处理相关内容。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;【Videostab】&lt;/strong&gt;——Video  stabilization，视频稳定相关的组件，官方文档中没有多作介绍，不管它了。&lt;/p&gt;

</description>
        <pubDate>Fri, 29 Jul 2016 07:09:09 +0000</pubDate>
        <link>http://liuious.github.io/2016/07/29/opencv_modules.html</link>
        <guid isPermaLink="true">http://liuious.github.io/2016/07/29/opencv_modules.html</guid>
        
        <category>OpenCV</category>
        
        
      </item>
    
      <item>
        <title>SDWebImage学习笔记</title>
        <description>&lt;p&gt;SDWebImage托管在github上&lt;a href=&quot;SDWebImage托管在github上。https://github.com/rs/SDWebImage&quot;&gt;https://github.com/rs/SDWebImage&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SDWebImage&lt;/strong&gt;功能如下：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;提供UIImageView的一个分类，以支持网络图片的加载与缓存管理&lt;/li&gt;
  &lt;li&gt;一个异步的图片加载器&lt;/li&gt;
  &lt;li&gt;一个异步的内存+磁盘图片缓存&lt;/li&gt;
  &lt;li&gt;支持GIF图片&lt;/li&gt;
  &lt;li&gt;支持WebP图片&lt;/li&gt;
  &lt;li&gt;后台图片解压缩处理&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;主要优点&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;确保同一个URL的图片不被下载多次&lt;/li&gt;
  &lt;li&gt;确保虚假的URL不会被反复加载&lt;/li&gt;
  &lt;li&gt;确保下载及缓存时，主线程不被阻塞&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;主要代码解析：&lt;/strong&gt;&lt;br /&gt;
下载的枚举类型&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;k&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;NS_OPTIONS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NSUInteger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderOptions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   
  &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderLowPriority&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    
  &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderProgressiveDownload&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    
  &lt;span class=&quot;cm&quot;&gt;/**
   * By default, request prevent the of NSURLCache. With this flag, NSURLCache
   * is used with default policies.
   * 默认情况下请求，但是不实用NSURLCache，如果设置该选项，则以默认的缓存策略来使用NSURLCache
  */&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderUseNSURLCache&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    
  &lt;span class=&quot;cm&quot;&gt;/**
   * Call completion block with nil image/imageData if the image was read from NSURLCache
   * (to be combined with SDWebImageDownloaderUseNSURLCache ).
   * 如果从NSURLCache缓存中读取图片，则使用nil作为参数来调用完成block
   */&lt;/span&gt;
     
  &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderIgnoreCachedResponse&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    
  &lt;span class=&quot;cm&quot;&gt;/**
   * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for
   * extra time in background to let the request finish. If the background task expires the operation will be cancelled.
   * 在iOS4+中， 允许程序在后台下载图片， 该操作通过向系统申请额外的时间来完成后台下载，如果后台任务终止，则会被取消。
  */&lt;/span&gt;
     
  &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderContinueInBackground&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    
  &lt;span class=&quot;cm&quot;&gt;/**
   * Handles cookies stored in NSHTTPCookieStore by setting 
   * NSMutableURLRequest.HTTPShouldHandleCookies = YES;
   * 通过设置NSMutableURLRequest。httpshouldHandleCookies=YES来处理存储在NSHTTPCookieStore中的cookie
   */&lt;/span&gt;
     
  &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderHandleCookies&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    
  &lt;span class=&quot;cm&quot;&gt;/**
   * Enable to allow untrusted SSL ceriticates.
   * Useful for testing purposes. Use with caution in production.
   * 允许不受信任的ssl证书，主要用于测试目的
   */&lt;/span&gt;
     
  &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderAllowInvalidSSLCertificates&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    
  &lt;span class=&quot;cm&quot;&gt;/**
   * Put the image in the high priority queue.
   * 将图片下载防盗高优先级队列中
   */&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderHighPriority&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;下载顺序:
SDWebImage提供了两种下载顺序，一种是以队列方式（先进先出），一种是以栈的方式（后进先出）。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;k&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;NS_ENUM&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NSInteger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderExecutionOrder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;cm&quot;&gt;/**
     * Default value. All download operations will execute in queue style (first-in-first-out).
     * 默认用队列的方式， 按照fifo的方式下载
     */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderFIFOExecutionOrder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;cm&quot;&gt;/**
     * All download operations will execute in stack style (last-in-first-out).
     * 以栈的方式
     */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderLIFOExecutionOrder&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;下载任务管理器
SDWebImageDownloader下载管理器是一个单例类，主要负责图片的下载操作管理，图片的下载是放在一个NSOperationQueue操作队列中来完成的，它的声明如下：&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;property&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strong&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nonatomic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NSOperationQueue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;downloadQueue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;//使用NSOperationQueue操作队列来完成下来&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;默认情况下，队列最大的并发数是&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，如果需要我们可以通过&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDWebImageDownloader&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;类的&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;maxConcurrentDownloads&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;属性来修改。&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;所有下载操作的网络响应序列化处理都放在一个自定义的并行调度队列中来处理，其声明及定义如下：&lt;/span&gt; 
&lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;property&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDDispatchQueueSetterSementics&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nonatomic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dispatch_queue_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;barrierQueue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;init&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;_barrierQueue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dispatch_queue_create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;com.hackemist.SDWebImageDownloaderBarrierQueue&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DISPATCH_QUEUE_CONCURRENT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;每一个图片的下载都会对应一些回调操作，如下载进度回调、下载结果回调等，这些回调操作是block形式来呈现，为此在SDWebImageDownloader.h中定义了几个block，&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;cm&quot;&gt;/**
 *  下载进度回调
 */&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderProgressBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NSInteger&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;receivedSize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NSInteger&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;expectedSize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NSData&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;cm&quot;&gt;/**
 *  下载完成回调
 */&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderCompletedBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;UIImage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NSData&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NSError&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BOOL&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;finished&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;cm&quot;&gt;/**
 *  Header过滤
 */&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NSDictionary&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderHeadersFilterBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NSURL&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NSDictionary&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;图片下载的这些回调信息存储在SDWebImageDownloader类的URLCallbacks属性中，该属性是个字典，key为图片的URL地址，value是个数组，包含每个图片的多组回调信息，由于我们允许多个图片同事下载，因此可能会有多个线程对URLCallbacks同事操作，为了保证URLCallbacks操作的线程安全性，SDWebImageDownloader将这些操作作为一个任务放在barrierQueue队列中，并设置屏障来确保同一时间只有一个线程操作URLCallbacks属性，我们以添加操作为例，&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addProgressCallback&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderProgressBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;progressBlock&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;andCompletedBlock&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDWebImageDownloaderCompletedBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;completedBlock&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;forURL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NSURL&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;createCallback&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SDWebImageNoParamsBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;createCallback&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
 
    &lt;span class=&quot;cm&quot;&gt;/**
     *  确保同一时间只有一个线程能对URLCallbacks进行操作,有兴趣的同学可以查阅下dispatch_barrier_sync方法相关的描述这里不一一细说
     */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;dispatch_barrier_sync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;barrierQueue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// Handle single download of simultaneous download request for the same URL&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 处理同一url的同步下载请求的单个下载&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;NSMutableArray&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;callbacksForURL&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;URLCallbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;NSMutableDictionary&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;callbacks&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NSMutableDictionary&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;progressBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kProgressCallbackKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;progressBlock&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;completedBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kCompletedCallbackKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;completedBlock&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;callbacksForURL&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;addObject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;URLCallbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;callbacksForURL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;createCallback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
</description>
        <pubDate>Wed, 27 Jul 2016 06:51:01 +0000</pubDate>
        <link>http://liuious.github.io/2016/07/27/sdwebimage_note.html</link>
        <guid isPermaLink="true">http://liuious.github.io/2016/07/27/sdwebimage_note.html</guid>
        
        <category>iOS</category>
        
        
      </item>
    
      <item>
        <title>基于fink的opencv搭建</title>
        <description>&lt;p&gt;转自&lt;a href=&quot;http://tianchunbinghe.blog.163.com/blog/static/7001201151592834161/&quot;&gt;在MacOSX10.6下编译安装高性能OpenCV库&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;最初由 Intel 开发的 &lt;a href=&quot;http://opencv.org/&quot;&gt;OpenCV&lt;/a&gt;库已经逐渐成为目前计算机视觉和图像识别领域的事实标准了，教科书里几乎所有的主流图形算法都在 OpenCV 里可以找到高效的实现。为了完成公司安排给我的工作，这个库是我的必经之路，道理很简单：我不可能花费一个相关专业的硕士研究生的在校时间去把所有底层算法从头学习并实现一遍，我的时间顶多只有一两个月，因此重要的是如何用尽可能少的时间把整个工作中我最不擅长的部分用现成的开源软件来完成。&lt;/p&gt;

&lt;p&gt;作为一个前 Linux 系统管理员，安装各种软件是我最拿手的事情。OpenCV的安装并不难，但是严格按照官方的&lt;a href=&quot;https://github.com/opencv/opencv/wiki&quot;&gt;安装向导&lt;/a&gt;来操作并不能得到一个真正高效的库。这个库的性能直接决定了我的工作效率：一次典型的机器学习过程在一台普通的电脑上单CPU执行通常需要花费几个小时到几天的时间，但如果我可以多核一起计算，就可以几倍地节省时间，把一次机器学习的时间减少到从几十分钟到几个小时的尺度上，从而可以轻松地调节机器学习过程中的各种参数并快速尝试多种分类器。目前我使用的MacBookPro带有4核超线程的2.2GHz Intel i7处理器，最近的实践表明它如果满负荷地跑起来至少比我另一台双核2.66GHz Intel Cuo 2 Duo 处理器的 Mac mini 快 6倍。因此，为了实现高性能的计算，我在编译安装 OpenCV 时必须达到以下两个目标：&lt;br /&gt;
  1.将 OpenCV 库编译成 64 位的 (x86_64)；&lt;br /&gt;
  2.OpenCV 支持 Intel Threading Building Block (TBB)以进行多线程计算，这个特性必须打开。&lt;br /&gt;
本文描述的是在 Mac OS X 10.6 系统上为了得到一个支持 TBB 的 64 位 OpenCV 库所进行的所有操作步骤，以供同行参考。&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;安装 64 位 Fink，以及 cmake 等各种依赖工具和库&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://finkproject.org/&quot;&gt;Fink&lt;/a&gt;是 Mac OS X 下各种开源工具的管理系统，底层基于 Debian 的 dpkg 和 apt-get。虽然 Mac OS X 下还有另一种称为 Macports 的类似平台，但我强烈推荐使用 Fink，因为 Fink 可以在 Mac 系统里同时安装两个版本，32 位的装在 /sw 目录下，64 位的装在 /sw64 目录下，从而分别满足 Mac 系统里不同类型应用程序的需求。(比如说我就需要 LispWorks 能够使用 32 位的 Berkeley DB 4.7，但同时我还需要 OpenCV 能够使用几种 64 位的开源图形库)。&lt;/p&gt;

&lt;p&gt;适用于 Mac OS X 10.6 系统的 Fink 必须从源代码安装。首先到 Fink 的&lt;a href=&quot;http://www.finkproject.org/download/srcdist.php&quot;&gt;源代码发布站点下载&lt;/a&gt;Fink 的源代码包，比如说目前的最新版 &lt;a href=&quot;http://downloads.sourceforge.net/fink/fink-0.39.3.tar.gz&quot;&gt;0.39.3&lt;/a&gt; ~/src 目录里，然后进入 fink 源代码目录，运行&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./bootstrap /sw64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Fink 随后会询问各种问题，第一个问题询问根权限的获取方法，选择使用默认值 Use sudo：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Fink must be installed and run with superuser (root) privileges. Fink can
automatically try to become root when it's run from a user account. Since
you're currently running this script as a normal user, the method you choose
will also be used immediately for this script. Avaliable methods:

(1) Use sudo
(2) Use su
(3) None, fink must be run as root

Choose a method: [1] 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;第二个问题是最重要的，一定要选择把所有软件包编译 &lt;strong&gt;64bit-only&lt;/strong&gt; 的：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Your hardware is a 64bit-compatible intel processor, so you have the option of
running Fink in 64bit-only mode.  This is not recommended for most users, since
many more packages are available for the default mode (which is mostly 32bit
but includes some 64bit packages).  Which mode would you like to use?

(1) Default (mostly 32bit)
(2) 64bit-only

Choose a mode: [1] 2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;剩下的几乎所有问题都跟后续各种软件包的源代码下载地址有关，全部采用默认值从主站点下载即可。Fink 接下来会自动下载所需的基础软件并编译安装到系统的 /sw64 目录下，完成后它会提示用户执行初始化脚本 /sw64/bin/init.sh 以设置必要的环境变量，尤其是 PATH（该脚本可以写入到 ~/.bash_profile 中以便日后打开终端窗口可以直接使用 64 位的 Fink，但如果还要安装 32 位 Fink 的话需要注意系统里不能同时设置两种 Fink 的环境变量）。然后先执行 &lt;strong&gt;fink selfupdate&lt;/strong&gt; 更新一次 Fink 自身，再执行 &lt;strong&gt;fink update-all&lt;/strong&gt; 更新所有基础软件包。接下来用 &lt;strong&gt;fink install&lt;/strong&gt; 命令安装 OpenCV 所需要的下列第三方程序和库：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;cmake，一个用来生成 Makefile 和其他 IDE (包括苹果的 Xcode) 的工程文件的程序:&lt;/li&gt;
  &lt;li&gt;libpng14，PNG 图片支持库&lt;/li&gt;
  &lt;li&gt;libjpeg，JPEG 图片支持库&lt;/li&gt;
  &lt;li&gt;libtiff，TIFF 图片支持库&lt;/li&gt;
  &lt;li&gt;libjasper.1，JPEG-2000 图片支持库&lt;/li&gt;
  &lt;li&gt;pkgconfig，一个帮助寻找各种依赖库的辅助程序&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;我不需要视频相关的功能，因此以 ffmpeg 为首的各种视频相关的程序库我都没有安装，直接输入一次 fink 命令就可以安装所有上述依赖库了：(各种文件格式的支持库如果不安装的话也可以，OpenCV 源代码自带了，但我觉得还是用 Fink 系统的比较好，至少以后升级方便)&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ fink install cmake libpng14 libjpeg libtiff libjasper.1 pkgconfig 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2.&lt;strong&gt;安装 Intel Threading Building Blocks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://threadingbuildingblocks.org/&quot;&gt;Intel Threading Building Blocks&lt;/a&gt; (TBB) 类似于以前的 OpenMP 和苹果系统自带的 GCD，用于帮助用户创建隐式的并行计算程序，底层依赖于操作系统的多线程库。TBB 最初是 Intel 的商业软件，但自从 3.0 以后就开源了，同时 Intel 仍然销售带有技术支持的商业版本。我在其下载站点上&lt;a href=&quot;https://www.threadingbuildingblocks.org/download&quot;&gt;下载&lt;/a&gt;了最新的 Commercial Aligned Release，目前的版本是 &lt;a href=&quot;https://www.threadingbuildingblocks.org/sites/default/files/software_releases/mac/tbb44_20160526oss_osx_2.tgz&quot;&gt;4.4 update 5&lt;/a&gt;。下载后我把它移动到了 /opt/intel 目录下并创建了一个软链接以便日后版本升级时可以随意切换到新版本：&lt;/p&gt;

&lt;p&gt;binghe@binghe-i7:/opt/intel$ ls -l&lt;br /&gt;
total 8&lt;br /&gt;
lrwxr-xr-x   1 root    wheel   12  6 14 13:55 tbb -&amp;gt; tbb30_196oss&lt;br /&gt;
drwxr-xr-x  10 binghe  lisp   340  5 10 18:28 tbb30_196oss&lt;/p&gt;

&lt;p&gt;然后需要做两件事，首先修改 /opt/intel/tbb/bin/tbbvars.sh 脚本文件的第一个有效行，将正确的安装位置设置到 TBB30_INSTALL_DIR 环境变量上：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;TBB30_INSTALL_DIR=&quot;/opt/intel/tbb&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;然后在 &lt;strong&gt;~/.bash_profile&lt;/strong&gt; 里添加一行以确保 TBB 库可被以后编译出来的 OpenCV 库成功加载：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;source /opt/intel/tbb/bin/tbbvars.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;操作完成以后重新打开一个终端窗口，显示 DYLD_LIBRARY_PATH 环境变量的值，里面应该包含 TBB 的路径才对：&lt;/p&gt;

&lt;p&gt;$ echo $DYLD_LIBRARY_PATH 
/opt/intel/tbb/lib&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;下载并编译 OpenCV 源代码&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;找一个比较合适的专门放源代码的地方（推荐使用 ~/src 或者 ~/Source），用 git 把最新的 OpenCV 源代码 clone 下来：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ git clone [https://github.com/opencv/opencv.git](https://github.com/opencv/opencv.git)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;然后进入 opencv 目录，执行下列 cmake 命令，创建用于编译的 Unix Makefile：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cmake -G &quot;Unix Makefiles&quot; -D BUILD_NEW_PYTHON_SUPPORT=OFF -D CMAKE_OSX_ARCHITECTURES=&quot;x86_64&quot; -D WITH_TBB=ON -D TBB_INCLUDE_DIR=/opt/intel/tbb/include .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;这是整个编译过程的关键所在。我不编译 Python 支持，强制编译成 64 位，并且要求其打开 TBB 支持。cmake 最后会输出一个汇总报告：&lt;/p&gt;

&lt;p&gt;– 
– General configuration for opencv 2.2.9 ===========&lt;br /&gt;
– &lt;br /&gt;
–     Built as dynamic libs?:     ON&lt;br /&gt;
–     Compiler:                   &lt;br /&gt;
–     C++ flags (Release):          -Wall -pthread  -O3 -DNDEBUG    -fomit-frame-pointer -O3 -ffast-math -msse -msse2 -DNDEBUG 
–     C++ flags (Debug):            -Wall -pthread  -g  -O0 -ggdb3 -DDEBUG -D_DEBUG &lt;br /&gt;
–     Linker flags (Release):      &lt;br /&gt;
–     Linker flags (Debug):        &lt;br /&gt;
– &lt;br /&gt;
–   GUI: &lt;br /&gt;
–     Cocoa:                      YES&lt;br /&gt;
– &lt;br /&gt;
–   Media I/O: &lt;br /&gt;
–     ZLib:                       TRUE&lt;br /&gt;
–     JPEG:                       TRUE&lt;br /&gt;
–     PNG:                        TRUE&lt;br /&gt;
–     TIFF:                       TRUE&lt;br /&gt;
–     JPEG 2000:                  TRUE&lt;br /&gt;
–     OpenEXR:                    NO&lt;br /&gt;
–     OpenNI:                     FALSE&lt;br /&gt;
– &lt;br /&gt;
–   Video I/O:                    QTKit&lt;br /&gt;
– &lt;br /&gt;
–   Interfaces: &lt;br /&gt;
–     Python:                     OFF&lt;br /&gt;
–     Python interpreter:         &lt;br /&gt;
–     Python numpy:               NO (Python interface will not cover OpenCV 2.x API)&lt;br /&gt;
–     Use IPP:                    NO&lt;br /&gt;
–     Use TBB:                    YES&lt;br /&gt;
–     Use Cuda:                   NO&lt;br /&gt;
–     Use Eigen:                  NO&lt;br /&gt;
– &lt;br /&gt;
–   Documentation: &lt;br /&gt;
–     Build Documentation:        NO &lt;br /&gt;
– &lt;br /&gt;
–     Install path:               /usr/local&lt;br /&gt;
– &lt;br /&gt;
–     cvconfig.h is in:           /users/binghe/src/o/opencv&lt;br /&gt;
– —————————————————————–&lt;br /&gt;
– &lt;br /&gt;
– Configuring done&lt;br /&gt;
– Generating done&lt;br /&gt;
– Build files have been written to: /users/binghe/src/o/opencv&lt;/p&gt;

&lt;p&gt;其中最关键的部分是，Use TBB 一项必须正确地显示为 YES，否则说明 TBB 库没有安装好，那么最后编译出来的 OpenCV 也就是废材一个了。如果已经成功走到这一步了，接下来就可以用 make 命令编译了。并行编译是允许了，我的系统有 2 个逻辑 CPU，所以可以全部用来加速编译过程，编译成功后再用 sudo make install 把它安装到 /usr/local 下：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ make -j 2  
$ sudo make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;编译和安装成功的标志是查看 /usr/local/lib 下的一个 OpenCV 库文件的依赖库时应该可以看到 libtbb.dylib，然后用 file 命令可以确认这是一个纯 64 位的库：&lt;/p&gt;

&lt;p&gt;$ otool -L /usr/local/lib/libopencv_core.dylib 
   /usr/local/lib/libopencv_core.dylib:
 lib/libopencv_core.2.2.dylib (compatibility version 2.2.0, current version 2.2.9)&lt;br /&gt;
    libtbb.dylib (compatibility version 0.0.0, current version 0.0.0)&lt;br /&gt;
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)&lt;br /&gt;
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)&lt;br /&gt;
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)&lt;br /&gt;
$ file /usr/local/lib/libopencv_core.dylib&lt;br /&gt;
   /usr/local/lib/libopencv_core.dylib: Mach-O 64-bit dynamically linked shared library x86_64&lt;/p&gt;

&lt;p&gt;4.&lt;strong&gt;测试&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;这样就顺利编译完成了。最后我们用一个简单的程序测试一下其可用性：&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include &quot;opencv/highgui.h&quot;
&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;IplImage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cvLoadImage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;cvNamedWindow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Example1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CV_WINDOW_AUTOSIZE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;cvShowImage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Example1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;cvWaitKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;cvReleaseImage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;cvDestroyWindow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Example1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;上述代码保存成 hello.c 以后用下列命令行应当能够成功编译成一个可执行文件 hello：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ gcc -lopencv_highgui -lopencv_core -o hello hello.c
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;然后以一个图片文件名为参数调用该程序应该可以在一个图形窗口里显示该图片的内容。如果程序正常运行，那么就说明 OpenCV 的安装成功了。&lt;/p&gt;
</description>
        <pubDate>Wed, 27 Jul 2016 06:15:44 +0000</pubDate>
        <link>http://liuious.github.io/2016/07/27/opencvfink.html</link>
        <guid isPermaLink="true">http://liuious.github.io/2016/07/27/opencvfink.html</guid>
        
        <category>OpenCV</category>
        
        
      </item>
    
      <item>
        <title>Welcome to Jekyll!</title>
        <description>&lt;p&gt;You’ll find this post in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll serve&lt;/code&gt;, which launches a web server and auto-regenerates your site when a file is updated.&lt;/p&gt;

&lt;p&gt;To add new posts, simply add a file in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; directory that follows the convention &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YYYY-MM-DD-name-of-post.ext&lt;/code&gt; and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.&lt;/p&gt;

&lt;p&gt;Jekyll also offers powerful support for code snippets:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print_hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hi, &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;print_hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Tom'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#=&amp;gt; prints 'Hi, Tom' to STDOUT.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Check out the &lt;a href=&quot;http://jekyllrb.com&quot;&gt;Jekyll docs&lt;/a&gt; for more info on how to get the most out of Jekyll. File all bugs/feature requests at &lt;a href=&quot;https://github.com/jekyll/jekyll&quot;&gt;Jekyll’s GitHub repo&lt;/a&gt;. If you have questions, you can ask them on &lt;a href=&quot;https://github.com/jekyll/jekyll-help&quot;&gt;Jekyll’s dedicated Help repository&lt;/a&gt;.&lt;/p&gt;

</description>
        <pubDate>Sun, 08 Mar 2015 22:21:49 +0000</pubDate>
        <link>http://liuious.github.io/2015/03/08/welcome-to-jekyll.html</link>
        <guid isPermaLink="true">http://liuious.github.io/2015/03/08/welcome-to-jekyll.html</guid>
        
        <category>Jekyll</category>
        
        
      </item>
    
  </channel>
</rss>
