[英]OpenCV saving image, keypoints and descriptors to file
我正在使用SURF / FLANN探測器,我正在尋找將圖像,點,描述符保存到文件中,這樣我就可以比較這個圖像,然后將它指向第二個圖像並指向我但是當我得到以下錯誤時試着寫:
In file included from detectFlannPoints.cpp:4:0:
/usr/local/include/opencv2/features2d/features2d.hpp:112:17: note: void cv::write(cv::FileStorage&, const string&, const std::vector<cv::KeyPoint>&)
/usr/local/include/opencv2/features2d/features2d.hpp:112:17: note: candidate expects 3 arguments, 4 provided
這是我用來編寫的代碼:
FileStorage fs("Keypoints.yml", FileStorage::WRITE);
write(fs, "templateImageOne", keypoints_1, tempDescriptors_1);
fs.release();
我不確定在哪里可以指定額外的參數( tempDescriptors_1
),因為它可以正常刪除這個arg。
代碼立即高於寫代碼:
//Detect the keypoints using SURF Detector
int minHessian = 400;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints_1;
detector.detect( img_1, keypoints_1 );
//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat tempDescriptors_1;
extractor.compute( img_1, keypoints_1, tempDescriptors_1 );
//-- Draw keypoints
Mat img_keypoints_1;
drawKeypoints( img_1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
你必須一次寫一個:
FileStorage fs("Keypoints.yml", FileStorage::WRITE);
write(fs, "keypoints_1", keypoints_1);
write(fs, "descriptors_1", tempDescriptors_1);
...
fs.release();
我們必須逐個編寫關鍵點和描述符
FileStorage fs("Keypoints.yml", FileStorage::WRITE);
write(fs, "templateImageOne_Keypoint", keypoints_1);
write(fs, "templateImageOne_descriptor", tempDescriptors_1);
fs.release();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.