OpenNI provides the function ConvertRealWorldToProjective
which lets you easily convert real world (x,y,z) joint positions, in mm, to a projected (x,y) position in pixels for a given viewport. This is really useful for drawing a 'skeleton' over the webcam feed.
Is this functionality exposed by ZigJS, either as a function or perhaps already converted somewhere? I can't find any mention of it in the docs, but I had luck with a previously undocumented feature with Zigfu in the past.
user.addEventListener('userupdate', function(user) {
var real = user.skeleton[zig.Joint.Head].position; // this is real world coordinate
// anything exposed by zigfu to convert to real world?
});
If not provided by Zigfu, does anyone know of a good JavaScript library that provides this sort of functionality?
ZigJS exposes two (unfortunately still undocumented) methods: convertImageToWorldSpace
and convertWorldToImageSpace
. They both accept an array of coordinates where every 3 elements represent a single point, and they return the converted points.
EDIT
To save anyone else the trial and error, it is the embedded object, not zig
itself that has the undocumented methods. Example:
var zigObj = zig.findZigObject();
user.addEventListener('userupdate', function(user) {
var real = user.skeleton[zig.Joint.Head].position;
var projective = zigObj.convertWorldToImageSpace(real);
// do something with the converted position, like drawing it over the webcam
});