Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    AI for Body Part Recognition

    2D Blocks
    1
    1
    371
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • info-creaticode
      CreatiCode last edited by admin

       

      Introduction

       

      You can use AI to recognize the key body parts of a person standing in front of the camera — such as their eyes, nose, shoulders, arms, and legs. This type of detection can be useful in many applications, especially for estimating a person’s pose (e.g., standing, sitting, or raising a hand).

       

      The AI Block

       

      To start detecting body parts, run this block:

      48cb84e4-5335-4ece-9976-01496b6be911-image.png

       
      This block turns on your computer’s front-facing camera and begins scanning for one or more people in the frame. Detected body parts are identified and their attributes are stored in a data table.

      Let’s break down the 3 input parameters:

       

      Single Person

       

      • If this is set to “Yes”, the AI will only track one person, even if there are multiple people in view.
      • If set to “No”, the AI will report all detected people.
      • In most cases — especially when the program is intended for a single user — choose “Yes”.

       

       

      Result Table

       

      This option determines where the detection results are stored. You can either:

      • Use the default table (created automatically), or
      • Select/create a custom table.

      The table includes 6 columns and 21 rows per person: the first 17 rows correspond to individual body parts, and the last 4 rows represent the 4 limbs.

       

      - First 17 Rows (Body Parts)

       
      These rows store data only in the first 4 columns:

      • The ID column is a unique identifier for each detected person. You can ignore it if your program only works with a single person.

      • The part column contains the name of the body part. Here is the full list: nose, left_eye, right_eye, left_ear, right_ear, left_shoulder, right_shoulder, left_elbow, right_elbow, left_wrist, right_wrist, left_hip, right_hip, left_knee, right_knee, left_ankle, right_ankle.

      • The X and Y values are the x and y positions of that part in the camera image. For example, if the nose is at the center of the image, then its x and y positions will both be 0.

      ![f14892c4-5ace-4cc7-a89b-c474b8f87f00.png](https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f14892c4-5ace-4cc7-a89b-c474b8f87f00.png

       

       

      - Next 4 Rows (Limbs)

       

      For each person that’s detected, the 4 rows below the 17 rows will use:

      • Columns 1 & 2: ID and part
      • Columns 5 & 6: curl and dir

      The meanings of these columns:

      • The ID column is still the unique ID for each detected person.

      • The part column contains name of the limb: “left_arm”, “right_arm”, “left_leg”, “right_leg”.

      • The curl column (the 5th column) tells us the curling (bending) angle of that limb. If that limb is extended in a straight line, then its curling angle is close to 180 degrees. If that limb is curled at the elbow or knee, then this angle will be much smaller.

      • The dir column (the 6th column) tells us the direction of that limb. For arms, this is the direction of the line from the shoulder to the elbow (the wrist is not considered here). For legs, this refers to the direction from the hip to the knee (the ankle is not included).

       
      For example, in this picture of Superman,

      • Both arms are bent ≈ 90°, both legs are straight ≈ 180°
      • All limbs are pointing downward.

      dc8c8c86-ee2f-4cd2-9b2c-9be260aee447-image.png

      e16981b2-cd42-4ff6-bf41-d91fab2bf758-image.png

       

      🛠️ Debug Mode

       

      If Debug is set to “yes”, visual markers (dots and lines) will be drawn over the camera image to show the detected body parts.

      If “no”, the video feed is shown with no overlays.

       
       

      Example - Two People from a Picture

       

      If you set single-person to “no”, the AI will detect and track multiple people at the same time.

      c6807910-4ded-4c84-8f0c-4a26b95c266e.png

      If you move the camera, both people will be recognized continuously in real-time.

      Each person will generate 21 rows in the table — so with two people, the result table will contain 42 rows.

      9d57ab0b-9ac5-4579-8633-67aed694fbd5.gif

      1 Reply Last reply Reply Quote 0
      • First post
        Last post