Skip to content

Commit

Permalink
samples updates for 405 (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
P-yver authored Jul 13, 2023
1 parent ccebcdf commit b4d8a6b
Show file tree
Hide file tree
Showing 35 changed files with 1,237 additions and 5,110 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ add_subdirectory("plane detection/plane detection/${TYPE}")
add_subdirectory("plane detection/floor plane/${TYPE}")
add_subdirectory("positional tracking/positional tracking/${TYPE}")
add_subdirectory("spatial mapping/spatial mapping/${TYPE}")
add_subdirectory("spatial mapping/advanced point cloud mapping/${TYPE}")
add_subdirectory("recording/export/sensors/${TYPE}")
add_subdirectory("recording/export/svo/${TYPE}")
add_subdirectory("recording/playback/${TYPE}")
Expand Down
3 changes: 0 additions & 3 deletions body tracking/body tracking/cpp/src/TrackingViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ void createSKPrimitive(sl::BodyData& body, const std::vector<std::pair<T, T>>&ma
}



void render_2D(cv::Mat &left_display, sl::float2 img_scale, std::vector<sl::BodyData> &bodies, bool isTrackingON, bool fastRender) {
cv::Mat overlay = left_display.clone();
cv::Rect roi_render(0, 0, left_display.size().width, left_display.size().height);
Expand All @@ -69,8 +68,6 @@ void render_2D(cv::Mat &left_display, sl::float2 img_scale, std::vector<sl::Body
createSKPrimitive(it, BODY_34_BONES, img_scale, left_display, roi_render, color);
else if (it.keypoint_2d.size() == 38)
createSKPrimitive(it, BODY_38_BONES, img_scale, left_display, roi_render, color);
else //if (it.keypoint_2d.size() == 70)
createSKPrimitive(it, BODY_70_BONES, img_scale, left_display, roi_render, color);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion body tracking/body tracking/cpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main(int argc, char **argv) {
BodyTrackingParameters body_tracker_params;
body_tracker_params.enable_tracking = true; // track people across images flow
body_tracker_params.enable_body_fitting = true; // smooth skeletons moves
body_tracker_params.body_format = sl::BODY_FORMAT::BODY_38;
body_tracker_params.body_format = sl::BODY_FORMAT::BODY_34;
body_tracker_params.detection_model = isJetson ? BODY_TRACKING_MODEL::HUMAN_BODY_FAST : BODY_TRACKING_MODEL::HUMAN_BODY_ACCURATE;
//body_tracker_params.allow_reduced_precision_inference = true;

Expand Down
109 changes: 3 additions & 106 deletions body tracking/body tracking/csharp/GLViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public void update(Mat pointCloud_, Bodies bodies, sl.Pose pose)

if (keypoints.Length > 0)
{
if (body_format_ == BODY_FORMAT.POSE_38)
if (body_format_ == BODY_FORMAT.BODY_38)
{
foreach (var limb in SKELETON_BONES_POSE_38)
foreach (var limb in SKELETON_BONES_BODY_38)
{
Vector3 kp_1 = keypoints[getIdx(limb.Item1)];
Vector3 kp_2 = keypoints[getIdx(limb.Item2)];
Expand All @@ -138,35 +138,7 @@ public void update(Mat pointCloud_, Bodies bodies, sl.Pose pose)
}
}
}
else if (body_format_ == BODY_FORMAT.POSE_70)
{
foreach (var limb in BODY_BONES_POSE_70)
{
Vector3 kp_1 = keypoints[getIdx(limb.Item1)];
Vector3 kp_2 = keypoints[getIdx(limb.Item2)];

float norm_1 = kp_1.Length();
float norm_2 = kp_2.Length();

if (!float.IsNaN(norm_1) && norm_1 > 0 && !float.IsNaN(norm_2) && norm_2 > 0)
{
skeleton.addCylinder(new float3(kp_1.X, kp_1.Y, kp_1.Z), new float3(kp_2.X, kp_2.Y, kp_2.Z), clr_id);
}
}

for (int i = 0; i < keypoints.Length; i++)
{
Vector3 kp = keypoints[i];
float norm = kp.Length();

if (!float.IsNaN(norm) && norm > 0)
{
skeleton.addSphere(sphere, new float3(kp.X, kp.Y, kp.Z), clr_id);
}
}
}
}

}
}
}
Expand Down Expand Up @@ -380,12 +352,7 @@ int getIdx(BODY_38_PARTS part)
return (int)(part);
}

int getIdx(BODY_70_PARTS part)
{
return (int)(part);
}

private static readonly Tuple<sl.BODY_38_PARTS, sl.BODY_38_PARTS>[] SKELETON_BONES_POSE_38 =
public static readonly Tuple<sl.BODY_38_PARTS, sl.BODY_38_PARTS>[] SKELETON_BONES_BODY_38 =
{
Tuple.Create<BODY_38_PARTS, BODY_38_PARTS>(BODY_38_PARTS.PELVIS, BODY_38_PARTS.SPINE_1),
Tuple.Create<BODY_38_PARTS, BODY_38_PARTS>(BODY_38_PARTS.SPINE_1, BODY_38_PARTS.SPINE_2),
Expand Down Expand Up @@ -426,76 +393,6 @@ int getIdx(BODY_70_PARTS part)
Tuple.Create<BODY_38_PARTS, BODY_38_PARTS>(BODY_38_PARTS.RIGHT_ANKLE, BODY_38_PARTS.RIGHT_SMALL_TOE)
};

private static readonly Tuple<sl.BODY_70_PARTS, sl.BODY_70_PARTS>[] BODY_BONES_POSE_70 =
{
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.PELVIS, BODY_70_PARTS.SPINE_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.SPINE_1, BODY_70_PARTS.SPINE_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.SPINE_2, BODY_70_PARTS.SPINE_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.SPINE_3, BODY_70_PARTS.NECK),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.PELVIS, BODY_70_PARTS.LEFT_HIP),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.PELVIS, BODY_70_PARTS.RIGHT_HIP),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.NECK, BODY_70_PARTS.NOSE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.NECK, BODY_70_PARTS.LEFT_CLAVICLE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_CLAVICLE, BODY_70_PARTS.LEFT_SHOULDER),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.NECK, BODY_70_PARTS.RIGHT_CLAVICLE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_CLAVICLE, BODY_70_PARTS.RIGHT_SHOULDER),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.NOSE, BODY_70_PARTS.LEFT_EYE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_EYE, BODY_70_PARTS.LEFT_EAR),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.NOSE, BODY_70_PARTS.RIGHT_EYE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_EYE, BODY_70_PARTS.RIGHT_EAR),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_SHOULDER, BODY_70_PARTS.LEFT_ELBOW),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_ELBOW, BODY_70_PARTS.LEFT_WRIST),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_WRIST, BODY_70_PARTS.LEFT_HAND_THUMB_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_THUMB_1, BODY_70_PARTS.LEFT_HAND_THUMB_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_THUMB_2, BODY_70_PARTS.LEFT_HAND_THUMB_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_THUMB_3, BODY_70_PARTS.LEFT_HAND_THUMB_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_WRIST, BODY_70_PARTS.LEFT_HAND_INDEX_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_INDEX_1, BODY_70_PARTS.LEFT_HAND_INDEX_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_INDEX_2, BODY_70_PARTS.LEFT_HAND_INDEX_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_INDEX_3, BODY_70_PARTS.LEFT_HAND_INDEX_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_WRIST, BODY_70_PARTS.LEFT_HAND_MIDDLE_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_MIDDLE_1, BODY_70_PARTS.LEFT_HAND_MIDDLE_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_MIDDLE_2, BODY_70_PARTS.LEFT_HAND_MIDDLE_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_MIDDLE_3, BODY_70_PARTS.LEFT_HAND_MIDDLE_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_WRIST, BODY_70_PARTS.LEFT_HAND_RING_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_RING_1, BODY_70_PARTS.LEFT_HAND_RING_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_RING_2, BODY_70_PARTS.LEFT_HAND_RING_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_RING_3, BODY_70_PARTS.LEFT_HAND_RING_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_WRIST, BODY_70_PARTS.LEFT_HAND_PINKY_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_PINKY_1, BODY_70_PARTS.LEFT_HAND_PINKY_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_PINKY_2, BODY_70_PARTS.LEFT_HAND_PINKY_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HAND_PINKY_3, BODY_70_PARTS.LEFT_HAND_PINKY_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_SHOULDER, BODY_70_PARTS.RIGHT_ELBOW),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_ELBOW, BODY_70_PARTS.RIGHT_WRIST),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_WRIST, BODY_70_PARTS.RIGHT_HAND_THUMB_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_THUMB_1, BODY_70_PARTS.RIGHT_HAND_THUMB_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_THUMB_2, BODY_70_PARTS.RIGHT_HAND_THUMB_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_THUMB_3, BODY_70_PARTS.RIGHT_HAND_THUMB_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_WRIST, BODY_70_PARTS.RIGHT_HAND_INDEX_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_INDEX_1, BODY_70_PARTS.RIGHT_HAND_INDEX_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_INDEX_2, BODY_70_PARTS.RIGHT_HAND_INDEX_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_INDEX_3, BODY_70_PARTS.RIGHT_HAND_INDEX_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_WRIST, BODY_70_PARTS.RIGHT_HAND_MIDDLE_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_MIDDLE_1, BODY_70_PARTS.RIGHT_HAND_MIDDLE_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_MIDDLE_2, BODY_70_PARTS.RIGHT_HAND_MIDDLE_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_MIDDLE_3, BODY_70_PARTS.RIGHT_HAND_MIDDLE_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_WRIST, BODY_70_PARTS.RIGHT_HAND_RING_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_RING_1, BODY_70_PARTS.RIGHT_HAND_RING_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_RING_2, BODY_70_PARTS.RIGHT_HAND_RING_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_RING_3, BODY_70_PARTS.RIGHT_HAND_RING_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_WRIST, BODY_70_PARTS.RIGHT_HAND_PINKY_1),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_PINKY_1, BODY_70_PARTS.RIGHT_HAND_PINKY_2),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_PINKY_2, BODY_70_PARTS.RIGHT_HAND_PINKY_3),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HAND_PINKY_3, BODY_70_PARTS.RIGHT_HAND_PINKY_4),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_HIP, BODY_70_PARTS.LEFT_KNEE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_ANKLE, BODY_70_PARTS.LEFT_HEEL),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_ANKLE, BODY_70_PARTS.LEFT_BIG_TOE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.LEFT_ANKLE, BODY_70_PARTS.LEFT_SMALL_TOE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_HIP, BODY_70_PARTS.RIGHT_KNEE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_ANKLE, BODY_70_PARTS.RIGHT_HEEL),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_ANKLE, BODY_70_PARTS.RIGHT_BIG_TOE),
Tuple.Create<BODY_70_PARTS, BODY_70_PARTS>(BODY_70_PARTS.RIGHT_ANKLE, BODY_70_PARTS.RIGHT_SMALL_TOE)
};

public void exit()
{
Expand Down
2 changes: 1 addition & 1 deletion body tracking/body tracking/csharp/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public MainWindow(string[] args)
bt_params.enableBodyFitting = true; // smooth skeletons moves
bt_params.imageSync = true; // the body tracking is synchronized to the image
bt_params.detectionModel = sl.BODY_TRACKING_MODEL.HUMAN_BODY_ACCURATE;
bt_params.bodyFormat = sl.BODY_FORMAT.POSE_38;
bt_params.bodyFormat = sl.BODY_FORMAT.BODY_38;

zedCamera.EnableBodyTracking(ref bt_params);

Expand Down
Loading

0 comments on commit b4d8a6b

Please sign in to comment.