当前位置:网站首页>Introduction to OpenCL of opencv
Introduction to OpenCL of opencv
2022-04-21 19:42:00 【꧁ under poplar ꧂】
Intro
Introduce
Open Computing Language (OpenCL) is an open standard for writing code that runs across heterogeneous platforms including CPUs, GPUs, DSPs and etc. In particular OpenCL provides applications with an access to GPUs for non-graphical computing (GPGPU) that in some cases results in significant speed-up. In Computer Vision many algorithms can run on a GPU much more effectively than on a CPU: e.g. image processing, matrix arithmetic, computational photography, object detection etc.
Open computing language (OpenCL) It's an open standard , Used to write cross heterogeneous platforms ( Include CPU、GPU、DSP etc. ) Running code . In especial ,OpenCL Provides support for applications GPU The interview of , For non graphical calculations (GPGPU), In some cases, it will significantly increase the speed . In computer vision , Many algorithms can be used in GPU Compared with CPU Run more effectively on : For example, image processing 、 Matrix operations 、 Computational photography 、 Target detection, etc .
History
history
Acceleration of OpenCV with OpenCL started 2011 by AMD. As the result the OpenCV-2.4.3 release included the new oclmodule containing OpenCL implementations of some existing OpenCV algorithms. That is, when OpenCL runtime and a compatible device are available on a client machine, user may call cv::ocl::resize() instead of cv::resize() to use the accelerated code. During 3 years more and more functions and classes have been added to the ocl module; but it has been a separate API alongside with the primary CPU-oriented API in OpenCV-2.x.
AMD from 2011 Year started OpenCL Speed up OpenCV. therefore ,OpenCV-2.4.3 The version includes the new OCL modular , It includes some existing OpenCV Algorithm OpenCL Realization . in other words , When there is... On the client computer OpenCL Runtime and compatible devices , Users can call cv::ocl::resize() instead of cv::resize() To use accelerated code . For three years ,ocl More and more functions and classes have been added to the module ; But it has something to do with OpenCV-2 The main aspects of CPU Of API Related independence .
In OpenCV-3.x the architecture concept has been changed to the so-called Transparent API (T-API). In the new architecture a separate OpenCL-accelerated cv::ocl::resize() is removed from external API and becomes a branch in a regular cv::resize(). This branch is called automatically when it’s possible and makes sense from the performance point of view. The T-API implementation was sponsored by AMD and Intel companies.
stay OpenCV-3.x in , The concept of architecture has been changed to so-called transparency API(T-API). In the new architecture , A single OpenCL Speed up cv::ocl::resize() From the outside API Delete in , And become routine cv::resize() A branch of . Where possible , This branch will be called automatically , And from a performance point of view , This branch is meaningful .T-API The realization of is by AMD And Intel sponsored .
Numbers
Some performance numbers are shown on the picture below:
Some performance data are shown in the figure below :

Code sample
Code example
Regular CPU code
routine CPU Code
// initialization
VideoCapture vcap(...);
CascadeClassifier fd("haar_ff.xml");
Mat frame, frameGray;
vector<rect> faces;
for(;;){
// processing loop
vcap >> frame;
cvtColor(frame, frameGray, BGR2GRAY);
equalizeHist(frameGray, frameGray);
fd.detectMultiScale(frameGray, faces, ...);
// draw rectangles …
// show image …
}
OpenCL-aware code OpenCV-2.x
Support OpenCL Code for OpenCV-2.x
// initialization
VideoCapture vcap(...);
ocl::OclCascadeClassifier fd("haar_ff.xml");
ocl::oclMat frame, frameGray;
Mat frameCpu;
vector<rect> faces;
for(;;){
// processing loop
vcap >> frameCpu;
frame = frameCpu;
ocl::cvtColor(frame, frameGray, BGR2GRAY);
ocl::equalizeHist(frameGray, frameGray);
fd.detectMultiScale(frameGray, faces, ...);
// draw rectangles …
// show image …
}
OpenCL-aware code OpenCV-3.x
Support OpenCL Code for OpenCV-3.x
// initialization
VideoCapture vcap(...);
CascadeClassifier fd("haar_ff.xml");
UMat frame, frameGray;
vector<rect> faces;
for(;;){
// processing loop
vcap >> frame;
cvtColor(frame, frameGray, BGR2GRAY);
equalizeHist(frameGray, frameGray);
fd.detectMultiScale(frameGray, faces, ...);
// draw rectangles …
// show image …
}
版权声明
本文为[꧁ under poplar ꧂]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211933039854.html
边栏推荐
- Robot framework log output Chinese garbled code
- Conan软件包管理器的Qt 6.2.4软件包
- Leetcode0886. Possible dichotomy (medium)
- Stm32cupeide / stm32cupemx USB link w25qxx as USB flash disk
- Building / building reusable QML modules using cmake
- Instructions of crystal Chem mouse glucose detection kit
- 调试 ms 源代码
- Installing MySQL 8 on Linux centos7 (simple and practical)
- Delete Nan data in matrix or vector in MATLAB
- MySQL de duplication query
猜你喜欢

【网络协议】ip addr

Use the mremoting tool to manage all remote connections

nodejs笔记1

Interviewer: a brief talk about go escape analysis?

Installing MySQL 8 on Linux centos7 (simple and practical)

leetcode344. Reverse string

The CPU and memory consumption are too high, but the memory and CPU occupied by the processes in the task manager cannot be seen

内网即时通讯软件优点大全分享

OpenHarmony Sensor 模块Callback注册和回调全流程

Instructions of crystal Chem mouse glucose detection kit
随机推荐
Edgeboard records
2023年东南大学劳动卫生与环境卫生学考研上岸前辈备考经验指导
调试 ms 源代码
学历造假、考试包过……考证市场有多乱
Questions fréquemment incorrectes pour la certification quotidienne du CISSP (20 avril 2022)
golang实现grpc的tcp示例
Text to SQL learning and sorting (XVII) s2sql model
杰理之不可屏蔽中断【篇】
Experience and guidance of seniors preparing for the postgraduate entrance examination of labor health and environmental hygiene of Southeast University in 2023
使用CMake构建/构建可重用的QML模块
内网即时通讯软件优点大全分享
我的“中医”就医经历
Instructions of crystal Chem mouse glucose detection kit
Lenovo promises that 100% of all computer products will contain recycled plastics by 2025
Instruction of crystal Chem active GIP ELISA Kit
Learn MySQL performance tuning and make your database smooth
多因子策略
Pat (advanced level) 1096 - continuous
auto 关键字的使用
MKL库矩阵乘法