gpt4 book ai didi

OpenCV GpuMat 用法

转载 作者:太空宇宙 更新时间:2023-11-03 21:55:58 31 4
gpt4 key购买 nike

我正在尝试使用 OpenCV GpuMat,但出现断言错误,我的代码如下

#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"

// ...

using namespace cv;
using namespace cv::gpu;

int main()
{
string baboon = "baboon.jpg";
try
{
DeviceInfo info = getDevice();
cout << info.name() << endl;

GpuMat src;

src = cv::imread(baboon, 1);
}
catch (const cv::Exception* ex)
{
cout << "Error: " << ex->what() << endl;
}
}

输出是:

GeForce GTX 550 Ti
OpenCV Error: Assertion failed (!m.empty()) in unknown function, file ($PATH_TO_OPENCV)\opencv\modules\gpu\src\gpumat.cpp, line 411

关于如何解决这个问题有什么想法吗?

最佳答案

解决方法是:

Mat src;

src = cv::imread("...");

GpuMat dst;

dst.upload(src);

关于OpenCV GpuMat 用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9318388/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com