How to load any of this tracking algorithm in opencvjs(BOOSTING, MIL, KCF, TLD, MEDIANFLOW, GOTURN, MOSSE or CSRT)

asked 2019-09-27 22:29:05 -0600

vasanthahr gravatar image

updated 2019-09-27 22:29:39 -0600

Hello,

I wanted to load any of these tracking algorithms in javascript using opencvjs. please suggest me or giving some links to do the same. (We do have opencv.js compiled file and it has all these tracking algortihms)

I tried to refer this c++ and Python code link :

https://www.learnopencv.com/object-tr...

But getting error when initialized with below code

code:

let video = document.getElementById('videoInput');
let cap = new cv.VideoCapture(video);

    // take first frame of the video
    let frame = new cv.Mat(video.height, video.width, cv.CV_8UC4);
    cap.read(frame);

    // hardcode the initial location of window
    let trackWindow = new cv.Rect(150, 60, 125, 125);

      let tracker_c = cv.TrackerKCF_create();

    // set up the ROI for tracking
    let roi = frame.roi(trackWindow);

Errror:

TypeError: cv.TrackerKCF_create is not a function
edit retag flag offensive close merge delete

Comments

We do have opencv.js compiled file and it has all these tracking algortihms

how do you know ? you can only use a small subset of opencv from js, see here, what is currently inside

berak gravatar imageberak ( 2019-09-28 00:08:51 -0600 )edit
1

@berak, We have followed opencv steps and compiled our own opencvjs file using ecmascript.

our embindgen.py consist of following tracking algorithms.

tracking = {"Tracker": ["init", "update"],
            "TrackerKCF": ["create"],
            "TrackerBoosting": ["create"],
            "TrackerMIL": ["create"],
            "TrackerTLD": ["create"],
            "TrackerMedianFlow": ["create"],
            "TrackerMOSSE": ["create"],
            "TrackerCSRT": ["create"]}

And trying to load below javascript function:

let tracker = cv.TrackerKCF();

But getting error as:

Uncaught UnboundTypeError {name: "UnboundTypeError", message: "Cannot construct TrackerKCF due to unbound types: N2cv9AlgorithmE", stack: "UnboundTypeError: Cannot constru
vasanthahr gravatar imagevasanthahr ( 2019-09-30 00:49:19 -0600 )edit