如何在JavaScript中打开cv.DMatchVector对象?

如何在JavaScript中打开cv.DMatchVector对象?,javascript,opencv,object,attributes,brute-force,Javascript,Opencv,Object,Attributes,Brute Force,我想在JavaScript中使用cv.BFMatcher比较2个cv.Mat(“des”和“newObj”)对象。它看起来很有效,因为我看到“matches”变量的长度。匹配后是500。然而,当我试图根据距离过滤好的匹配时,我得到了一个错误 Uncaught TypeError: Cannot read property 'distance' of undefined 我的代码: var bf = new cv.BFMatcher(); var matches = new cv.DMatchV

我想在JavaScript中使用cv.BFMatcher比较2个cv.Mat(“des”和“newObj”)对象。它看起来很有效,因为我看到“matches”变量的长度。匹配后是500。然而,当我试图根据距离过滤好的匹配时,我得到了一个错误

Uncaught TypeError: Cannot read property 'distance' of undefined
我的代码:

var bf = new cv.BFMatcher();
var matches = new cv.DMatchVector();
bf.match(des, newObj, matches);
console.log(matches.size()); // 500

var good_matches = new cv.DMatchVector();
for (let i = 0; i < matches.size(); i++) {
    if(matches[i].distance < 40) {
        good_matches.push_back(matches[i]);
    } 
}
console.log(good_matches.size())
var bf=new cv.BFMatcher();
var matches=new cv.DMatchVector();
匹配(des、newObj、匹配);
console.log(matches.size());//500
var good_matches=new cv.DMatchVector();
for(设i=0;i
“匹配”-对象的类型。但是我无法检查这些键来找到“距离”属性的正确名称


如果有人能帮我解决这个问题,我会非常高兴。提前谢谢你

我今天遇到了这个问题。尝试使用:

for (let i = 0; i < matches.size(); i++) {
if(matches.get(i).distance < 40) {
    good_matches.push_back(matches.get(i));
} 
for(设i=0;i
}