Kinetix ML should be installed as a node module using the command below.
Copy
yarn add kml-pipe-ts
There is a known issue with Tensorflow JS dependencies when installing using
the npm command so please use yarn. They are for the most part interoperable.
The pipeline will need a data source for each of its inputs. A common input is image data for nodes such as PoseDetection2D. For these nodes you should first create a video source element.
Copy
<video id="webcam" autoplay />
Now we need to make a function that we can call for every frame
Copy
let outputs = []let processing = falseasync function runInference() { if (!processing) { processing = true; outputs = await pipe.execute([videoSource]); processing = false; } document.getElementById("webcam").requestVideoFrameCallback(runInference); // run inference on every frame};
Then, to use your webcam, run the following function which will ask the user for webcam permission, start playing the video, and start inference.