Commit
·
8ae5517
1
Parent(s):
fed3109
feat: 編集モードの改善と矩形描画の最適化
Browse files- 編集モード終了時にGradioに編集結果を送信する機能を追加
- 矩形位置を保持したまま再描画するように変更
- 編集済みキーポイントから手と顔の矩形を計算するロジックを追加
- static/pose_editor.js +24 -5
static/pose_editor.js
CHANGED
|
@@ -337,12 +337,17 @@ function handleMouseDown(event) {
|
|
| 337 |
|
| 338 |
// 矩形外クリック → 編集モード終了
|
| 339 |
debugLog("Clicked outside rectangles, exiting edit mode");
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
window.poseEditorGlobals.rectEditModeActive = false;
|
| 341 |
window.poseEditorGlobals.rectEditMode = null;
|
| 342 |
|
| 343 |
-
//
|
| 344 |
const currentPoseData = window.poseEditorGlobals.poseData || poseData;
|
| 345 |
if (currentPoseData) {
|
|
|
|
| 346 |
drawPose(currentPoseData, window.poseEditorGlobals.enableHands, window.poseEditorGlobals.enableFace);
|
| 347 |
}
|
| 348 |
return;
|
|
@@ -618,8 +623,17 @@ function drawPose(poseData, enableHands = true, enableFace = true, highlightInde
|
|
| 618 |
// 🔧 簡易モード:手の矩形描画(編集モード中は再計算しない)
|
| 619 |
if (window.poseEditorGlobals.editMode === "簡易モード") {
|
| 620 |
if (!window.poseEditorGlobals.rectEditModeActive) {
|
| 621 |
-
//
|
| 622 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 623 |
} else {
|
| 624 |
// 編集モード中:既存の矩形を描画(再計算しない)
|
| 625 |
drawExistingRectangles(['leftHand', 'rightHand']);
|
|
@@ -643,8 +657,13 @@ function drawPose(poseData, enableHands = true, enableFace = true, highlightInde
|
|
| 643 |
// 🔧 簡易モード:顔の矩形描画(編集モード中は再計算しない)
|
| 644 |
if (window.poseEditorGlobals.editMode === "簡易モード") {
|
| 645 |
if (!window.poseEditorGlobals.rectEditModeActive) {
|
| 646 |
-
//
|
| 647 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 648 |
} else {
|
| 649 |
// 編集モード中:既存の矩形を描画(再計算しない)
|
| 650 |
drawExistingRectangles(['face']);
|
|
|
|
| 337 |
|
| 338 |
// 矩形外クリック → 編集モード終了
|
| 339 |
debugLog("Clicked outside rectangles, exiting edit mode");
|
| 340 |
+
|
| 341 |
+
// 🚀 編集モード終了前に編集結果をGradioに送信
|
| 342 |
+
sendPoseDataToGradio();
|
| 343 |
+
|
| 344 |
window.poseEditorGlobals.rectEditModeActive = false;
|
| 345 |
window.poseEditorGlobals.rectEditMode = null;
|
| 346 |
|
| 347 |
+
// 🚀 矩形位置を保持したまま再描画(再計算させない)
|
| 348 |
const currentPoseData = window.poseEditorGlobals.poseData || poseData;
|
| 349 |
if (currentPoseData) {
|
| 350 |
+
// 矩形編集モードをfalseにした直後なので、矩形は保持される
|
| 351 |
drawPose(currentPoseData, window.poseEditorGlobals.enableHands, window.poseEditorGlobals.enableFace);
|
| 352 |
}
|
| 353 |
return;
|
|
|
|
| 623 |
// 🔧 簡易モード:手の矩形描画(編集モード中は再計算しない)
|
| 624 |
if (window.poseEditorGlobals.editMode === "簡易モード") {
|
| 625 |
if (!window.poseEditorGlobals.rectEditModeActive) {
|
| 626 |
+
// 🚀 通常時:編集済みキーポイントから矩形を計算
|
| 627 |
+
if (currentPoseData.people && currentPoseData.people[0]) {
|
| 628 |
+
const person = currentPoseData.people[0];
|
| 629 |
+
const editedHandsData = [
|
| 630 |
+
person.hand_left_keypoints_2d || (currentPoseData.hands && currentPoseData.hands[0]),
|
| 631 |
+
person.hand_right_keypoints_2d || (currentPoseData.hands && currentPoseData.hands[1])
|
| 632 |
+
];
|
| 633 |
+
drawHandRectangles(editedHandsData, originalRes, scaleX, scaleY);
|
| 634 |
+
} else {
|
| 635 |
+
drawHandRectangles(currentPoseData.hands, originalRes, scaleX, scaleY);
|
| 636 |
+
}
|
| 637 |
} else {
|
| 638 |
// 編集モード中:既存の矩形を描画(再計算しない)
|
| 639 |
drawExistingRectangles(['leftHand', 'rightHand']);
|
|
|
|
| 657 |
// 🔧 簡易モード:顔の矩形描画(編集モード中は再計算しない)
|
| 658 |
if (window.poseEditorGlobals.editMode === "簡易モード") {
|
| 659 |
if (!window.poseEditorGlobals.rectEditModeActive) {
|
| 660 |
+
// 🚀 通常時:編集済みキーポイントから矩形を計算
|
| 661 |
+
if (currentPoseData.people && currentPoseData.people[0] && currentPoseData.people[0].face_keypoints_2d) {
|
| 662 |
+
const editedFacesData = [currentPoseData.people[0].face_keypoints_2d];
|
| 663 |
+
drawFaceRectangles(editedFacesData, originalRes, scaleX, scaleY);
|
| 664 |
+
} else {
|
| 665 |
+
drawFaceRectangles(currentPoseData.faces, originalRes, scaleX, scaleY);
|
| 666 |
+
}
|
| 667 |
} else {
|
| 668 |
// 編集モード中:既存の矩形を描画(再計算しない)
|
| 669 |
drawExistingRectangles(['face']);
|