ppwwyyxx / OpenPano

Automatic Panorama Stitching From Scratch
MIT License
1.9k stars 555 forks source link

Masked inputs masked output #71

Closed Mirmix closed 6 years ago

Mirmix commented 6 years ago

@ppwwyyxx thanks for sharing your work. I am trying to stitch masked images . Sample images are below:

cropboat8

cropboat2

cropboat3

My goal is to stitch the masked images and get the masked output with the same input size. My crop positions can be noisy but also can be accepted as good initial estimate. When I remove the masks the stitching algorithms gives good results. But I also want to get some good results without removing the mask. I managed to filter out wrong keypoints that was wrongly perceived on the mask border/edge. Afterwards there were some problems regarding the :

assertion "p.size() >= 3" failed, in PointInPolygon, (OpenPano/src/lib/polygon.hh:33)

I was able to get along with the problem by adding the following change to transform_estimate.cc

auto get_keypoint_cnt = [&](vector<Vec2D>& poly, bool first) {
        if (poly.size() < 3) return 3; // this line was added
        auto pip = PointInPolygon{poly};
        int cnt = 0;
        for (auto& p : first ? kp1 : kp2)
            if (pip.in_polygon(p))
                cnt ++;
        return cnt;
    };

But the pipeline still can not manage to give me some output. I suspect it fails while trying to select overlapping region (because of the mask may cause some confusion). What could be your suggestion for this problem.

Mirmix commented 6 years ago

Issue is solved by converting images to BRGA format applying changes to code so it cope with BRGA format. I have also changed bundle adjustment so that it could work with planar crops.