zoukankan      html  css  js  c++  java
  • 使用OpenCL提升OpenCV图像处理性能 | speed up opencv image processing with OpenCL

    本文首发于个人博客https://kezunlin.me/post/59afd8b3/,欢迎阅读最新内容!

    speed up opencv image processing with OpenCL

    Guide

    OpenCL is a framework for writing programs that execute on these heterogenous platforms. The developers of an OpenCL library utilize all OpenCL compatible devices (CPUs, GPUs, DSPs, FPGAs etc) they find on a computer / device and assign the right tasks to the right processor.
    Keep in mind that as a user of OpenCV library you are not developing any OpenCL library. In fact you are not even a user of the OpenCL library because all the details are hidden behind the transparent API/TAPI.

    config

    cmake config by default for compiling OpenCV:

    WITH_OPENCL ON
    

    example

    Mat

    #include "opencv2/opencv.hpp"
    using namespace cv;
     
    int main(int argc, char** argv)
    {
        Mat img, gray;
        img = imread("image.jpg", IMREAD_COLOR);
         
        cvtColor(img, gray, COLOR_BGR2GRAY);
        GaussianBlur(gray, gray,Size(7, 7), 1.5);
        Canny(gray, gray, 0, 50);
         
        imshow("edges", gray);
        waitKey();
        return 0;
    }
    

    UMat

    #include "opencv2/opencv.hpp"
    using namespace cv;
     
    int main(int argc, char** argv)
    {
        UMat img, gray;
        imread("image.jpg", IMREAD_COLOR).copyTo(img);
         
        cvtColor(img, gray, COLOR_BGR2GRAY);
        GaussianBlur(gray, gray,Size(7, 7), 1.5);
        Canny(gray, gray, 0, 50);
         
        imshow("edges", gray);
        waitKey();
        return 0;
    }
    

    UMat with transparent API/TAPI

    Reference

    History

    • 20190626: created.

    Copyright

  • 相关阅读:
    2020.06.09——习题训练五
    2020.06.01——习题训练4
    2020-05-26 — 习题训练三
    2020-05-22 — 习题训练二-F
    Java笔记(22):IO流(04)
    Java笔记(21):IO流(03)
    Java笔记(20):IO流(02)
    Java笔记(19):IO流(01)
    Java笔记(18):集合框架(04)
    Java笔记(17):集合框架(03)
  • 原文地址:https://www.cnblogs.com/kezunlin/p/11940014.html
Copyright © 2011-2022 走看看