匹配的描述我提取descriptors
然後將其保存到文件是這樣的:opecv C++從文件
detector->detect(img, imgKpts);
extractor->compute(img, imgKpts, imgMat);
fsKpts << filename << imgMat;
但是當我回來read
他們是這樣的:
std::vector<cv::Mat> filesDVec;
cv::Mat temp;
fs[filename] >> temp;
filesDVec.push_back(temp);
和match
的descriptors
與一個加載的圖像:
cv::Mat givenIn, givenInMat;
givenIn = cv::imread(dataDirGivenIn, CV_LOAD_IMAGE_GRAYSCALE);
cv::vector<cv::KeyPoint> givenInKpts;
detector->detect(givenIn, givenInKpts);
extractor->compute(givenIn, givenInKpts, givenInMat);
cv::vector<cv::DMatch> matchesVector;
with th e 2的cv::Mat
s此方式輪:
matcher->match(filesDVec[i], givenInMat, matchesVector);
A.K.A match(Scene, Object, ...)
輸出爲:minDist = 100 maxDist = 0
(不是一個單一的匹配)。
但是他們這樣一輪:
matcher->match(givenInMat, filesDVec[i], matchesVector);
AKA match(Object, Scene, ...)
引發此錯誤:
opencv error:assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type = CV_8U)) in void cv::batchDistance
我想有從每個圖像保存,以便它可以在加載的描述信息,我究竟做錯了什麼?
編輯
我要補充一點,它不是試圖因爲它知道,如果目標和源圖像相等出於測試目的matcher
不起作用匹配和圖像本身的情況。
編輯2項
內容的文件:
Image_0: !!opencv-matrix
rows: 315
cols: 32
dt: u
data: [ 0, 128, 196, 159, 108, 136, 172, 39, 188, 3, 114, 16, 172,
234, 0, 66, 74, 43, 46, 128, 64, 172, 67, 239, 4, 54, 218, 8, 84,
0, 225, 136, 160, 133, 68, 155, 204, 136, 232, 47, 61, 17, 115,
18, 236, 106, 8, 81, 107, 131, 46, 128, 114, 56, 67, 213, 12, 50,
218, 64, 21, 8, 209, 136, 180, 69, 70, 142, 28, 130, 238, 96, 141,
128, 243, 2, 74, 74, 37, 65, 120, 161, 78, 226, 104, 163, 0, 204,
...
etc
閱讀:
std::vector<cv::Mat> filesDVec(imgVec.size());
cv::Mat temp;
cv::FileStorage fs("tileDesc.yml", cv::FileStorage::READ);
for(size_t i = 0; i < (imgVec.size()); i++){
cv::string iValue = std::to_string(i);
cv::string filename = "Image_" + iValue;
fs[filename] >> temp;
filesDVec.push_back(temp);
}
fs.release();
'matcher-> match'的兩個錯誤意味着'filesDVec [i]'可能是一個空的Mat。確保'fs [文件名] >> temp;'讀取您指定的文件。 – mcchu
我查過了,確實如此。 – MLMLTL