From 448b8508cd7fa47cd06684d7e6b363b7e997ed5f Mon Sep 17 00:00:00 2001 From: huchenlei Date: Mon, 29 May 2023 16:35:18 -0400 Subject: [PATCH] :bug: Fix default hands --- output_pose.json | 210 +++++++++++++++++++++--------------------- pose.json | 195 --------------------------------------- pose_hand_fixed.json | 194 +++++++++++++++++++++++++++++++++++++++ process_keypoints.py | 14 ++- src/App.vue | 212 +++++++++++++++++++++---------------------- 5 files changed, 414 insertions(+), 411 deletions(-) delete mode 100644 pose.json create mode 100644 pose_hand_fixed.json diff --git a/output_pose.json b/output_pose.json index 373c1f6..19edf9a 100644 --- a/output_pose.json +++ b/output_pose.json @@ -2,215 +2,215 @@ "left_hand": [ [ 72.0, - 120.0, - 1.0 + 138.6749968987715, + 1 ], [ 50.00001525878906, - 108.0, - 1.0 + 126.6749968987715, + 1 ], [ 26.000015258789062, - 91.0, - 1.0 + 109.6749968987715, + 1 ], [ 15.0, - 71.0, - 1.0 + 89.6749968987715, + 1 ], [ 0.0, - 56.0, - 1.0 + 74.6749968987715, + 1 ], [ - 50.00001525878906, - 55.0, - 1.0 + 46.88441843878036, + 68.06475585206891, + 1 ], [ - 44.00001525878906, - 30.0, - 1.0 + 44.700867221123644, + 41.31155552497435, + 1 ], [ 42.99998474121094, - 10.0, - 1.0 + 22.714115786649984, + 1 ], [ - 41.00001525878906, - -117.0, - 1.0 + 42.00298865302648, + 7.0136598257858935, + 1 ], [ - 66.99998474121094, - 53.0, - 1.0 + 66.64955876004365, + 63.25333859753661, + 1 ], [ 65.00001525878906, - 22.0, - 1.0 + 40.6749968987715, + 1 ], [ - 66.99998474121094, + 65.94870679770906, + 22.18139755296059, + 1 + ], + [ + 65.38117571016846, 0.0, - 1.0 + 1 ], [ - -508.0000000298023, - -117.0, - 1.0 + 82.28699289317831, + 68.16587713769567, + 1 ], [ - 81.0, - 56.0, - 1.0 + 84.50425981167291, + 45.869876375420176, + 1 ], [ - 81.0, - 30.0, - 1.0 + 85.4529971269601, + 27.623076702514766, + 1 ], [ - 83.00001525878906, - 10.0, - 1.0 + 85.02609712479875, + 9.122938432072758, + 1 ], [ - 83.00001525878906, - -117.0, - 1.0 + 98.0260818660098, + 76.01283565581218, + 1 ], [ - 96.0, - 64.0, - 1.0 + 103.05127794350199, + 60.272436637095865, + 1 ], [ - 102.0, - 43.0, - 1.0 + 107.35044123995635, + 46.921796571676936, + 1 ], [ - 107.00001525878906, - 30.0, - 1.0 - ], - [ - 110.00001525878906, - 16.0, - 1.0 + 110.70086722112376, + 31.519236310001304, + 1 ] ], "right_hand": [ [ 37.00000762939453, - 127.0, - 1.0 + 140.03029482565358, + 1 ], [ 59.000003814697266, - 119.0, - 1.0 + 132.03029482565358, + 1 ], [ 83.00000381469727, - 104.0, - 1.0 + 117.0302948256536, + 1 ], [ 99.99999618530273, - 86.0, - 1.0 + 99.0302948256536, + 1 ], [ 117.99999618530273, - 75.0, - 1.0 + 88.0302948256536, + 1 ], [ - 64.00000762939453, - 67.0, - 1.0 + 68.60503479194651, + 69.66265371825791, + 1 ], [ 72.0000114440918, - 38.0, - 1.0 + 51.0302948256536, + 1 ], [ 75.99999618530273, - 21.0, - 1.0 + 34.0302948256536, + 1 ], [ 80.00000381469727, - 4.0, - 1.0 + 17.0302948256536, + 1 ], [ - 45.0, - 64.0, - 1.0 + 47.878141976595, + 66.66265371825791, + 1 ], [ - 50.000003814697266, - 29.0, - 1.0 + 49.424375419378265, + 45.4861751947855, + 1 ], [ 51.0, - 8.0, - 1.0 + 21.0302948256536, + 1 ], [ 54.0, - -104.0, - 1.0 + 0.0, + 1 ], [ - 29.000003814697266, - 67.0, - 1.0 + 29.575632210016238, + 70.81461384130189, + 1 ], [ 30.0, - 35.0, - 1.0 + 44.574414456521666, + 1 ], [ - 32.000003814697266, - 16.0, - 1.0 + 30.848747024059264, + 26.150394518043655, + 1 ], [ - 34.00000762939453, - 0.0, - 1.0 + 34.57563602471356, + 7.270494210433782, + 1 ], [ 11.000003814697266, - 70.0, - 1.0 + 78.99843439499973, + 1 ], [ 8.000003814697266, - 48.0, - 1.0 + 61.0302948256536, + 1 ], [ 4.000007629394531, - 35.0, - 1.0 + 48.0302948256536, + 1 ], [ 0.0, - 21.0, - 1.0 + 34.0302948256536, + 1 ] ], "face": [] diff --git a/pose.json b/pose.json deleted file mode 100644 index fce7def..0000000 --- a/pose.json +++ /dev/null @@ -1,195 +0,0 @@ -{ - "people": [ - { - "pose_keypoints_2d": [ - 0.4778645833333333, - 0.3359375, - 1.0, - 0.4778645833333333, - 0.587890625, - 1.0, - 0.3333333333333333, - 0.587890625, - 1.0, - 0.15104166666666666, - 0.6953125, - 1.0, - 0.19921875, - 0.462890625, - 1.0, - 0.6184895833333334, - 0.59375, - 1.0, - 0.7799479166666666, - 0.724609375, - 1.0, - 0.7565104166666666, - 0.484375, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.4479166666666667, - 0.298828125, - 1.0, - 0.5078125, - 0.298828125, - 1.0, - 0.4088541666666667, - 0.341796875, - 1.0, - 0.55078125, - 0.34375, - 1.0 - ], - "face_keypoints_2d": null, - "hand_left_keypoints_2d": [ - 0.75390625, - 0.4609375, - 1.0, - 0.7252604365348816, - 0.4375, - 1.0, - 0.6940104365348816, - 0.404296875, - 1.0, - 0.6796875, - 0.365234375, - 1.0, - 0.66015625, - 0.3359375, - 1.0, - 0.7252604365348816, - 0.333984375, - 1.0, - 0.7174479365348816, - 0.28515625, - 1.0, - 0.7161458134651184, - 0.24609375, - 1.0, - 0.7135416865348816, - -0.001953125, - 1.0, - 0.7473958134651184, - 0.330078125, - 1.0, - 0.7447916865348816, - 0.26953125, - 1.0, - 0.7473958134651184, - 0.2265625, - 1.0, - -0.0013020833721384406, - -0.001953125, - 1.0, - 0.765625, - 0.3359375, - 1.0, - 0.765625, - 0.28515625, - 1.0, - 0.7682291865348816, - 0.24609375, - 1.0, - 0.7682291865348816, - -0.001953125, - 1.0, - 0.78515625, - 0.3515625, - 1.0, - 0.79296875, - 0.310546875, - 1.0, - 0.7994791865348816, - 0.28515625, - 1.0, - 0.8033854365348816, - 0.2578125, - 1.0 - ], - "hand_right_keypoints_2d": [ - 0.2096354216337204, - 0.44921875, - 1.0, - 0.23828125, - 0.43359375, - 1.0, - 0.26953125, - 0.404296875, - 1.0, - 0.2916666567325592, - 0.369140625, - 1.0, - 0.3151041567325592, - 0.34765625, - 1.0, - 0.2447916716337204, - 0.33203125, - 1.0, - 0.2552083432674408, - 0.275390625, - 1.0, - 0.2604166567325592, - 0.2421875, - 1.0, - 0.265625, - 0.208984375, - 1.0, - 0.2200520783662796, - 0.326171875, - 1.0, - 0.2265625, - 0.2578125, - 1.0, - 0.2278645783662796, - 0.216796875, - 1.0, - 0.2317708283662796, - -0.001953125, - 1.0, - 0.19921875, - 0.33203125, - 1.0, - 0.2005208283662796, - 0.26953125, - 1.0, - 0.203125, - 0.232421875, - 1.0, - 0.2057291716337204, - 0.201171875, - 1.0, - 0.17578125, - 0.337890625, - 1.0, - 0.171875, - 0.294921875, - 1.0, - 0.1666666716337204, - 0.26953125, - 1.0, - 0.1614583283662796, - 0.2421875, - 1.0 - ] - } - ], - "canvas_height": 512, - "canvas_width": 768 -} \ No newline at end of file diff --git a/pose_hand_fixed.json b/pose_hand_fixed.json new file mode 100644 index 0000000..b3a537e --- /dev/null +++ b/pose_hand_fixed.json @@ -0,0 +1,194 @@ +{ + "people": [ + { + "pose_keypoints_2d": [ + 367, + 172, + 1, + 367, + 301, + 1, + 256, + 301, + 1, + 104.85654973694608, + 376.2731965157172, + 1, + 147.0056595578984, + 238.99933417965596, + 1, + 475, + 304, + 1, + 611.9877376245533, + 383.99567216776376, + 1, + 588.9924539228022, + 248.999667089828, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 344, + 153, + 1, + 390, + 153, + 1, + 314, + 175, + 1, + 423, + 176, + 1 + ], + "hand_right_keypoints_2d": [ + 152.01000953674315, + 237, + 1, + 174.0100057220459, + 229, + 1, + 198.0100057220459, + 214, + 1, + 215.00999809265136, + 196, + 1, + 233.00999809265136, + 185, + 1, + 183.61503669929513, + 166.63235889260432, + 1, + 187.01001335144042, + 148, + 1, + 191.00999809265136, + 131, + 1, + 195.0100057220459, + 114, + 1, + 162.88814388394363, + 163.63235889260432, + 1, + 164.4343773267269, + 142.4558803691319, + 1, + 166.01000190734862, + 118, + 1, + 169.01000190734862, + 96.9697051743464, + 1, + 144.58563411736486, + 167.7843190156483, + 1, + 145.01000190734862, + 141.54411963086807, + 1, + 145.8587489314079, + 123.12009969239006, + 1, + 149.58563793206218, + 104.24019938478018, + 1, + 126.01000572204589, + 175.96813956934614, + 1, + 123.01000572204589, + 158, + 1, + 119.01000953674315, + 145, + 1, + 115.01000190734862, + 131, + 1 + ], + "hand_left_keypoints_2d": [ + 592.9895663894382, + 244.00249844938574, + 1, + 570.9895816482273, + 232.00249844938574, + 1, + 546.9895816482273, + 215.00249844938574, + 1, + 535.9895663894382, + 195.00249844938574, + 1, + 520.9895663894382, + 180.00249844938574, + 1, + 567.8739848282186, + 173.39225740268316, + 1, + 565.6904336105619, + 146.6390570755886, + 1, + 563.9895511306491, + 128.04161733726423, + 1, + 562.9925550424647, + 112.34116137640014, + 1, + 587.6391251494819, + 168.58084014815086, + 1, + 585.9895816482273, + 146.00249844938574, + 1, + 586.9382731871473, + 127.50889910357483, + 1, + 586.3707420996067, + 105.32750155061424, + 1, + 603.2765592826165, + 173.49337868830992, + 1, + 605.4938262011111, + 151.19737792603442, + 1, + 606.4425635163983, + 132.950578253129, + 1, + 606.015663514237, + 114.450439982687, + 1, + 619.015648255448, + 181.34033720642643, + 1, + 624.0408443329402, + 165.5999381877101, + 1, + 628.3400076293946, + 152.24929812229118, + 1, + 631.690433610562, + 136.84673786061555, + 1 + ] + } + ], + "canvas_width": 768, + "canvas_height": 512 +} \ No newline at end of file diff --git a/process_keypoints.py b/process_keypoints.py index dd41376..99dbaf8 100644 --- a/process_keypoints.py +++ b/process_keypoints.py @@ -16,15 +16,19 @@ def process_keypoints(nums: List[float], width: int, height: int) -> List[List[f base_x = find_min(nums[::3]) base_y = find_min(nums[1::3]) + normalized = all(abs(num) <= 1.0 for num in nums) + x_factor = width if normalized else 1.0 + y_factor = height if normalized else 1.0 + return [ - [(x-base_x) * width, (y-base_y) * height, c] + [(x-base_x) * x_factor, (y-base_y) * y_factor, c] for x, y, c in zip(nums[::3], nums[1::3], nums[2::3]) ] if __name__ == '__main__': - with open('pose.json', 'r') as f: + with open('pose_hand_fixed.json', 'r') as f: pose = json.load(f) person = pose["people"][0] @@ -33,7 +37,7 @@ if __name__ == '__main__': height = pose['canvas_height'] json.dump({ - 'left_hand': process_keypoints(person['hand_left_keypoints_2d'], width, height), - 'right_hand': process_keypoints(person['hand_right_keypoints_2d'], width, height), - 'face': process_keypoints(person['face_keypoints_2d'], width, height), + 'left_hand': process_keypoints(person.get('hand_left_keypoints_2d'), width, height), + 'right_hand': process_keypoints(person.get('hand_right_keypoints_2d'), width, height), + 'face': process_keypoints(person.get('face_keypoints_2d'), width, height), }, f, indent=4) diff --git a/src/App.vue b/src/App.vue index cb6f091..e5b704d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -69,216 +69,216 @@ const default_body_keypoints: [number, number, number][] = [ const default_left_hand_keypoints: [number, number, number][] = [ [ 72.0, - 120.0, - 1.0 + 138.6749968987715, + 1 ], [ 50.00001525878906, - 108.0, - 1.0 + 126.6749968987715, + 1 ], [ 26.000015258789062, - 91.0, - 1.0 + 109.6749968987715, + 1 ], [ 15.0, - 71.0, - 1.0 + 89.6749968987715, + 1 ], [ - 0.0, - 56.0, - 1.0 + 0.001, + 74.6749968987715, + 1 ], [ - 50.00001525878906, - 55.0, - 1.0 + 46.88441843878036, + 68.06475585206891, + 1 ], [ - 44.00001525878906, - 30.0, - 1.0 + 44.700867221123644, + 41.31155552497435, + 1 ], [ 42.99998474121094, - 10.0, - 1.0 + 22.714115786649984, + 1 ], [ - 41.00001525878906, - -117.0, - 1.0 + 42.00298865302648, + 7.0136598257858935, + 1 ], [ - 66.99998474121094, - 53.0, - 1.0 + 66.64955876004365, + 63.25333859753661, + 1 ], [ 65.00001525878906, - 22.0, - 1.0 + 40.6749968987715, + 1 ], [ - 66.99998474121094, - 0.0, - 1.0 + 65.94870679770906, + 22.18139755296059, + 1 ], [ - -508.0000000298023, - -117.0, - 1.0 + 65.38117571016846, + 0.001, + 1 ], [ - 81.0, - 56.0, - 1.0 + 82.28699289317831, + 68.16587713769567, + 1 ], [ - 81.0, - 30.0, - 1.0 + 84.50425981167291, + 45.869876375420176, + 1 ], [ - 83.00001525878906, - 10.0, - 1.0 + 85.4529971269601, + 27.623076702514766, + 1 ], [ - 83.00001525878906, - -117.0, - 1.0 + 85.02609712479875, + 9.122938432072758, + 1 ], [ - 96.0, - 64.0, - 1.0 + 98.0260818660098, + 76.01283565581218, + 1 ], [ - 102.0, - 43.0, - 1.0 + 103.05127794350199, + 60.272436637095865, + 1 ], [ - 107.00001525878906, - 30.0, - 1.0 + 107.35044123995635, + 46.921796571676936, + 1 ], [ - 110.00001525878906, - 16.0, - 1.0 + 110.70086722112376, + 31.519236310001304, + 1 ] ]; const default_right_hand_keypoints: [number, number, number][] = [ [ 37.00000762939453, - 127.0, - 1.0 + 140.03029482565358, + 1 ], [ 59.000003814697266, - 119.0, - 1.0 + 132.03029482565358, + 1 ], [ 83.00000381469727, - 104.0, - 1.0 + 117.0302948256536, + 1 ], [ 99.99999618530273, - 86.0, - 1.0 + 99.0302948256536, + 1 ], [ 117.99999618530273, - 75.0, - 1.0 + 88.0302948256536, + 1 ], [ - 64.00000762939453, - 67.0, - 1.0 + 68.60503479194651, + 69.66265371825791, + 1 ], [ 72.0000114440918, - 38.0, - 1.0 + 51.0302948256536, + 1 ], [ 75.99999618530273, - 21.0, - 1.0 + 34.0302948256536, + 1 ], [ 80.00000381469727, - 4.0, - 1.0 + 17.0302948256536, + 1 ], [ - 45.0, - 64.0, - 1.0 + 47.878141976595, + 66.66265371825791, + 1 ], [ - 50.000003814697266, - 29.0, - 1.0 + 49.424375419378265, + 45.4861751947855, + 1 ], [ 51.0, - 8.0, - 1.0 + 21.0302948256536, + 1 ], [ 54.0, - -104.0, - 1.0 + 0.001, + 1 ], [ - 29.000003814697266, - 67.0, - 1.0 + 29.575632210016238, + 70.81461384130189, + 1 ], [ 30.0, - 35.0, - 1.0 + 44.574414456521666, + 1 ], [ - 32.000003814697266, - 16.0, - 1.0 + 30.848747024059264, + 26.150394518043655, + 1 ], [ - 34.00000762939453, - 0.0, - 1.0 + 34.57563602471356, + 7.270494210433782, + 1 ], [ 11.000003814697266, - 70.0, - 1.0 + 78.99843439499973, + 1 ], [ 8.000003814697266, - 48.0, - 1.0 + 61.0302948256536, + 1 ], [ 4.000007629394531, - 35.0, - 1.0 + 48.0302948256536, + 1 ], [ - 0.0, - 21.0, - 1.0 + 0.001, + 34.0302948256536, + 1 ] ];