问题
I am looking into the tensorflow implementation of posenet to do pose estimation in real time and also if possible in an offline mode. I am looking into the following repo :
https://github.com/tensorflow/tfjs-models/tree/master/posenet
The keypoints are read out in the following function in the following section of code
export function drawKeypoints(keypoints, minConfidence, ctx, scale = 1) {
for (let i = 0; i < keypoints.length; i++) {
const keypoint = keypoints[i];
if (keypoint.score < minConfidence) {
continue;
}
const {y, x} = keypoint.position;
drawPoint(ctx, y * scale, x * scale, 3, color);
}
}
https://github.com/tensorflow/tfjs-models/blob/master/posenet/demos/demo_util.js
I was looking into the possibility to extract the keypoints to a json file and if it was possible to do so ?
Any tips on this regard would be very helpful .
回答1:
Blob saving to a file is a common way of writing to a file in the browser environment. In the nodejs server, one can use the fs module for that purpose.
Here is a way of doing it in the browser
var blob = new Blob( [ keypointsData ], {
type: 'application/octet-stream'
});
var url = URL.createObjectURL( blob );
var link = document.createElement( 'a' );
link.setAttribute( 'href', url );
link.setAttribute( 'download', 'data.json' );
var event = document.createEvent( 'MouseEvents' );
event.initMouseEvent( 'click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent( event );
来源:https://stackoverflow.com/questions/55533698/extracting-keypoints-from-posenet-to-a-json-file