我目前正在使用 360° 相机,并希望为此使用 OpenCV 的球形变形器。但是,每次我尝试运行一个使用拼接器功能的简单程序时,它都无法返回拼接图像。我基本上只是拍摄 360° 照片,将其分成两张单独的照片(前后镜头),然后将它们缝合在一起。
这是代码:
Mat srcImage = imread("assets/360_0043.JPG");
Mat frontLensImage(srcImage, Rect(0, 0, srcImage.cols / 2, srcImage.rows));
Mat rearLensImage(srcImage, Rect(srcImage.rows, 0, srcImage.cols / 2, srcImage.rows));
vector<Mat> imagesToStitch;
imagesToStitch.push_back(frontLensImage);
imagesToStitch.push_back(rearLensImage);
Mat panorama;
Stitcher stitcher = Stitcher::createDefault();
if(!imagesToStitch.empty()){
stitcher.stitch(imagesToStitch, panorama);
imshow("test", panorama);
waitKey(0);
}
else{
cout << "ERROR: Image array empty" << endl;
}
return 0;
尝试运行时,它返回此错误:
OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/imgproc/src/imgwarp.cpp, line 1834
terminate called after throwing an instance of 'cv::Exception'
what(): /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/imgproc/src/imgwarp.cpp:1834: error: (-215) ssize.area() > 0 in function resize
调试时,panorama
即使我将它作为OutputArray
to传递,它也是一个空对象stitcher.stitch
。我彻底搜索了网络,找不到解决方案,所以任何帮助将不胜感激!