Skip to content

Instantly share code, notes, and snippets.

@albjeremias
Created March 19, 2020 16:33
Show Gist options
  • Save albjeremias/c50a5610d35e40f279546f8ee1d1d4ce to your computer and use it in GitHub Desktop.
Save albjeremias/c50a5610d35e40f279546f8ee1d1d4ce to your computer and use it in GitHub Desktop.

Revisions

  1. albjeremias created this gist Mar 19, 2020.
    22 changes: 22 additions & 0 deletions opencv_sort_resize_DMatchVector
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    function OpencvExt() {
    cv.DMatchVector.prototype.sort = function () {
    for (let i = 0; i < this.size(); i++) {
    for (let j = 0; j < this.size(); j++) {
    if (this.get(i).distance < this.get(j).distance) {
    let x = this.get(i);
    let y = this.get(j);
    this.set(i, y);
    this.set(j, x);
    }
    }
    }
    }

    cv.DMatchVector.prototype.resizeMe=function(length){
    let matchesResized = new cv.DMatchVector();
    for (let i = 0; i < length; i++) {
    matchesResized.push_back(this.get(i));
    }
    return matchesResized;
    }
    }