我使用四个静止的摄像头。这些摄像头彼此之间不会移动。而我希望能够将它们的视频图像实时地拼接成一个统一的视频图像。
我使用OpenCV 2.4.10和cv:stitcher
类来完成这项任务,代码如下:
// use 4 video-cameras
cv::VideoCapture cap0(0), cap1(1), cap2(2), cap3(3);
bool try_use_gpu = true; // use GPU
cv::Stitcher stitcher = cv::Stitcher::createDefault(try_use_gpu);
stitcher.setWarper(new cv::CylindricalWarperGpu());
stitcher.setWaveCorrection(false);
stitcher.setSeamEstimationResol(0.001);
stitcher.setPanoConfidenceThresh(0.1);
//stitcher.setSeamFinder(new cv::detail::GraphCutSeamFinder(cv::detail::GraphCutSeamFinderBase::COST_COLOR_GRAD));
stitcher.setSeamFinder(new cv::detail::NoSeamFinder());
stitcher.setBlender(cv::detail::Blender::createDefault(cv::detail::Blender::NO, true));
//stitcher.setExposureCompensator(cv::detail::ExposureCompensator::createDefault(cv::detail::ExposureCompensator::NO));
stitcher.setExposureCompensator(new cv::detail::NoExposureCompensator());
std::vector<cv::Mat> images(4);
cap0 >> images[0];
cap1 >> images[1];
cap2 >> images[2];
cap3 >> images[3];
// call once!
cv::Stitcher::Status status = stitcher.estimateTransform(images);
while(true) {
// **lack of speed, even if I use old frames**
// std::vector<cv::Mat> images(4);
//cap0 >> images[0];
//cap1 >> images[1];
//cap2 >> images[2];
//cap3 >> images[3];
cv::Stitcher::Status status = stitcher.composePanorama(images, pano_result);
}
我只能获得10帧每秒的速度(FPS),但我需要25 FPS。如何加速这个例子?
当我使用
stitcher.setWarper(new cv::PlaneWarperGpu());
时,会得到一个非常扩大的图像,而我不需要这个。我只需要进行平移操作。
例如,我可以不使用:
透视变换
比例变换
甚至旋转
我该怎么做?或者我怎样才能从
cv::Stitcher stitcher
参数中获取每个图像的平移参数x,y
?更新-在Windows 7 x64上的MSVS 2013中进行性能分析: