TI中文支持网
TI专业的中文技术问题搜集分享网站

Opencv-OCL For AM5718 Using.

 我在使用TI的AM5718系列的芯片过程中,使用到了Opencv3.1.0的图像处理库,由于AM5718是能够支持OpenCL的,其中的加速设备时TI的C66系列的DSP,故想使用OpenCV中集成的OpenCL模块来调用AM5718的DSP Accelerate来加速Opencv函数,但是我发现,在opencv中并不能使能TI的DSP作为加速器,我的代码如下:

#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;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);

#if DSPcv::UMat Ori = cv::imread("/home/root/test.jpg").getUMat(cv::ACCESS_RW),Res;cout << "Use the OpenCL Deivice?" << cv::ocl::useOpenCL() << endl;t = (double)cv::getTickCount();cv::cvtColor(Ori,Res,cv::COLOR_RGB2GRAY);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);
#elseMat I = imread("/home/root/test.jpg"),gray;t = (double)cv::getTickCount();cv::cvtColor(I,gray,cv::COLOR_RGB2GRAY);t = ((double)cv::getTickCount() - t) / cv::getTickFrequency();std::cout << "CPU Time Cost:" << t << "s" << std::endl;cv::imshow("Ori",I);cv::imshow("Res",gray);
#endiffor (;;){int key = waitKey();if (key == 27/*ESC*/ || key == 'q' || key == 'Q')break;}return 0;
}

在AM5718板卡上运行结果如下:

Use the OpenCL Device?这一行的结果为0表示未能使能加速器,也就是没使用到Opencv的加速器,那么请问因该如何修改程序使能DSP加速器呢?或者说Opencv的支持当中,不包括TI的DSP加速器呢?

user4763388:

回复 Shine:

谢谢您,现在可以工作啦!

赞(0)
未经允许不得转载:TI中文支持网 » Opencv-OCL For AM5718 Using.
分享到: 更多 (0)