本文共 553 字,大约阅读时间需要 1 分钟。
一、环境配置
1、VS+CUDA环境搭建:参考我的文章:
2、CUDA版本的OpenCV:参考我的文章:
二、简单示例
1、新建控制台项目
2、在源文件中加载头文件如下:
#include "stdafx.h"#include "cuda_runtime.h"#include "device_launch_parameters.h"#include#include #include #include using namespace std;using namespace cv;using namespace cuda;
3、操作GpuMat像素在__global__函数中进行,返回值一定是void,此处操作的是将偶数行的像素置为255。
/*** GPU访问数据* @param mat GpuMat被强转为PtrStep<>类型之后的参数*/__global__ void removeRowPointProcess(PtrStepSzmat){ int i = threadIdx.x + blockIdx.x * blockDim.x; //列坐标 int
转载地址:http://lyulf.baihongyu.com/