|
7305 | 7305 | "\n",
|
7306 | 7306 | "\n",
|
7307 | 7307 | "def calc_hand_data(iv):\n",
|
7308 |
| - " origin = to_vec(calculate_origin(iv.hmap[0][..., 9]))\n", |
| 7308 | + " origin = to_vec(calc_origin(iv.hmap[0][..., 9]))\n", |
7309 | 7309 | "# origin = to_vec([iv.uv[9][1] / 32, 1 - (iv.uv[9][0]) / 32])\n",
|
7310 | 7310 | " \n",
|
7311 | 7311 | "# UV instead of XY\n",
|
7312 | 7312 | "# joints = list([to_vec([*(uv[::-1]/32), xyz[2]]) for xyz, uv in zip(iv.xyz, iv.uv)])\n",
|
7313 | 7313 | "# joints = list([to_vec([*(uv[::-1]/32), xyz[2]]) for xyz, uv in zip(iv.xyz, xy)])\n",
|
7314 | 7314 | " \n",
|
7315 | 7315 | " joints = list([to_vec(xyz) for xyz in iv.xyz.tolist()]) # tolist, because 0mq can't work with np.float\n",
|
7316 |
| - " \n", |
7317 |
| - " dists_x = np.array([32 *\n", |
7318 |
| - " np.linalg.norm(iv.xyz[i[1:], :2] - iv.xyz[i[:-1], :2]) /\n", |
7319 |
| - " np.linalg.norm(iv.uv[i[1:]] - iv.uv[i[:-1]])\n", |
7320 |
| - " for i in indexes_x])\n", |
7321 | 7316 | "\n",
|
7322 |
| - " dists_y = np.array([32 * \n", |
7323 |
| - " np.linalg.norm(iv.xyz[i[1:], :2] - iv.xyz[i[:-1], :2]) /\n", |
7324 |
| - " np.linalg.norm(iv.uv[i[1:]] - iv.uv[i[:-1]])\n", |
7325 |
| - " for i in indexes_y])\n", |
| 7317 | + " def calc_dists(indexes):\n", |
| 7318 | + " return np.array([\n", |
| 7319 | + " np.linalg.norm(iv.xyz[i[1:], :2] - iv.xyz[i[:-1], :2]) * 32 /\n", |
| 7320 | + " np.linalg.norm(iv.uv[i[1:]] - iv.uv[i[:-1]])\n", |
| 7321 | + " for i in indexes\n", |
| 7322 | + " ])\n", |
| 7323 | + "\n", |
| 7324 | + " dists_x = filter_nan_inf(calc_dists(indexes_x))\n", |
| 7325 | + " dists_y = filter_nan_inf(calc_dists(indexes_y))\n", |
| 7326 | + "\n", |
| 7327 | + " if dists_x.size == 0 or dists_y.size == 0:\n", |
| 7328 | + " return None\n", |
7326 | 7329 | "\n",
|
7327 |
| - " dist_x = np.mean(filter_nan_inf(dists_x))\n", |
7328 |
| - " dist_y = np.mean(filter_nan_inf(dists_y))\n", |
| 7330 | + " dist_x = np.mean(dists_x)\n", |
| 7331 | + " dist_y = np.mean(dists_y)\n", |
7329 | 7332 | " \n",
|
7330 | 7333 | "# palm_size = sum(np.linalg.norm(iv.xyz[0] - iv.xyz[i]) for i in [1, 5, 9, 13, 17])\n",
|
7331 | 7334 | " \n",
|
|
7336 | 7339 | " return origin, joints, dist_x, dist_y, vert\n",
|
7337 | 7340 | "\n",
|
7338 | 7341 | "\n",
|
7339 |
| - "data_originL, data_jointsL, data_distXL, data_distYL, data_palmSizeL, data_vertL = calc_hand_data(ivl)\n", |
7340 |
| - "data_originR, data_jointsR, data_distXR, data_distYR, data_palmSizeR, data_vertR = calc_hand_data(ivr)\n", |
| 7342 | + "data_originL, data_jointsL, data_distXL, data_distYL, data_vertL = calc_hand_data(ivl)\n", |
| 7343 | + "data_originR, data_jointsR, data_distXR, data_distYR, data_vertR = calc_hand_data(ivr)\n", |
7341 | 7344 | "\n",
|
7342 | 7345 | "scaleXL = data_vertL * data_distXL + (1 - data_vertL) * data_distYL\n",
|
7343 | 7346 | "scaleYL = data_vertL * data_distYL + (1 - data_vertL) * data_distXL\n",
|
|
0 commit comments