目标识别探测全景拼接相机程序耗时分析

2018年11月15日

release_X64   X64模式下

全程耗时35ms左右

const cv::Mat ComFrame = Mat::zeros(480 * 4, 640 * 18, CV_8UC1);          7ms

const cv::Mat ColorComFrame = Mat::zeros(480 * 4, 640 * 18, CV_8UC3);   24ms

发现分配该内存时间太长,

测试cv::Mat ColorComFrametest = Mat::zeros(480 * 4, 640 * 18, CV_8UC3);   19ms

const cv::Mat ColorComFrametest = Mat::zeros(1920, 11520, CV_8UC3);      20ms

cv::Mat ColorMainWindows = Mat::zeros(300, 1800, CV_8UC3);  0ms

发现:使用matlab方式初始化时比较大的mat类型比较耗时,

改进:使Mat类型构造函数方式初始化

memcpy(image.data, pNewImage->buffer, pNewImage->head.iHeight* pNewImage->head.iWidth);   0ms

cv::resize(image, resImage, cv::Size(800, 600), 0, 0, INTER_NEAREST);    0ms

flip(resImage, resImage, -1);  0ms

cv::resize(ColorComFrame, ColorMainWindows, Size(1800, 300), 0, 0, INTER_NEAREST);  0ms

imshow("MainWindows", ColorMainWindows);   0ms

imshow("view", dst);  一般情况下为0ms,如果选择范围太大,则耗时会比较大,可能超过5ms

//显示雷达扫描区域   耗时0到1ms
double beta, beta0;
//    int rhomax = 1125;
double rhomax = copyRadar.cols / 2.67;
beta = 3.1415926 * index / 36;
beta0 = beta - 1.134;
Point start, end, end0;
start.x = copyRadar.cols / 2;
start.y = copyRadar.rows / 2;
//end.x = 1500 + rhomax * sin(beta);
//end.y = 1500 - rhomax * cos(beta);
end.x = start.x + rhomax * sin(beta);
end.y = start.y - rhomax * cos(beta);
end0.x = start.x + rhomax * sin(beta0);
end0.y = start.y - rhomax * cos(beta0);
copyRadar.copyTo(copyRadarLine);
line(copyRadarLine, start, end0, Scalar(0, 255, 0), 3);
line(copyRadarLine, start, end, Scalar(0, 255, 0), 3);
imshow("Radar", copyRadarLine);
_cprintf("%d\n\n", (int)(t.time()));

ImageStitch(index, image1, resImage, ColorComFrame);  30ms

下面分析ImageStitch中的各个函数:

cv::matchTemplate(image_source, image_template, image_matched, cv::TM_CCORR_NORMED);    耗时2ms,同时测试该函数在debug模式下耗时为8ms,release模式仅为其25%。

std::vector<bbox_t> result_vec = detector.detect(newframe1);    27ms

draw_boxes(newframe1, result_vec, obj_names, 0, -1, -1);   0ms

object_location(newframe1, result_vec, &copyRadar);    0ms

猜你喜欢

转载自blog.csdn.net/u010440456/article/details/84098494
今日推荐