栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

OpenCV的SGBM with GPU和without GPU的性能对比

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

OpenCV的SGBM with GPU和without GPU的性能对比

测试机器为AMD5800H+3050Ti

测试代码:

#include 
#include 
#include 
#include 
#include 
#include 
#include
#include 

using namespace std;

void calcu_disparity(cv::Mat& left, cv::Mat& right, cv::Mat& disparity)
{
    auto t_a = chrono::high_resolution_clock::now();
    cv::Ptr sgbm = cv::StereoSGBM::create(
        0, 96, 9, 8 * 9 * 9, 32 * 9 * 9, 1, 63, 10, 100, 32);
    cv::Mat disparity_sgbm;
    sgbm->compute(left, right, disparity_sgbm);
    disparity_sgbm.convertTo(disparity, CV_32F, 1.0 / 16.0f);
    auto t_b = chrono::high_resolution_clock::now();
    cout<<"no cuda:"<< chrono::duration_cast(t_b-t_a).count()<<"微秒"< sgbm = cv::cuda::createStereoSGM(
        0, 128, 8, 180, 3, cv::cuda::StereoSGM::MODE_HH);
    cv::Mat disparity_sgbm(left.size(), CV_16S);
    cv::cuda::GpuMat cudaDisparityMap(left.size(), CV_16S);
    cv::cuda::GpuMat cudaDrawColorDisparity(left.size(), CV_8UC4);
    cv::cuda::GpuMat cudaLeftFrame, cudaRightFrame;
    cudaLeftFrame.upload(left);
    cudaRightFrame.upload(right);
    sgbm->compute(cudaLeftFrame, cudaRightFrame, cudaDisparityMap);
    cudaDisparityMap.download(disparity_sgbm);
    disparity_sgbm.convertTo(disparity, CV_32F, 1.0 / 16.0f);
    auto t_b = chrono::high_resolution_clock::now();
    cout<<"with cuda:"<< chrono::duration_cast(t_b-t_a).count()<<"微秒"< 

注意,参数还没调,不知道影响有多大。

结果:

粗算一下,应该是13-15倍的速度提升

视差和点云图

without GPU:

 

with GPU:

 

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/942964.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号