如何使用opencv graphcut

时间:2014-01-13 12:10:24

标签: c++ opencv image-processing

我正在尝试使用图形切割来切割给定图像中的眼睛并用另一只眼睛替换它。

void imageStitching::findEye(cv::Mat originalImage, cv::Mat eye)
{
    // our corners are just at (0,0)
    cv::Point corner1;
    corner1.x = 0;
    corner1.y = 0;

    cv::Point corner2;
    corner2.x = 0;
    corner2.y = 0;

    std::vector<cv::Point> corners;

    corners.push_back(corner1);
    corners.push_back(corner2);

    std::vector<cv::Mat> masks;

    std::vector<cv::Mat> sources;

    sources.push_back(originalImage);
    sources.push_back(eye);

    cv::detail::GraphCutSeamFinder *seam_finder = new cv::detail::GraphCutSeamFinder();
    seam_finder->find(sources, corners, masks);

    printf("%lu\n", masks.size());
    for(int i = 0; i < masks.size(); i++)
    {
        std::cout << "MASK = "<< std::endl << " "  << masks.at(i) << std::endl << std::endl;
    }
}

但是代码在

上崩溃了
seam_finder->find(sources, corners, masks);

带有消息:

Thread 1: EXC_BAD_ACCESS(code=1, address=0x0)

如何使用opencv获取图像中某个位置的对象的图形切割?

0 个答案:

没有答案