Exemplo n.º 1
0
void AsiftKeypoints::inireadSiftParameters(std::string name){

	ptree pt;
	
	if(this->path.isExist(name)){

		read_ini(name, pt);

		inireadSiftParameters(pt);

	}else{
		
		std::cout << "not exist " << name << endl;
		
		default_sift_parameters(siftparams);

		iniwriteSiftParameters(name);


	}

}
Exemplo n.º 2
0
/// SIFT matches
static void SIFT(const Image<unsigned char> &im1,
                 const Image<unsigned char> &im2,
                 std::vector<Match>& vec_matchings,
                 float fMatchRatio=0.6f) {
    //Convert images to float
    Image<float> If1, If2;
    libs::convertImage(im1, &If1);
    libs::convertImage(im2, &If2);

    siftPar param;
    default_sift_parameters(param);
    param.MatchRatio = fMatchRatio;
    param.DoubleImSize=0;

    keypointslist keyp1, keyp2;
    compute_sift_keypoints(If1.data(), keyp1, If1.Width(), If1.Height(), param);
    std::cout<< "sift:: 1st image: " << keyp1.size() << " keypoints"<<std::endl;
    compute_sift_keypoints(If2.data(), keyp2, If2.Width(), If2.Height(), param);
    std::cout<< "sift:: 2nd image: " << keyp2.size() << " keypoints"<<std::endl;

    // Find putatives matches
    compute_sift_matches(keyp1, keyp2, vec_matchings, param);
    std::cout << "sift:: matches: " << vec_matchings.size() <<std::endl;
}
Exemplo n.º 3
0
/// Usage: siftMatch imgIn imgIn2 fileOut [imgOut]
/// Output in text file fileOut the matches evaluated by SIFT method between
/// the images imgIn and imgIn2 (PNG format). If imgOut is in the argument list,
/// this is an image file where matches will be shown (PNG format).
int main(int argc, char **argv)
{	
    if(argc != 4 && argc != 5) {
        std::cerr << "Usage: " << argv[0] << " imgIn imgIn2 fileOut [imgOut]"
                  << std::endl;
        return 1;
    }

	//////////////////////////////////////////////// Input
	int w1, h1;
    float* ipixels1;
    if(! load(argv[1], ipixels1, w1, h1))
        return 1;

	//////////////////////////////////////////////// Input
    int w2, h2;
    float* ipixels2;
    if(! load(argv[2], ipixels2, w2, h2))
        return 1;

	///////////////////////////////////////// Applying Sift
	siftPar siftparameters;
	default_sift_parameters(siftparameters);
    siftparameters.DoubleImSize=0;

	keypointslist keyp1, keyp2;
	compute_sift_keypoints(ipixels1,keyp1,w1,h1,siftparameters);
    std::cout<< "siftMatch:: 1st image: " << keyp1.size() << " keypoints"<<std::endl;
	compute_sift_keypoints(ipixels2,keyp2,w2,h2,siftparameters);
    std::cout<< "siftMatch:: 2nd image: " << keyp2.size() << " keypoints"<<std::endl;

	matchingslist matchings;
	compute_sift_matches(keyp1,keyp2,matchings,siftparameters);	
    std::cout << "siftMatch:: matches: " << matchings.size() <<std::endl;

	//////////////////////////////////////////////////////////////// Save file with matches
    saveMatch(argv[3], matchings);

	//////////////////////////////////////////////// Output image containing line matches
    if(argc > 4) {
        int wo =  std::max(w1,w2);
        int ho = h1+h2;

        float *opixels = new float[wo*ho];
        for(int j = 0; j < h1; j++)
            for(int i = 0; i < w1; i++)  opixels[j*wo+i] = ipixels1[j*w1+i];
        for(int j = 0; j < h2; j++)
            for(int i = 0; i < w2; i++)  opixels[(h1 + j)*wo + i] = ipixels2[j*w2 + i];	

        //////////////////////////////////////////////////////////////////// Draw matches
        matchingslist::iterator ptr = matchings.begin();
        for(; ptr != matchings.end(); ++ptr)
            draw_line(opixels,
                      (int) ptr->x1, (int) ptr->y1,
                      (int) ptr->x2, (int) ptr->y2 + h1,
                      255.0f, wo, ho);

        ///////////////////////////////////////////////////////////////// Save imgOut	
        io_png_write_f32(argv[4], opixels, (size_t)wo, (size_t)ho, 1);
        delete[] opixels;
	}

	/////////////////////////////////////////////////////////////// Delete memory
	free(ipixels1);
	free(ipixels2);
    return 0;
}