-1
我试图用iPhone上的OpenCV(videostream)检测具有6个角的形状。我得到了相当不错的结果,但是对于低帧速率的成本约为8 fps(取决于检测等高线) 以下是一些代码片段和相应的帧速率(如果在此调用之后我会中断)和一些时间测量使用OpenCV getTickCount()和getTickFrequenzy();OpenCV:加快iPhone上简单形状的检测
clock_t now;
clock_t then;
double tickpersecond = cv::getTickFrequency();
double elapsed_seconds;
// around 24 fps
then = cv::getTickCount();
GaussianBlur(gray, gray, cv::Size(9, 9), 2, 2); // 20fps
Canny(gray, gray, m_threshold, m_threshold * 2,3); // 13fps
now = cv::getTickCount();
elapsed_seconds = (double)(now - then)/tickpersecond;
// elapsed_seconds is around 0.068183 seconds
//assuming we there are around 120 contours found
cv::findContours(gray, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_TC89_L1, cv::Point(0,0));
// 10 fps and elapsed_time around 0.008560 seconds
我不知道,如果有什么要加快,但我觉得有点怪,有3FPS的当我运行findContours但与0.008560一个相当低ELAPSED_TIME下降。然而最重要的部分是下面的代码片段:
for(int i = 0; i< contours.size(); i++)
{
cv::Scalar color = cv::Scalar(rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255));
std::vector<cv::Point> output;
approxPolyDP(contours[i], output, 0.01*arcLength(contours[i],true), true);
convexHull(output, convexContour);
if(convecContour.size() == 6)
//dosomething which I think is not performance relevant
}
//8 fps and elapsed_time == 0.018076
我处理从10 contours.size() - 150 我真的希望你们能指出一些事情,我可以提高性能15.
如果在CPU上完成'GaussianBlur'和'Canny',则相对较慢。你可能会检查[GPUImage](https://github.com/BradLarson/GPUImage),这将大大加快这些操作。 – Aurelius 2013-05-02 16:55:11
谢谢你的提示。不过,我正在使用http://computer-vision-talks.com/中已经支持GPU加速的框架。 – goTAN 2013-05-03 09:02:20
你是否真的在iPhone上实现了GPU加速的代码?我的印象是OpenCV只支持CUDA。 – Aurelius 2013-05-03 14:59:00