Stream body tracking data to UDP or OSC in C++ (no Unity and no UE)

Hi, I want to get body tracking data from 1 camera to my custom webapp, so no Unity nor UE.

I saw that there is https://www.stereolabs.com/docs/livelink to do that but is it possible to get the data in my webapp.

My webapp is local and will be able to read from any UDP or OSC incoming data.

What UDP port does Live Link stream the body tracking data to ?
What is the data protocol of that stream and will I be able to read/decode the data if I listen myself on the UDP port of Live stream?

Thanks for your help

Re,Ok I got some of my answers here https://www.stereolabs.com/docs/livelink/livelink-unity/

Can you confirm that I can use anything that can listen to the UDP port that Live Link is configured with?

Can I just add this code in the C++ bodytracking code?

// ----------------------------------
    // UDP to Unity----------------------
    // ----------------------------------
    std::string servAddress;
    unsigned short servPort;
    UDPSocket sock;

    sock.setMulticastTTL(1);

    servAddress = "230.0.0.1";
    servPort = 20001;

    std::cout << "Sending fused data at " << servAddress << ":" << servPort << std::endl;
    // ----------------------------------
    // UDP to Unity----------------------
    // ----------------------------------

Or does it need to be compiled and run as a separate program in parallel as the bodytracking program?

Hi @robotpapier,

The implementation of LiveLink for Unity is basically just a C++ Body tracking sample from the SDK to which is added the UDP sending part (via the library whose header you can find in the project on GitHub). The UDP sending is actually processed in the same main loop as the Body Tracking, so no, you don’t need to have a secondary program. However, you need to add a bit more code to your project.

Please take a look at the sender sample on GitHub to get inspiration for yours. In the same vein, the receiver code can be found here (C#): ZED Streaming Client.

Note that we send the body tracking data in a particular formatting via json, you’ll need to match it in your app if you want to use the sample as is.

1 Like

Thanks @JPlou
Just succeeded implementing this.
I just had to add an OSC library to send with the OSC format rather than json.
My client is Maxmsp can decode OSC out of the box.

1 Like

Hi,
can you help me with the other way around ?
I would like to listen to incoming upd data.
I have tried this below but I received in the console.

Receive failed (recvfrom()): No error

Here is my code :

I declare outside the main loop:

std::string recvAddress;
unsigned short recvPort;
recvPort = 20002;

then in the main loop

// UDP Receive
        try
        {
            sock.recvFrom(recv_buffer, max_data_recv_buffer_size, recvAddress, recvPort);
            //std::string receivedData((char*)recv_buffer, bytesReceived);
            std::cout << "Received : " << recv_buffer << std::endl;
        }
        catch (SocketException& e)
        {
            cerr << "errror" << e.what() << std::endl;
}
            

and even tried this way :

// UDP Receive
        try
        {
            size_t bytesReceived = sock.recvFrom(recv_buffer, max_data_recv_buffer_size, recvAddress, recvPort);
            std::string receivedData(recv_buffer, bytesReceived);
            std::cout << "Received : " << receivedData << std::endl;
        }
        catch (SocketException& e)
        {
            cerr << "errror" << e.what() << std::endl;
            //exit(1);
        }

Am I missing something?