wasm_tensorflow_models_pose_detection/
pose.rs1use serde::{Deserialize, Serialize};
2use std::fmt::Debug;
3use wasm_bindgen::JsValue;
4
5#[derive(Serialize, Deserialize, Debug, Clone)]
6pub struct Keypoint {
7 pub x: f64,
8 pub y: f64,
9 pub z: Option<f64>,
10 pub score: Option<f64>,
11 pub name: Option<String>,
12}
13
14#[derive(Serialize, Deserialize, Debug, Clone)]
15pub struct BoundingBox {
16 pub x_min: f64,
17 pub y_min: f64,
18 pub x_max: f64,
19 pub y_max: f64,
20 pub width: f64,
21 pub height: f64,
22}
23
24#[derive(Serialize, Deserialize, Debug, Clone)]
25pub struct Pose {
26 pub keypoints: Vec<Keypoint>,
27 pub score: Option<f64>,
28 pub keypoints_3d: Option<Vec<Keypoint>>,
29 pub bounding_box: Option<BoundingBox>,
30 pub id: Option<f64>,
32}
33
34impl TryFrom<JsValue> for Pose {
35 fn try_from(value: JsValue) -> Result<Self, Self::Error> {
36 Ok(serde_wasm_bindgen::from_value::<Self>(value)?)
37 }
38
39 type Error = serde_wasm_bindgen::Error;
40}