【CUDA编程笔记】(3)opencv4 + CUDA 并行图像处理实战入门:图像均值滤波和图像反色

本文介绍了如何在CUDA环境下结合OpenCV4进行图像处理,包括环境配置、CUDA与OpenCV的结合方法。通过一个具体的例子展示了如何实现图像的均值滤波和反色操作,并详细讨论了网格大小和线程块大小的确定,以及并行与串行计算的加速比。实验表明,随着计算量增大,GPU并行计算的优势更为明显。
摘要由CSDN通过智能技术生成

相关阅读:

【CUDA编程笔记】(1)CUDA C 编程入门

【CUDA编程笔记】(2)CPU与GPU之间的参数传递

一、环境配置与测试

因为学校的机房vs2017已经配置好 cuda10.0 了,但没有配置opencv,所以这里只考虑配置opencv的事情,opencv4的配置参考视频 VS_2017(Visual Studio)配置OpenCV教程

跟着上面教程配置好opencv之后,新建一个cuda10.0 runtime的项目,在kernel.cu文件中运行以下测试代码:

测试代码来源于 Opencv4+cuda 加速开发教程笔记

#include <opencv2/opencv.hpp>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>


int main() {
   
	int deviceCount;
	cudaGetDeviceCount(&deviceCount);

	int dev;
	for (dev = 0; dev < deviceCount; dev++)
	{
   
		int driver_version(0), runtime_version(0);
		cudaDeviceProp deviceProp;
		cudaGetDeviceProperties(&deviceProp, dev);
		if (dev == 0)
			if (deviceProp.minor = 9999 && deviceProp.major == 9999)
				printf("\n");
		printf("\nDevice%d:\"%s\"\n", dev, deviceProp.name);
		cudaDriverGetVersion(&driver_version);
		printf("CUDA驱动版本:                                   %d.%d\n", driver_version / 1000, (driver_version % 1000) / 10);
		cudaRuntimeGetVersion(&runtime_version);
		printf("CUDA运行时版本:                                 %d.%d\n", runtime_version / 1000, (runtime_version % 1000) / 10);
		printf("设备计算能力:                                   %d.%d\n", deviceProp.major, deviceProp.minor);
		printf("Total amount of Global Memory:                  %u bytes\n", deviceProp.totalGlobalMem);
		printf("Number of SMs:                                  %d\n", deviceProp.multiProcessorCount);
		printf("Total amount of Constant Memory:                %u bytes\n", deviceProp.totalConstMem);
		printf("Total amount of Shared Memory per block:        %u bytes\n", deviceProp.sharedMemPerBlock);
		printf(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ctrl A_ctrl C_ctrl V

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值