我正在努力将Open CV图像拼接实现到我的IOS应用程序中。我正在使用Xcode 7.1。我遇到的问题是我将stitcher :: Stitch传递给一个包含3个图像的数组,以便拼接图像,但它返回的状态代码为:ERR_NEED_MORE_IMGS。我不确定我做错了什么,这是我的代码:
+(UIImage *) stitchImages:(UIImage *)image :(UIImage *) imageTwo :(UIImage *) imageThree
{
cv::Mat matImageOne;
cv::Mat matImageTwo;
cv::Mat matImageThree;
cv::Mat imgOut;
cv::Stitcher stitcher = cv::Stitcher::createDefault(TRUE);
std::vector<cv::Mat> images;
UIImage *panoImage;
UIImageToMat(image, matImageOne);
UIImageToMat(imageTwo, matImageTwo);
UIImageToMat(imageThree, matImageThree);
matImageOne = cv::Mat::zeros(matImageOne.size(), CV_8UC3);
matImageTwo = cv::Mat::zeros(matImageTwo.size(), CV_8UC3);
matImageThree = cv::Mat::zeros(matImageThree.size(), CV_8UC3);
images.push_back(matImageOne);
images.push_back(matImageTwo);
images.push_back(matImageThree);
cv::Stitcher::Status status = stitcher.stitch(images, imgOut);
if(status == cv::Stitcher::Status::OK) { //Here the status is being returned as ERR_NEED_MORE_IMGS
return MatToUIImage(imgOut);
}
else{
return 0;
}
return image;
}
当您使用此ulr时,我使用的图像是前2个图像:https://ramsrigoutham.com/2012/11/22/panorama-image-stitching-in-opencv/ Thanx提前!