OPENCV(opencv2和opencv3.3)用GPU加速

OpenCV3.1 使用GPU及OpenCL加速的教程

OpenCV内部很多函数都已经实现了GPU加速, 新发布的OpenCV3.0版本很方便的解决了这个问题,只要你使用UMat即可。

cuda初始化需要时间,而且你传入cuda也有时间。

首先你得说一下你是直接用的Cuda Runtime API/Cuda Driver API,还是用的OpenCV封装的CUDA API

CUDA与OpenCV混合编译:CUDA与OpenCV的混合编译其实就是讲.cu文件与.c/.cpp文件混合编译

The OpenCV GPU module is a set of classes and functions to utilize GPU computational capabilities. 
It is implemented using NVIDIA* CUDA* Runtime API and supports only NVIDIA GPUs.


OPENCV用GPU加速的例子,是用cmake编译opencv,勾选上with cuda
需要重新编译opencv 的,最后getCudaEnabledDeviceCount(); 这个函数返回值大于零才行

// first.cpp : 定义控制台应用程序的入口点。
 
#include "stdafx.h"
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"
 
#pragma comment(lib,"opencv_gpu2410.lib")
#pragma comment(lib,"opencv_core2410.lib")
 
using namespace std; 
using namespace cv; 
using namespace cv::gpu;
int main()
{
    int i;
    try
    {
        cout << getCudaEnabledDeviceCount();
    }
    catch(const cv::Exception& ex)
    {    
            cout << "Error:" << ex.what() <<endl;
    }
    system("PAUSE");
    return 0;
}

OpenCV中GPU模块使用

VS2015+opencv3.3 GPU模块编译(包含opencv_contrib模块)
转:https://blog.csdn.net/mangobar/article/details/80459149

猜你喜欢

转载自blog.csdn.net/eric_e/article/details/83904897