基于OpenCL的OpenCV扩展库发布了
来源:互联网 发布:远程网络教学系统类图 编辑:程序博客网 时间:2024/05/18 00:35
参考链接:http://bbs.csdn.net/topics/390145759
1 扩展库简介
OpenCV(Open Source Computer Vision Library)是一个致力于实时处理计算机视觉问题的开源库。它最初由Intel公司开发,以GPL许可协议发布,后来由Willow Garage基金会负责开发和维护,以BSD许可协议发布,至今已有超过250万的用户。其用途非常广泛,涵盖从图像处理,计算机视觉到交互艺术,矿产勘探等领域。OpenCV最初以C语言编写,后来提供了C++和Python接口,在版本2.2中又加入了CUDA接口,目前的正式版本为2.4。
OpenCL(Open Computing Language)是一个在异构平台(例如:CPU和GPU,APU)上高效执行程序的开源计算框架,它由Khronos发布并维护,是一个IBM, Intel, AMD等业界公司普遍认可和支持的标准,目前版本为1.2。OpenCL包含一组用于定义和控制平台的API和一个基于C99标准的编写的可执行在并行设备上的kernel。它使应用程序能够在GPU上执行,使GPU可以不仅执行图形程序,而且可以执行通用计算程序(GPGPU)。
虽然OpenCV的目标是能够实时的处理计算机视觉问题,但是大多数计算机视觉的算法太过复杂,无法在CPU上实时执行。而计算机视觉的大多数算法具有天生的并行性,非常适合在GPU和APU上执行并获得可观的加速比。本工程使用和OpenCV兼容的C/C++编写,致力于为OpenCV添加OpenCL接口,使得OpenCV的函数能够在异构设备上高速运行。由于OpenCL是一个跨平台的开放标准,所有支持OpenCL的平台都将获益。
2 OpenCV的架构
OpenCV可以分成以下一些模块,以执行设备来分类的话有CPU和GPU之分,GPU中原有CUDA模块,现在我们加入OpenCL模块,OpenCL模块将在CPU上执行的算法在GPU上加速执行。
为了获得良好的性能而又不损失灵活性,我们将OpenCV中最重要的基础结构二维矩阵映射为GPU上的二维Buffer,没有使用OpenCL中得Image对象。这样做可以更有效率的处理单通道数据。
补充:
Since version 2.2, the OpenCV library is divided into several modules. These modules are built in library fles located in the lib directory. They are:
1 The opencv_core module that contains the core functionalities of the library, in particular, the basic data structures and arithmetic functions.
2 The opencv_imgproc module that contains the main image processing functions.
3 The opencv_highgui module that contains the image and video reading and writing functions, along with other user interface functions.
4 The opencv_features2d module that contains the feature point detectors and descriptors and the feature point matching framework.
5 The opencv_calib3d module that contains the camera calibration, two-view geometry estimation, and stereo functions.
6 The opencv_video module that contains the motion estimation, feature tracking, and foreground extraction functions and classes.
7 The opencv_objdetect module containing the object detection functions such as the face and people detectors.
The library also includes other utility modules containing machine learning functions (opencv_ml), computational geometry algorithms (opencv_flann), contributed code (opencv_contrib), obsolete code (opencv_legacy), and GPU accelerated code (opencv_gpu).
All of these modules have a header fle associated with them (located in include directory).
Typical OpenCV C++ code will therefore start by including the required modules. For example
(and this is the suggested declaration style):
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
If you see OpenCV code starting with:
#include "cv.h"
it is because it uses the old style, before the library was restructured into modules.
翻译:
opencv自从2.2版本起,将库分成很多模块,这些模块编译成库,放在opencv的lib文件夹下。他们分别是:
1. opencv_core 模块 它包含库的核心函数,实际上它包含基本的数据结构和算术函数
2. opencv_imgproc 模块 它包含主要的图像处理函数
3. The opencv_highgui 模块,它包含图像和视频的读写函数以及用户交互函数
4. opencv_features2d 模块,它包含特征点的检测、描述以及匹配的框架
5. opencv_calib3d 模块,它包含摄像头的校准,双目几何估计和立体函数
6. opencv_video 模块,它包含运动目标估计,特征跟踪和前景提取的函数和类
7. opencv_objdetect 模块,它包含目标检测函数如人脸检测,和行人检测
opencv库还包含其他单元模块如机器学习模块 (opencv_ml), 计算几何算法模块(opencv_flann), 已贡献代码模块(opencv_contrib), 过时的代码模块opencv_legacy以及图形加速模块(opencv_gpu).
所有的模块都有一个与之关联的头文件(在include路径下)
典型的OPENCV c++代码通常以包含这些必须的模块开始,如:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
OpenCV拥有四百多个函数,并且有些函数的算法十分复杂,由于时间和资源所限,目前的OpenCL并没有包含所有的函数,以下是目前已经经过加速的函数列表
4 性能测试结果
通过GPU的加速和对代码的优化,我们获得了可观的加速比,整体而言,我们对CUDA有1.2倍的加速,对CPU有平均60倍的加速(kernel时间vsCPU时间)。以下是我们的测试平台和测试结果。
表2:测试平台
图2:OpenCL vs. CUDA 纵坐标为加速比
图3:OpenCL vs. CPU纵坐标为加速比
5 资源获取
基于OpenCL的OpenCV扩展库已经进入官方的svn,可以在此下载最新代码,也可以在Google Code中下载。
OpenCV official svn: http://code.opencv.org/svn/opencv/branches/ocl
下载:http://code.opencv.org/svn/opencv/trunk
- 基于OpenCL的OpenCV扩展库发布了
- OpenCV对OpenCL的支持
- 为Android平台编译支持OpenCL的Opencv静态库
- OpenCL扩展
- Nvidia 在11.26号发布了新的Toolkit version3.2 支持OpenCL
- 基于 Mozilla Firefox 的 Watir 发布了!
- 使用OpenCV的OpenCL(ocl)模块
- OpenCV OpenCL Gtest 工程框架的问题。
- 使用OpenCV的OpenCL(ocl)模块
- 使用OpenCV的OpenCL(ocl)模块
- 已移植到OpenCL的OpenCV功能
- 使用OpenCV的OpenCL(ocl)模块
- 【转载】使用OpenCV的OpenCL(ocl)模块
- 使用OpenCV的OpenCL(ocl)模块
- php-beanstalk扩展发布了
- 基于OpenCL的mean filter性能
- 【OpenCV开发】使用OpenCV的OpenCL(ocl)模块
- OpenCV 2.4 正式版发布了
- Linux操作系统文件系统基础知识详解
- Tengine 淘宝Web服务器 试用
- 用Java实现HTTP断点续传功能
- sql 使用触发器如何update多条记录
- linux开启启动 svn服务器
- 基于OpenCL的OpenCV扩展库发布了
- 20条常见的编码陷阱 你中枪了没?
- Java、C#区别之语法
- Ubuntu下使用源码文件安装软件(二)
- 领导者需要哪种权力?
- Android实现异步加载图片 ListView(转)
- Eclipse背景颜色修改方案
- 尊重他才能留住他
- IOS5基础十七------可编辑的详细单元格