Spaces:
Runtime error
Runtime error
add hide node
Browse files- js/poseMaker.js +26 -25
- main.py +1 -0
js/poseMaker.js
CHANGED
@@ -154,6 +154,10 @@ function cutOffPersonLimb(personIndex, limbIndex) {
|
|
154 |
Redraw();
|
155 |
}
|
156 |
|
|
|
|
|
|
|
|
|
157 |
// ドラッグ中の各キーが押されているかどうかのフラグ
|
158 |
var keyDownFlags = {};
|
159 |
// マウスカーソル
|
@@ -255,7 +259,7 @@ function rotateAndProject(f, p, c, angle) {
|
|
255 |
return [v2[0] + c[0], v2[1] + c[1]];
|
256 |
}
|
257 |
|
258 |
-
function drawBodyPose() {
|
259 |
let stickWidth = 4;
|
260 |
let imageSize = Math.min(canvas.width, canvas.height);
|
261 |
stickWidth *= imageSize / 512;
|
@@ -274,6 +278,7 @@ function drawBodyPose() {
|
|
274 |
const p = pose[limbSeq[j][0]];
|
275 |
const q = pose[limbSeq[j][1]];
|
276 |
if (p == null || q == null) continue;
|
|
|
277 |
const [X0, Y0] = p;
|
278 |
const [X1, Y1] = q;
|
279 |
let angle = Math.atan2(Y1 - Y0, X1 - X0);
|
@@ -296,10 +301,20 @@ function drawBodyPose() {
|
|
296 |
const p = pose[j];
|
297 |
if (p == null) continue;
|
298 |
const [x, y] = p;
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
// ctx.fillStyle = 'rgb(255,255,255)'
|
304 |
// ctx.fillText(j, x-3, y+4);
|
305 |
}
|
@@ -352,10 +367,10 @@ function drawUI() {
|
|
352 |
}
|
353 |
}
|
354 |
|
355 |
-
function Redraw() {
|
356 |
clearCanvas();
|
357 |
drawBackground();
|
358 |
-
drawBodyPose();
|
359 |
drawUI();
|
360 |
}
|
361 |
|
@@ -447,6 +462,7 @@ function handleMouseDown(event) {
|
|
447 |
|
448 |
if (keyDownFlags["KeyD"]) {removePerson(personIndex);return;}
|
449 |
if (keyDownFlags["KeyR"]) {repairPerson(personIndex);return;}
|
|
|
450 |
|
451 |
if (keyDownFlags["KeyQ"] && minDist < 16) {
|
452 |
console.log("pressed KeyQ");
|
@@ -635,24 +651,6 @@ function importPose(jsonData) {
|
|
635 |
Redraw();
|
636 |
}
|
637 |
|
638 |
-
/*
|
639 |
-
function savePose() {
|
640 |
-
const canvasUrl = canvas.toDataURL();
|
641 |
-
|
642 |
-
const createEl = document.createElement('a');
|
643 |
-
createEl.href = canvasUrl;
|
644 |
-
|
645 |
-
// This is the name of our downloaded file
|
646 |
-
createEl.download = "pose.png";
|
647 |
-
|
648 |
-
createEl.click();
|
649 |
-
createEl.remove();
|
650 |
-
|
651 |
-
var [candidate, subset] = poseDataToCandidateAndSubset(poseData);
|
652 |
-
return {candidate: candidate, subset: subset};
|
653 |
-
}
|
654 |
-
*/
|
655 |
-
|
656 |
// crc32
|
657 |
// CRC32を初期化
|
658 |
function initCrc32Table() {
|
@@ -791,6 +789,7 @@ function mergeCanvasWithPose(keyword, content) {
|
|
791 |
function savePose() {
|
792 |
var [candidate, subset] = poseDataToCandidateAndSubset(poseData);
|
793 |
let jsonData = {candidate: candidate, subset: subset};
|
|
|
794 |
|
795 |
var url = mergeCanvasWithPose("openpose", JSON.stringify(jsonData));
|
796 |
|
@@ -803,6 +802,8 @@ function savePose() {
|
|
803 |
createEl.click();
|
804 |
createEl.remove();
|
805 |
|
|
|
|
|
806 |
return jsonData;
|
807 |
}
|
808 |
|
|
|
154 |
Redraw();
|
155 |
}
|
156 |
|
157 |
+
function toggleHideNode(personIndex, nodeIndex) {
|
158 |
+
poseData[personIndex][nodeIndex][2] = !poseData[personIndex][nodeIndex][2];
|
159 |
+
}
|
160 |
+
|
161 |
// ドラッグ中の各キーが押されているかどうかのフラグ
|
162 |
var keyDownFlags = {};
|
163 |
// マウスカーソル
|
|
|
259 |
return [v2[0] + c[0], v2[1] + c[1]];
|
260 |
}
|
261 |
|
262 |
+
function drawBodyPose(saving) {
|
263 |
let stickWidth = 4;
|
264 |
let imageSize = Math.min(canvas.width, canvas.height);
|
265 |
stickWidth *= imageSize / 512;
|
|
|
278 |
const p = pose[limbSeq[j][0]];
|
279 |
const q = pose[limbSeq[j][1]];
|
280 |
if (p == null || q == null) continue;
|
281 |
+
if (p[2] || q[2]) { continue; }
|
282 |
const [X0, Y0] = p;
|
283 |
const [X1, Y1] = q;
|
284 |
let angle = Math.atan2(Y1 - Y0, X1 - X0);
|
|
|
301 |
const p = pose[j];
|
302 |
if (p == null) continue;
|
303 |
const [x, y] = p;
|
304 |
+
if (p[2]) {
|
305 |
+
if (!saving) {
|
306 |
+
ctx.beginPath();
|
307 |
+
ctx.arc(x, y, stickWidth, 0, 2 * Math.PI);
|
308 |
+
ctx.lineWidth = 1;
|
309 |
+
ctx.strokeStyle = `rgb(${colors[j].join(',')})`;
|
310 |
+
ctx.stroke();
|
311 |
+
}
|
312 |
+
} else {
|
313 |
+
ctx.beginPath();
|
314 |
+
ctx.arc(x, y, stickWidth, 0, 2 * Math.PI);
|
315 |
+
ctx.fillStyle = `rgb(${colors[j].join(',')})`;
|
316 |
+
ctx.fill();
|
317 |
+
}
|
318 |
// ctx.fillStyle = 'rgb(255,255,255)'
|
319 |
// ctx.fillText(j, x-3, y+4);
|
320 |
}
|
|
|
367 |
}
|
368 |
}
|
369 |
|
370 |
+
function Redraw(saving) {
|
371 |
clearCanvas();
|
372 |
drawBackground();
|
373 |
+
drawBodyPose(saving);
|
374 |
drawUI();
|
375 |
}
|
376 |
|
|
|
462 |
|
463 |
if (keyDownFlags["KeyD"]) {removePerson(personIndex);return;}
|
464 |
if (keyDownFlags["KeyR"]) {repairPerson(personIndex);return;}
|
465 |
+
if (keyDownFlags["KeyH"]) {toggleHideNode(personIndex, nodeIndex);return;}
|
466 |
|
467 |
if (keyDownFlags["KeyQ"] && minDist < 16) {
|
468 |
console.log("pressed KeyQ");
|
|
|
651 |
Redraw();
|
652 |
}
|
653 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
654 |
// crc32
|
655 |
// CRC32を初期化
|
656 |
function initCrc32Table() {
|
|
|
789 |
function savePose() {
|
790 |
var [candidate, subset] = poseDataToCandidateAndSubset(poseData);
|
791 |
let jsonData = {candidate: candidate, subset: subset};
|
792 |
+
Redraw(true);
|
793 |
|
794 |
var url = mergeCanvasWithPose("openpose", JSON.stringify(jsonData));
|
795 |
|
|
|
802 |
createEl.click();
|
803 |
createEl.remove();
|
804 |
|
805 |
+
Redraw();
|
806 |
+
|
807 |
return jsonData;
|
808 |
}
|
809 |
|
main.py
CHANGED
@@ -108,6 +108,7 @@ In this project, MMPose is used for pose estimation.
|
|
108 |
- "X + drag" to **x-axis** pseudo-3D rotation
|
109 |
- "C + drag" to **y-axis** pseudo-3D rotation
|
110 |
- "R + click" to **repair**
|
|
|
111 |
|
112 |
When using Q, X, C, R, pressing and dont release until the operation is complete.
|
113 |
|
|
|
108 |
- "X + drag" to **x-axis** pseudo-3D rotation
|
109 |
- "C + drag" to **y-axis** pseudo-3D rotation
|
110 |
- "R + click" to **repair**
|
111 |
+
- "H + click" to **hide** node
|
112 |
|
113 |
When using Q, X, C, R, pressing and dont release until the operation is complete.
|
114 |
|