|
【Linux】
ubuntu18.04 Mali-T860 GPU 浮点加速无效
发表于 2020-11-19 10:36:50
浏览:7763
|
回复:0
打印
只看该作者
[复制链接]
楼主
C:\Users\SCI-Q2\Desktop\微信图片_20201119095759.jpg
我调用opencv的canny边缘检测的函数进行浮点运算,使用umat格式的数据参数,opencv会自动调用opencl的接口进行GPU加速,但是opencl 返回报错说是无效的设备,错误截图如上。测试代码如下:
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/core/ocl.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/videoio/videoio.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace std;
using namespace cv;
using namespace cv::ocl;
#define DSP 1
int main()
{
double t = 0.0;
#if DSP
std::vector<cv::ocl::PlatformInfo> plats;
cv::ocl::getPlatfomsInfo(plats);
const cv::ocl::PlatformInfo *platform = &plats[0];
cout << "Platform Name:" << platform->name().c_str() << endl;
cv::ocl::Device c_dev;
platform->getDevice(c_dev,0);
cout << "Device name:" << c_dev.name().c_str() << endl;
c_dev.set(0);
cv::ocl::setUseOpenCL(true);
cout << "Use the OpenCL Deivice?" << cv::ocl::useOpenCL() << endl;
cv::UMat Ori = cv::imread("./bigKeyboard.bmp").getUMat(cv::ACCESS_RW),Res,Canny;
t = (double)cv::getTickCount();
cv::cvtColor(Ori,Res,cv::COLOR_RGB2GRAY);
cv::Canny(Res,Res,0,30);
t = ((double)cv::getTickCount() - t) / cv::getTickFrequency();
std::cout << "TI AM57x Accelerate Time Cost:" << t << "s" << std::endl;
cv::imshow("Test",Ori);
cv::imshow("Gray",Res);
#else
Mat I = imread("./bigKeyboard.bmp"),gray;
t = (double)cv::getTickCount();
cv::cvtColor(I,gray,cv::COLOR_RGB2GRAY);
cv::Canny(gray,gray,0,30);
t = ((double)cv::getTickCount() - t) / cv::getTickFrequency();
std::cout << "CPU Time Cost:" << t << "s" << std::endl;
cv::imshow("Ori",I);
cv::imshow("Res",gray);
#endif
for (;;)
{
int key = waitKey();
if (key == 27/*ESC*/ || key == 'q' || key == 'Q')
break;
}
return 0;
}
有知道原因的大神,请帮忙解答下,深表感谢! |
|