How do I send Kinect v1 depth data over OscP5 from one computer to another?

edited November 2017 in Kinect

I am trying to send kinect depth from one computer to create a point cloud on another. I have tried sending the data through OSC, but I'm not sure how to declare it on the receiving end as the depth data is sending as an int[].

This is not my entire code for each side, just what matters to my question to avoid confusion: (hello is what I am trying to send) This is the sender code.

int[] hello;

void draw() {
  int[] depth = kinect.getRawDepth();

  hello = depth;

void OscEvent(OscMessage theOscMessage) {
  //create a message with a unique address pattern
  OscMessage myOutGoingMessage = new OscMessage( playerAddressPattern ); 
  myOutGoingMessage.add(hello); //send the depth data (as an int string)
  osc.send( myOutGoingMessage, destination );  

This is the applicable code from the receiver

int[] hello;//Declare the depth that is coming in from the kinect

int[] depth = hello; // the actual depth data coming from the remote kinect as the variable "hello"

void OscEvent (OscMessage theOscMessage) {
  hello=theOscMessage.get(0).intvalue(); //the value being received is an int[], not an int as i have typed- how do i declare this?

So what might help me here is how would i declare that " hello=theOscMessage.get(0).intvalue();" as an int[]

(MacOS High Sierra, Processing 3.0.1)



  • You should have continue in your previous post:

    Anyways, I am not an expert on the oscP5 but I think you could try this below. First,send a smaller package between two computers in the same network. Then try increasing the size of the package. Not sure if you have to allow larger packages in your router settings. However, if you start with smaller packages, then you don't have to deal with this issue upfront. I just saw recently in another post that you could use spout, another library that sends textures. Maybe you should look into it as it might be doing some of the data handling for you.

    My only question is that if, when you are sending the array package, if it is not being modified by the oscP5 object. I am hoping that the methods implemented in oscArgument would be reverting any changes and allow you to retrieve your raw data.


    import oscP5.*;
    import netP5.*;
    OscP5 oscP5;
    NetAddress myRemoteLocation;
    void setup() {
      size(400, 400);
      /* start oscP5, listening for incoming messages at port 12000 */
      oscP5 = new OscP5(this, 12000);
      /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
       * an ip address and a port number. myRemoteLocation is used as parameter in
       * oscP5.send() when sending osc packets to another computer, device, 
       * application. usage see below. for testing purposes the listening port
       * and the port of the remote location address are the same, hence you will
       * send messages back to this sketch.
      myRemoteLocation = new NetAddress("", 12000);
    void draw() {
    void mousePressed() {
      /* in the following different ways of creating osc messages are shown by example */
      OscMessage myMessage = new OscMessage("/mouseTest");
      myMessage.add(123); /* add an int to the osc message */
      myMessage.add(12.34); /* add a float to the osc message */
      myMessage.add("some text"); /* add a string to the osc message */
      myMessage.add(new byte[] {0x00, 0x01, 0x10, 0x20}); /* add a byte blob to the osc message */
      myMessage.add(new int[] {1, 2, 3, 4}); /* add an int array to the osc message */
      /* send the message */
      oscP5.send(myMessage, myRemoteLocation);
    void keyPressed() {
      OscMessage myMessage = new OscMessage("/keyTest");
      byte[] bb=new byte[1024];
        for (int i=0; i<bb.length; i++) {
      oscP5.send(myMessage, myRemoteLocation);
    /* incoming osc message are forwarded to the oscEvent method. */
    void oscEvent(OscMessage theOscMessage) {
      /* print the address pattern and the typetag of the received OscMessage */
      print("### received an osc message.");
      print(" addrpattern: "+theOscMessage.addrPattern());
      if (theOscMessage.checkAddrPattern("/mouseTest"))  
        println(" typetag: "+theOscMessage.typetag());
        println(" **typetag: "+theOscMessage.toString());
        theOscMessage.print();  //Prints some info about the package
        theOscMessage.printData();  //Prints the data
        //OTHER ways to access the data:
        byte[] byteRx=theOscMessage.get(0).bytesValue();
        byte[] byteRx_v2=theOscMessage.get(0).blobValue(); //Same as before? 
        //If you send an array of integers, then you should be able to retrieve it like this (untested):
        int[] intRx=theOscMessage.get(0).midiValue();   
        //Check more in the documentation:
        //[])    <== Check the get() entry
  • edited November 2017

    Sending an image 480 x 640 in ARGB mode: 4 byes per pixel produces the following error.

    ### [2017/11/24 22:43:3] ERROR @ UdpClient.send ioexception while sending packet.   
    The message is larger than the maximum supported by the underlying transport: Datagram send failed

    The following post discusses about this limit:

    Notice from the next reference:

    setDatagramSize set the size of the datagrampacket byte buffer. the default size is 1536 bytes.


  • Thanks for the replies! I was able to retrieve the depth values as simple digits instead of its weird 11 bit numbers that kinect uses but it does look like its too much data too send over OSC without crashing processing.

    Anyhow, once again- Thanks anyway for the help though- much appreciated!

Sign In or Register to comment.