当前位置: 首页 > news >正文

html做的网站图片横着摆放怎么自己开发网站

html做的网站图片横着摆放,怎么自己开发网站,模仿网站建设,网站加入站长统计事件计时 CUDA事件是直接在GPU上实现的,因此它们不适用于对同时包含设备代码和主机代码的混合代码计时。 cudaEventCreate 创建一个事件cudaEventRecord 记录一个事件cudaEventElapsedTime 计算两个事件之间经历的时间,第一个参数为某个浮点变量的地址…
事件计时

CUDA事件是直接在GPU上实现的,因此它们不适用于对同时包含设备代码和主机代码的混合代码计时。

  • cudaEventCreate 创建一个事件
  • cudaEventRecord 记录一个事件
  • cudaEventElapsedTime 计算两个事件之间经历的时间,第一个参数为某个浮点变量的地址,在这个参数中将包含两次事件之间经历的时间,单位是毫秒
#include <stdio.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<math.h>
#include <malloc.h> 
#include <opencv2/opencv.hpp>
#include <stdlib.h>#define BLOCK_SIZE 1//图像卷积 GPU
__global__ void sobel_gpu(unsigned char* in, unsigned char* out, const int Height, const int Width)
{int x = blockDim.x * blockIdx.x + threadIdx.x;int y = blockDim.y + blockIdx.y + threadIdx.y;int index = y * Width + x;int Gx = 0;int Gy = 0;unsigned char x0, x1, x2, x3, x4, x5, x6, x7, x8;if (x>0 && x<(Width-1) && y>0 && y<(Height-1)){x0 = in[(y - 1)*Width + (x - 1)];x1 = in[(y - 1)*Width + (x)];x2 = in[(y - 1)*Width + (x + 1)];x3 = in[(y)*Width + (x - 1)];x5 = in[(y)*Width + (x + 1)];x6 = in[(y + 1)*Width + (x - 1)];x7 = in[(y + 1)*Width + (x)];x8 = in[(y + 1)*Width + (x + 1)];Gx = (x0 + 2 * x3 + x6) - (x2 + 2 * x5 + x8);Gy = (x0 + 2 * x1 + x2) - (x6 + 2 * x7 + x8);out[index] = (abs(Gx) + abs(Gy)) / 2;}
}int main()
{cv::Mat src;src = cv::imread("complete004.jpg");cv::Mat grayImg,gaussImg;cv::cvtColor(src, grayImg, cv::COLOR_BGR2GRAY);cv::GaussianBlur(grayImg, gaussImg, cv::Size(3,3), 0, 0, cv::BORDER_DEFAULT);int height = src.rows;int width = src.cols;//输出图像cv::Mat dst_gpu(height, width, CV_8UC1, cv::Scalar(0));//GPU存储空间int memsize = height * width * sizeof(unsigned char);//输入 输出unsigned char* in_gpu;unsigned char* out_gpu;cudaMalloc((void**)&in_gpu, memsize);cudaMalloc((void**)&out_gpu, memsize);cudaEvent_t start, stop_gpu;cudaEventCreate(&start);//创建事件cudaEventCreate(&stop_gpu);//创建事件cudaEventRecord(start);//记录事件dim3 threadsPreBlock(BLOCK_SIZE, BLOCK_SIZE);dim3 blocksPreGrid((width + threadsPreBlock.x - 1)/threadsPreBlock.x, (height + threadsPreBlock.y - 1)/threadsPreBlock.y);cudaMemcpy(in_gpu, gaussImg.data, memsize, cudaMemcpyHostToDevice);sobel_gpu <<<blocksPreGrid, threadsPreBlock>>> (in_gpu, out_gpu, height, width);cudaEventRecord(stop_gpu);//记录事件cudaError_t  error_code = cudaGetLastError();if (error_code != cudaSuccess){printf("Error: %s\n", cudaGetErrorString(error_code));printf("FILE: %s\n", __FILE__);printf("LINE: %d\n", __LINE__);printf("Error code: %d\n", error_code);}cudaMemcpy(dst_gpu.data, out_gpu, memsize, cudaMemcpyDeviceToHost);float time_gpu;cudaEventElapsedTime(&time_gpu, start, stop_gpu);//事件计时printf("GPU time: %.3f ms \n", time_gpu);cudaEventDestroy(start);//销毁事件cudaEventDestroy(stop_gpu);cv::imwrite("dst_gpu_save.png", dst_gpu);//cv::namedWindow("src", cv::WINDOW_NORMAL);cv::imshow("src", src);cv::imshow("dst_gpu", dst_gpu);cv::waitKey();cudaFree(in_gpu);cudaFree(out_gpu);return 0;
}

在这里插入图片描述
在这里插入图片描述

http://www.ds6.com.cn/news/5517.html

相关文章:

  • 温州做网站找哪家好买卖链接网站
  • 岳阳网站开发网站运营哪家好网站推广策划书
  • 如何做自己的网站信息流广告怎么投放
  • 淘宝网站都是怎么做的吗手机流畅优化软件
  • 青岛企业网站推广全网推广网站
  • b2b网站功能模块手机优化大师下载2022
  • 工业产品设计草图北京百度关键词优化
  • 外贸网站建设 推广下载关键词推广软件
  • 微信 网站提成方案点做中国销售网
  • 重庆企业网站建设电商网站大全
  • 宜昌建设网站seo网站推广杭州
  • 武昌手机网站北京网站优化推广方案
  • 京东网站建设思维导图北京百度推广公司
  • 信用门户网站建设观摩网络舆情管理
  • 怎么用新浪云做淘宝客网站淘宝站外引流推广方法
  • 宁波外贸推广网络营销慧聪网seo页面优化
  • 上海如何批量建站免费快速网站
  • 怎么做短文网站株洲发布最新通告
  • 大连网站建设个人武汉推广服务
  • 织梦系统如何做网站英雄联盟韩国
  • 网站界面可以做版权吗品牌营销推广代运营
  • 泰安放心的企业建站公司谷歌seo排名工具
  • 汽车网站建设的目的北京如何优化搜索引擎
  • 删除网站备案中关村在线app
  • 曹县做网站建设公司网站建设流程
  • 服装网站设计互联网宣传方式有哪些
  • 广州网站推广建设百度网站优化工具
  • 湖北什么是网站建设腾讯广告推广怎么做
  • 学校网站建设考评办法产品品牌策划方案
  • 公司网站开发费用计入什么科目网页模板网站