atilimcetin / global-matting

An implementation of global matting algorithm for OpenCV.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

findBoundaryPixels return nothing to foregroundBoundary

oaleeapp opened this issue · comments

Dear Atılım,

I encountered problem when using the library on iOS, which happened when I trying to get boundary:

    std::vector<cv::Point> foregroundBoundary = findBoundaryPixels(trimap, 255, 128);
    std::vector<cv::Point> backgroundBoundary = findBoundaryPixels(trimap, 0, 128);

the function findBoundaryPixels didn't find the boundary , and cause calculateAlphaPatchMatch(image, trimap, foregroundBoundary, backgroundBoundary, samples); crash due to the fact that the size of foregroundBoundary is zero.

I use cvtColor to change the type of the image.

    cv::Mat img = [self cvMatFromUIImage:sourceImage];
    cv::cvtColor(img , img , CV_RGBA2RGB);
    cv::Mat trimap = [self cvMatFromUIImage:trimapImage];
    cv::cvtColor(trimap , trimap , CV_RGB2GRAY);

I'm thinking is my preparation for the image have gone wrong, don't know if you can help with this.