loading
 
sending Surveyor SRV-1 image to RoboRealm
Dan from United States  [3 posts]
14 year
we have an SRV-1 application that we'd like to use RoboRealm for the vision processing for.  So I need to take the image that I'm capturing from the SRV-1 and send it to RoboRealm -- how do I do this?  Near as I can tell, I need to convert it to a pixel array for RoboRealm.  Is there a pixel array type that RoboRealm accepts that the java.awt.image.* code can generate?  Clearly, RoboRealm has solved this problem because they have the SRV-1 supported in their app.  Just looking for a code snippet.  Thanks.
Anonymous 14 year
Hi Dan,

  Have you read the Fun with Surveyor Tutorial ?

  http://www.roborealm.com/tutorial/Fun_with_Surveyor/slide010.php
Dan from United States  [3 posts] 14 year
I've seen this page.  This uses the Surveyor interface built by RoboRealm.  I want to interface to my own app.  So what I really want is how they sent the image over to RoboRealm.  I actually tried it -- converted the java Image I had via PixelGrabber to an RGB  byte array and then sent that byte array via the API "send image" command to RoboRealm -- no image is displayed in RoboRealm.  I extended the RR_API.java file send_image command to do this.  The send_image status is true -- as in it received an "ok" response as opposed to a timeout.
Dan from United States  [3 posts] 14 year
got this working.  Used PixelGrabber object to extract the pixels from an Image.  Then extracted the RGB components and put them into a byte array.  Ignored the alpha component.  finally extended the setImage routine in RR_API to do this extraction and send the byte array to RoboRealm.  I had a couple bugs in my conversion to the byte array which is why this didn't work at first.
Anonymous 14 year
Dan,

Thanks for the followup. Perhaps if you can include a small snippet of the code here using the PixelGrabber class we can verify that its the way to go and include that example in the Java API file for others to use.

Our version is something like this (untested)

  public static void sendImage(RR_API rr, Image img)
  {
    int width = img.getWidth(null);
    int height = img.getHeight(null);

    // create your own copy of the data in case the parent goes away ...
    int pixelInt[] = new int[width*height];
    byte pixelByte[] = new byte[width*height*3];

    // Get the image data
    PixelGrabber grabber = new PixelGrabber(img, 0, 0, width, height, pixelInt, 0, width);

    try
    {
      grabber.grabPixels();

      int i,j;

      for (j=i=0;i<width*height;)
      {
        int num = pixelInt[i++];
        pixelByte[j++] = (byte)(num&255);
        pixelByte[j++] = (byte)((num>>8)&255);
        pixelByte[j++] = (byte)((num>>16)&255);
      }

      // send image to RR
      rr.setImage(pixelByte, width, height);
    }
    catch (Exception e)
    {
    };
  }

Does that meet with your version?

Thanks,
STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index