🐛 Fix default hands

main
huchenlei 2023-05-29 16:35:18 -04:00
parent c60a06cb05
commit 448b8508cd
5 changed files with 414 additions and 411 deletions

View File

@ -2,215 +2,215 @@
"left_hand": [ "left_hand": [
[ [
72.0, 72.0,
120.0, 138.6749968987715,
1.0 1
], ],
[ [
50.00001525878906, 50.00001525878906,
108.0, 126.6749968987715,
1.0 1
], ],
[ [
26.000015258789062, 26.000015258789062,
91.0, 109.6749968987715,
1.0 1
], ],
[ [
15.0, 15.0,
71.0, 89.6749968987715,
1.0 1
], ],
[ [
0.0, 0.0,
56.0, 74.6749968987715,
1.0 1
], ],
[ [
50.00001525878906, 46.88441843878036,
55.0, 68.06475585206891,
1.0 1
], ],
[ [
44.00001525878906, 44.700867221123644,
30.0, 41.31155552497435,
1.0 1
], ],
[ [
42.99998474121094, 42.99998474121094,
10.0, 22.714115786649984,
1.0 1
], ],
[ [
41.00001525878906, 42.00298865302648,
-117.0, 7.0136598257858935,
1.0 1
], ],
[ [
66.99998474121094, 66.64955876004365,
53.0, 63.25333859753661,
1.0 1
], ],
[ [
65.00001525878906, 65.00001525878906,
22.0, 40.6749968987715,
1.0 1
], ],
[ [
66.99998474121094, 65.94870679770906,
22.18139755296059,
1
],
[
65.38117571016846,
0.0, 0.0,
1.0 1
], ],
[ [
-508.0000000298023, 82.28699289317831,
-117.0, 68.16587713769567,
1.0 1
], ],
[ [
81.0, 84.50425981167291,
56.0, 45.869876375420176,
1.0 1
], ],
[ [
81.0, 85.4529971269601,
30.0, 27.623076702514766,
1.0 1
], ],
[ [
83.00001525878906, 85.02609712479875,
10.0, 9.122938432072758,
1.0 1
], ],
[ [
83.00001525878906, 98.0260818660098,
-117.0, 76.01283565581218,
1.0 1
], ],
[ [
96.0, 103.05127794350199,
64.0, 60.272436637095865,
1.0 1
], ],
[ [
102.0, 107.35044123995635,
43.0, 46.921796571676936,
1.0 1
], ],
[ [
107.00001525878906, 110.70086722112376,
30.0, 31.519236310001304,
1.0 1
],
[
110.00001525878906,
16.0,
1.0
] ]
], ],
"right_hand": [ "right_hand": [
[ [
37.00000762939453, 37.00000762939453,
127.0, 140.03029482565358,
1.0 1
], ],
[ [
59.000003814697266, 59.000003814697266,
119.0, 132.03029482565358,
1.0 1
], ],
[ [
83.00000381469727, 83.00000381469727,
104.0, 117.0302948256536,
1.0 1
], ],
[ [
99.99999618530273, 99.99999618530273,
86.0, 99.0302948256536,
1.0 1
], ],
[ [
117.99999618530273, 117.99999618530273,
75.0, 88.0302948256536,
1.0 1
], ],
[ [
64.00000762939453, 68.60503479194651,
67.0, 69.66265371825791,
1.0 1
], ],
[ [
72.0000114440918, 72.0000114440918,
38.0, 51.0302948256536,
1.0 1
], ],
[ [
75.99999618530273, 75.99999618530273,
21.0, 34.0302948256536,
1.0 1
], ],
[ [
80.00000381469727, 80.00000381469727,
4.0, 17.0302948256536,
1.0 1
], ],
[ [
45.0, 47.878141976595,
64.0, 66.66265371825791,
1.0 1
], ],
[ [
50.000003814697266, 49.424375419378265,
29.0, 45.4861751947855,
1.0 1
], ],
[ [
51.0, 51.0,
8.0, 21.0302948256536,
1.0 1
], ],
[ [
54.0, 54.0,
-104.0, 0.0,
1.0 1
], ],
[ [
29.000003814697266, 29.575632210016238,
67.0, 70.81461384130189,
1.0 1
], ],
[ [
30.0, 30.0,
35.0, 44.574414456521666,
1.0 1
], ],
[ [
32.000003814697266, 30.848747024059264,
16.0, 26.150394518043655,
1.0 1
], ],
[ [
34.00000762939453, 34.57563602471356,
0.0, 7.270494210433782,
1.0 1
], ],
[ [
11.000003814697266, 11.000003814697266,
70.0, 78.99843439499973,
1.0 1
], ],
[ [
8.000003814697266, 8.000003814697266,
48.0, 61.0302948256536,
1.0 1
], ],
[ [
4.000007629394531, 4.000007629394531,
35.0, 48.0302948256536,
1.0 1
], ],
[ [
0.0, 0.0,
21.0, 34.0302948256536,
1.0 1
] ]
], ],
"face": [] "face": []

195
pose.json
View File

@ -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
}

194
pose_hand_fixed.json Normal file
View File

@ -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
}

View File

@ -16,15 +16,19 @@ def process_keypoints(nums: List[float], width: int, height: int) -> List[List[f
base_x = find_min(nums[::3]) base_x = find_min(nums[::3])
base_y = find_min(nums[1::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 [ 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]) for x, y, c in zip(nums[::3], nums[1::3], nums[2::3])
] ]
if __name__ == '__main__': if __name__ == '__main__':
with open('pose.json', 'r') as f: with open('pose_hand_fixed.json', 'r') as f:
pose = json.load(f) pose = json.load(f)
person = pose["people"][0] person = pose["people"][0]
@ -33,7 +37,7 @@ if __name__ == '__main__':
height = pose['canvas_height'] height = pose['canvas_height']
json.dump({ json.dump({
'left_hand': process_keypoints(person['hand_left_keypoints_2d'], width, height), 'left_hand': process_keypoints(person.get('hand_left_keypoints_2d'), width, height),
'right_hand': process_keypoints(person['hand_right_keypoints_2d'], width, height), 'right_hand': process_keypoints(person.get('hand_right_keypoints_2d'), width, height),
'face': process_keypoints(person['face_keypoints_2d'], width, height), 'face': process_keypoints(person.get('face_keypoints_2d'), width, height),
}, f, indent=4) }, f, indent=4)

View File

@ -69,216 +69,216 @@ const default_body_keypoints: [number, number, number][] = [
const default_left_hand_keypoints: [number, number, number][] = [ const default_left_hand_keypoints: [number, number, number][] = [
[ [
72.0, 72.0,
120.0, 138.6749968987715,
1.0 1
], ],
[ [
50.00001525878906, 50.00001525878906,
108.0, 126.6749968987715,
1.0 1
], ],
[ [
26.000015258789062, 26.000015258789062,
91.0, 109.6749968987715,
1.0 1
], ],
[ [
15.0, 15.0,
71.0, 89.6749968987715,
1.0 1
], ],
[ [
0.0, 0.001,
56.0, 74.6749968987715,
1.0 1
], ],
[ [
50.00001525878906, 46.88441843878036,
55.0, 68.06475585206891,
1.0 1
], ],
[ [
44.00001525878906, 44.700867221123644,
30.0, 41.31155552497435,
1.0 1
], ],
[ [
42.99998474121094, 42.99998474121094,
10.0, 22.714115786649984,
1.0 1
], ],
[ [
41.00001525878906, 42.00298865302648,
-117.0, 7.0136598257858935,
1.0 1
], ],
[ [
66.99998474121094, 66.64955876004365,
53.0, 63.25333859753661,
1.0 1
], ],
[ [
65.00001525878906, 65.00001525878906,
22.0, 40.6749968987715,
1.0 1
], ],
[ [
66.99998474121094, 65.94870679770906,
0.0, 22.18139755296059,
1.0 1
], ],
[ [
-508.0000000298023, 65.38117571016846,
-117.0, 0.001,
1.0 1
], ],
[ [
81.0, 82.28699289317831,
56.0, 68.16587713769567,
1.0 1
], ],
[ [
81.0, 84.50425981167291,
30.0, 45.869876375420176,
1.0 1
], ],
[ [
83.00001525878906, 85.4529971269601,
10.0, 27.623076702514766,
1.0 1
], ],
[ [
83.00001525878906, 85.02609712479875,
-117.0, 9.122938432072758,
1.0 1
], ],
[ [
96.0, 98.0260818660098,
64.0, 76.01283565581218,
1.0 1
], ],
[ [
102.0, 103.05127794350199,
43.0, 60.272436637095865,
1.0 1
], ],
[ [
107.00001525878906, 107.35044123995635,
30.0, 46.921796571676936,
1.0 1
], ],
[ [
110.00001525878906, 110.70086722112376,
16.0, 31.519236310001304,
1.0 1
] ]
]; ];
const default_right_hand_keypoints: [number, number, number][] = [ const default_right_hand_keypoints: [number, number, number][] = [
[ [
37.00000762939453, 37.00000762939453,
127.0, 140.03029482565358,
1.0 1
], ],
[ [
59.000003814697266, 59.000003814697266,
119.0, 132.03029482565358,
1.0 1
], ],
[ [
83.00000381469727, 83.00000381469727,
104.0, 117.0302948256536,
1.0 1
], ],
[ [
99.99999618530273, 99.99999618530273,
86.0, 99.0302948256536,
1.0 1
], ],
[ [
117.99999618530273, 117.99999618530273,
75.0, 88.0302948256536,
1.0 1
], ],
[ [
64.00000762939453, 68.60503479194651,
67.0, 69.66265371825791,
1.0 1
], ],
[ [
72.0000114440918, 72.0000114440918,
38.0, 51.0302948256536,
1.0 1
], ],
[ [
75.99999618530273, 75.99999618530273,
21.0, 34.0302948256536,
1.0 1
], ],
[ [
80.00000381469727, 80.00000381469727,
4.0, 17.0302948256536,
1.0 1
], ],
[ [
45.0, 47.878141976595,
64.0, 66.66265371825791,
1.0 1
], ],
[ [
50.000003814697266, 49.424375419378265,
29.0, 45.4861751947855,
1.0 1
], ],
[ [
51.0, 51.0,
8.0, 21.0302948256536,
1.0 1
], ],
[ [
54.0, 54.0,
-104.0, 0.001,
1.0 1
], ],
[ [
29.000003814697266, 29.575632210016238,
67.0, 70.81461384130189,
1.0 1
], ],
[ [
30.0, 30.0,
35.0, 44.574414456521666,
1.0 1
], ],
[ [
32.000003814697266, 30.848747024059264,
16.0, 26.150394518043655,
1.0 1
], ],
[ [
34.00000762939453, 34.57563602471356,
0.0, 7.270494210433782,
1.0 1
], ],
[ [
11.000003814697266, 11.000003814697266,
70.0, 78.99843439499973,
1.0 1
], ],
[ [
8.000003814697266, 8.000003814697266,
48.0, 61.0302948256536,
1.0 1
], ],
[ [
4.000007629394531, 4.000007629394531,
35.0, 48.0302948256536,
1.0 1
], ],
[ [
0.0, 0.001,
21.0, 34.0302948256536,
1.0 1
] ]
]; ];