Skip to content

Commit

Permalink
opencv now can track
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed May 20, 2024
1 parent 23087ed commit b63e7df
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions build/opencv_js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module 'opencv_js' {
export function cv(): any;
}
2 changes: 1 addition & 1 deletion dist/webarkitCV.js

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions src/Workers/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const ctx: Worker = self as any;

var next: any = null;

var _msg;
var _msg: any;
let ocv: any = null;
let markerResult: any = null;

Expand All @@ -19,10 +19,6 @@ ctx.onmessage = (e: MessageEvent<any>) => {
_msg = msg;
process(msg);
}
case "loaded": {
ocv = msg.CV;

}
}
};

Expand All @@ -32,22 +28,24 @@ const loadTrackables = (msg: any) => {
ocv = core;
console.log(core);
console.log(ocv)

ocv.loadTrackables(msg);
var EVENT = new CustomEvent("loaded", { detail: { CV: ocv } });
ctx.dispatchEvent(EVENT);
ocv.loadTrackables(msg);
}

const onError = function (error: any) {
console.error(error);
};

WebARKitCoreCV.initCV().then(onLoad).catch(onError);
console.log(ocv);
};

ctx.addEventListener("loaded", (e: any) => {
console.log(e)
ocv = e.detail.CV;
//process(_msg);
ocv.track(_msg);
});

const process = (msg: any) => {
Expand Down
2 changes: 2 additions & 0 deletions src/core/WebARKitCoreCV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export class WebARKitCoreCV {
var knnMatches = new this.cv.DMatchVectorVector();

var matcher = new this.cv.BFMatcher();
console.log("template_descriptors", this.template_descriptors);


matcher.knnMatch(frame_descriptors, this.template_descriptors, knnMatches, 2);

Expand Down

0 comments on commit b63e7df

Please sign in to comment.