Socket Program Plugin

Please be sure to read the Overview page to get a general sense of if the Socket RoboRealm Extension is a good fit for you.

To create your own socket program to extend RoboRealm download our example socket programs. This example program (SwapColors) will swap the Red and Blue pixel colors in an effort to show how image modifications can be performed. Note that the download also includes the Pipe and DLL example implementations. The example socket program is in the single source file called main.cpp.

There are both C++ and Java based examples for the socket extension. You will need VC++ or other C++ compiler to build the C++ based program and any generic Javac compiler to compile the Java based extension.

Note that there are pre-built executables in each of the examples. If you run these programs (either C++ or Java) you should see a black command dialog with the words 'Running' being displayed. The program is now waiting for a connection from the RoboRealm program on port 5050. Note that if you have any firewall software installed that prevents communication on port 5050 either allow that port or change the port number in the appropriate source file and within the RoboRealm socket module.

To configure RoboRealm to use a socket based program click on the Extensions->Socket_Program module. This module is a CLIENT and thus expects to connect to a network server application.



Server Hostname - This is the computer name or IP address that will play host to the image processing server that you create. This machine needs to be accessible on your network. Localhost - your current computer - is the default. Running your socket server on remote machines will require adequate bandwidth as a single image within RoboRealm is typically 320x240x3 (or larger) in size. Images are NOT compressed in any way when sent across the network.

Server Port - The port number to use when connecting to the host specified above. Please be sure that your Firewall or security proxies allow for that port to be communicated on AND that the TCP protocol is allowed.

Available Variables - Shows you the current RoboRealm variables that other modules have created. Note that the variables are NOT reset during each image call and thus can be used to save information from past images.

Returned Variables - Shows the variables that your socket program has returned which were added to the RoboRealm variables.

Messages - Any system error messages. If your socket program passes back the 'error' variable the contents are displayed in this text box.

Connect - Causes RoboRealm to connect to the specified hostname using the specified port. Use this to test your connection.

While the examples we provide are in C++ using Windows Visual C++ Ver. 6.0 and Java JDK2.1 you are not required to use these platforms in order to extend RoboRealm. By following the same protocol you can write your extensions in other languages like C#, Perl, etc.

The data format used to pass the image and associated variables to both pipe and socket based programs is based on the a name value pair. The following is and example of the data stream:

5 width 4 320 6 height 4 240 5 image 6 230400 xxxxx ... 0

The pair format is

length of name | name | length of value | value | next length or 0 to end

and continues until a 0 or -1 is encountered. 0 means end of the current image step while -1 means end of program.

Note that all variable values are sent as text strings with the exception of width and height which are stored as a four byte number and the actual image which is composed on unsigned BGR pixel triplets.

Things to remember:

  • If the socket program fails RoboRealm will pause processing and then continue slowly while trying to reconnect each time. Unlike Pipe programs RoboRealm cannot restart the server (we assume the server may not even be on the same machine). Thus you will need to ensure standard monitoring practices to ensure that the system remains stable.
  • RoboRealm only processes images when needed! If you are processing a single static image RoboRealm will call your socket module only when refreshing part of the window. So if you are not using a live camera feed you will have to move the RoboRealm window or hide/show that window to ensure that RoboRealm will call your program.

 New Post 

Socket_Program Related Forum PostsLast postPostsViews