图像拼接源码分析向:opencv stitching module 中添加上拼接缝的结果

seam_finder->find(images_warped_f, corners, masks_warped);
    imwrite("/Users/pengyuyan/Desktop/data/stitching_warp/mask/masks_warped_1.jpeg", masks_warped[0]);
    imwrite("/Users/pengyuyan/Desktop/data/stitching_warp/mask/masks_warped_2.jpeg", masks_warped[1]);
    imwrite("/Users/pengyuyan/Desktop/data/stitching_warp/mask/images_warped_f_1.jpeg", images_warped_f[0]);
    imwrite("/Users/pengyuyan/Desktop/data/stitching_warp/mask/images_warped_f_2.jpeg", images_warped_f[1]);
    
//    LOGLN("images_warped_f size, " << images_warped_f.size());
//    LOGLN("masks_warped size, " << masks_warped.size());
    
    //通过canny边缘检测,得到掩码边界,其中有一条边界就是接缝线
    for(int k=0;k<2;k++)
        Canny(masks_warped[k], masks_warped[k], 3, 9,3 );
    
    vector dilate_img(2);
    Mat element = getStructuringElement(MORPH_RECT, Size(10, 10));
    
    for(int k =0; k(y, x) == 255)    //掩码边界
                {
                    images_warped[k].getMat(ACCESS_READ).at(y, x)[0] = 255;
                    images_warped[k].getMat(ACCESS_READ).at(y, x)[1] = 0;
                    images_warped[k].getMat(ACCESS_READ).at(y, x)[2] = 255;
                }
            }
        }
    }
    
    imwrite("/Users/pengyuyan/Desktop/data/stitching_warp/seam/seam1.jpg", images_warped[0]);    //存储图像
    imwrite("/Users/pengyuyan/Desktop/data/stitching_warp/seam/seam2.jpg", images_warped[1]);
   
    // Release unused memory
    images.clear();
    images_warped.clear();
    images_warped_f.clear();
    masks.clear();

 

你可能感兴趣的:(opencv)