Error in retrieving body data for body tracking SDK 4.0

Hi all,
I am using ZED2 SDK4.0 C++ for body tracking. I used to get the information for the joints using something like ( object.keypoint[index].y) and to get angles (object.local_orientation_per_joint[index].y ). However, I am seeing that the program crashes when I use anything besides (object.keypoint[index]).
I would like to note that things were fine in the previous version SDK 3.8.

Thank you,

Hi @feraskiki
the body tracking indices changed from SDK v3.8 to SDK v4.x according to the model that you are using.
Please check that they are correct.

Hi,
I payed attention to that. The problem here is that the whole program crashes. I used a small index as an example (17), and I don’t recall seeing such behavior before.

Can you share the code so we can test it?
You can send it to support@stereolabs.com if you can’t share it publicly

main.cpp.txt (10.3 KB)

I have attached the file below, I only made changes to main.cpp. I am using the basic example file from body tracking. I can share the whole thing if necessary.

Hi @feraskiki
your code works as expected by simply adding a check on the vector size:

            if(bodies.body_list.size()>0) {
                auto object = bodies.body_list[0];
                if (counter % 20 == 0) {
                    std::cout << "iter= " << counter << "  " << object.id << " " << object.position << " position of blue \n ";
                    std::cout << "time= " << std::chrono::duration_cast<std::chrono::seconds>(end - begin).count() << std::endl;

                    ////////////////////////////////////
                    // problematic line
                    //std::cout << object.local_orientation_per_joint[arr_orient[5]].x << endl;

                }
            }

You cannot call auto object = bodies.body_list[0]; without being sure that at least a skeleton has been detected.

Maybe I am confusing something here. To clarify more, the problem occurs when I uncomment the line underneath (// problematic line). I agree that the camera needs to have tracked a body for sure. The problem is happening after the body is tracked.
The problem is specific to object.local_orientation_per_joint. Does it work fine for you?

I would like also to point out that model BODY_34 is also a problem and doesn’t work. All other models worked in general but not this. It used to be just a camera view without a skeleton, but now what I am seeing is that the program crashes. For example, BODY_38 or BODY_18 work fine on the same code

You should always check the size of a vector before accessing it by index.

In your case, the vector object.local_orientation_per_joint is empty because you did not enable the Body Fitting feature body_tracker_params.enable_body_fitting = false;.

Hello again,
The code is working now, but I am not able to get the orientation values properly. I am getting only zeros for all the joints values. I am using body_38 and I am targeting the right arm side, which corresponds to keypoints (0, 3, 11, 13, 15, 17, 31, 33, 35, 37). The problem is the same with
(object.global_root_orientation) and it gives (nan nan nan nan). Position values for keypoints are good, but orientation values are not. I used to be able to get these values with the prior version (3.8) fine with similar code.
I am accessing the points like the following
object.local_orientation_per_joint[37].z << “,”;