1

我正在对两个图像进行拼接,并在调试时出现此错误(编译成功但运行时中断):

断言失败 ==CV_8Uc3> 在未知函数中。

这是代码:

int main(int argc, char ** argv)
{
    Mat im1=imread("panorama_image1.jpg", CV_LOAD_IMAGE_GRAYSCALE);
    Mat im2=imread("panorama_image2.jpg", CV_LOAD_IMAGE_GRAYSCALE);

    Mat result;
    vector<Mat> imgs;
    imgs.push_back(im1);
    imgs.push_back(im2);
    cv::Stitcher stitcher=cv::Stitcher::createDefault(false);
    stitcher.stitch(imgs,result);

    namedWindow("Mosaic", CV_WINDOW_AUTOSIZE);
    imshow("Mosaic",result);
    waitKey(0);

    return 0;
}

我无法在此代码中找到错误。并且链接器库是正确的(使用 D 版本,例如opencv_core244d.libopencv_stitching244d.lib

4

1 回答 1

1

我认为sgarizvi是对的,加载颜色为我解决了类似的问题:

Mat im1=imread("panorama_image1.jpg", CV_LOAD_IMAGE_COLOR);
Mat im2=imread("panorama_image2.jpg", CV_LOAD_IMAGE_COLOR);
于 2015-05-02T03:42:02.283 回答