This repository uses p5.js to render data from an OptiTrack CSV -> WebSocket server.
-
Clone this repo.
-
Install Node.js.
- On macOS, install HomeBrew, and then enter
brew install nodeinto a terminal window. - On Windows, install it from the Node.js download page.
- On macOS, install HomeBrew, and then enter
-
In a terminal window:
- Change directories (
cd) into the repository directory. - Enter
npm install
- Change directories (
In a terminal window:
- Change directories (
cd) into the repository directory. - Either:
- Add a
serverUrlproperty to theoptitrack.poseNet()call insketch.js; or: - Run an OptiTrack CSV -> WebSocket server.
- Add a
- Enter
npm start
If you added serverUrl property, the modified code should look like:
const poseNet = optitrack.poseNet(video, { p5, serverUrl: 'ws://myserver.example.com:8764' },
() => p5.select('#status').hide());where myserver.example.com and 8764 are the hostname and port of a WebSocket
server.
This will open PoseNet in a browser window.
The code in optitrack.js provides an API that is very similar to the ml5.js
PoseNet API. Code that uses
ml5.poseNet can be trivially adapted to render (a projection of) OptiTrack
data instead, or more extensively modified to make use of 3D data.
const poseNet = optitrack.poseNet(?video, ?options, ?callback);
-
video: OPTIONAL. Optional HTMLVideoElement. If present, the x and y coordinates from the 3D position are scaled to the dimensions of this element, to create the 2D position. (This can any object that provides
widthandheightproperties.) -
callback: OPTIONAL. A function that is called when the WebSocket connection is established.
-
options: OPTIONAL. An object that contains the following properties.
p5is the globalp5variable. It is required when p5.js is used in instance mode.{ p5: p5, frameRate: 1, serverUrl: 'ws://localhost:8765' }
posenet.on('pose', callback)
An event listener that returns the results when a pose is detected.
This is upwards-compatible with the ML5's posenet.on
method.
Each keypoint in the array includes both a position: {x, y} property (the same
as PoseNet), but also a pos: {x, y, z} with the 3D OptiTrack data.
MIT License