void CRecoImage::FindFeatures(SIFT& SIFTDetector) { Mat image; if(!this->LoadImg(image)) { CRecoLogMgr::Instance()->WriteLog("CRecoImage -> FindFeatures !FAILURE! Could not open or find the image. Path is: " + this->GetFullImagePath()); } SIFTDetector.detect(image, this->_KeyPoints); }
Mat Pyramids::extractFeatures(const Mat &im, vector<KeyPoint> &keypoints, int step) { Mat features; SIFT dec; if (step <= 0) dec.detect(im, keypoints); else keypoints = extractDenseKeypoints(im, step); dec.compute(im, keypoints, features); return features; }
/***************************************************************************** * @brief : siftFeatureDetect * @author : Zhangle * @date : 2014/9/8 11:18 * @version : ver 1.0 * @inparam : * @outparam : *****************************************************************************/ void FeatureDetect::siftFeatureDetect(string inputImageName, string outputImageName,string outputTxtName) { Mat image = imread(inputImageName); Mat descriptors; vector<KeyPoint> keypoints; SIFT sift; time_t beginTime = time(NULL); sift.detect(image,keypoints); time_t endTime = time(NULL); time_t runTime = endTime - beginTime; drawKeypoints(image,keypoints,image,Scalar(0,255,0)); imwrite(outputImageName,image); ofstream outTxt(outputTxtName); outTxt << "SIFT" << endl; outTxt << "影像尺寸:" << image.cols<<" * "<<image.rows<<endl; outTxt << "特征点数目:" << keypoints.size() <<"个"<< endl; outTxt << "提取特征点耗费时间:" << runTime << "s"<< endl; outTxt << "默认参数设置" << endl; outTxt.close(); }