Ejemplo n.º 1
0
// ** please don't make this program interactive. it must be
// usable in a script, as a filter. **
int main(int argc,char **argv)
{
    vul_arg<vcl_string> infile ("-in"   ,"input image file"    ,"-"); // default is stdin.
    vul_arg<vcl_string> outfile("-out"  ,"output corner file (default is stdout)"  ,"");
    vul_arg<double>     sigma  ("-sigma","gauss sigma"         ,0.7);
    vul_arg<int>        corner_count_max("-c","Max number of corners", 900);
    vul_arg<int>        adaptive_window_size("-w","Adaptive window size (0 disables)", 64);
    vul_arg<vcl_string> cormap ("-map"  ,"cornerness map (pnm)","");
    vul_arg<bool>       pab    ("-pab"  ,"emulate pab harris"  ,false);
    vul_arg_parse(argc,argv);

    // load image
    vil1_image I;
    if (infile() == "-")
    {
        //vcl_cerr << "reading image from stdin\n";
        //I = vil1_load(cin);
        vcl_cerr << "cannot read from stdin yet\n";
        return 1;
    }
    else
        I = vil1_load(infile().c_str());

    // parameters
    osl_harris_params params;
    params.corner_count_max = corner_count_max();
    params.gauss_sigma = (float)sigma();
    params.verbose = true;
    params.adaptive_window_size = adaptive_window_size();
    params.adaptive = (adaptive_window_size() != 0);
    params.pab_emulate = pab();

    // compute object
    osl_harris H(params);
    H.compute(I);

    // save
    if (outfile() == "")
    {
        vcl_cerr << "writing image to stdout\n";
        H.save_corners(vcl_cout);
    }
    else
        H.save_corners(outfile().c_str());

    // cornerness map
    if (cormap.set())
        vil1_save(H.image_cornerness_buf, cormap().c_str(), "pnm");

    return 0;
}
cv::Mat_<cv::Vec2b> adaptive_window_size(const cv::Mat& image, const cv::Mat_<int>& labels, float threshold, int minsize, int maxsize, const std::vector<disparity_region>& regions)
{
	return adaptive_window_size(image, labels, threshold, minsize, maxsize, regions, compare_disparity);
}