loading
 
Anonymous 10 years
Matthew,

1. See set_image XML call in the API. The stream data is sent after the HTML header as raw RGB bytes.

2. Run the sobel edge in RoboRealm. (And the shape match too). Save the robofile using the save button and use the .robo extension. Load that text file into a text editor ... and there is your XML. Note that you can remove the header part of the XML string as that is optional.

So anything you want RoboRealm do to via the API can first be done using the RR GUI and then used to produce the XML file that you would send via the execute command to repeat that configuration.

STeven.
Matthew from United States  [5 posts] 10 years
Thanks STeven. Using the RR UI was something that I was trying to avoid. Is there no way to call specific method like sobel from the API?
Anonymous 10 years
Yes, there is ... we perhaps did not make our last posting as clear as it should be. Try this (bear with us till the end):

1. Run RR.
2. Insert the Sobel module
3. Save that config as c:\test.robo
4. Load that c:\test.robo into a text editor
5. Add that line

rr.Execute("<Sobel_Edge><mode>1</mode></Sobel_Edge>");

into your program within the Execute routine.
6. ** To change the parameter from your own program simply change the line to

rr.Execute("<Sobel_Edge><mode>2</mode></Sobel_Edge>");

(note the 2) in your application. If you are using C++ that would be using the sprintf function.

Thus you use the RR GUI to figure out the possible parameters of the module and then use your own application to change that parameter string as needed. When you program is running the GUI IS NOT USED in RR.

Think of the GUI as a wizard. Does that make more sense?

STeven.

Matthew from United States  [5 posts] 10 years
Sorry STeven. Makes perfect sense. I'll assume then that you MUST use the ui. I was looking to use the API in such a fashion as:

object ArrayOfInts = rr.Execute("Xml_String_For_Shape_Detection_Which_Returns_Array_Of_Coordinates");

Something like this would allow me to use RoboRealm as an actual server and not rely on the UI. It seems that most, if not all, of the methods called in the API only return bool.

I do think it is an awesome piece of software!
Anonymous 10 years
Matthew,

There was an original thought to use the api in such a fashion. For example, in your case the ideal routine would be something like

object ArrayOfInts = rr.GetHarrisPoints(arg1, arg2, arg3, arg4)

but the issue with that is that we have over 300 such routines and the documentation alone would be a huge effort. Using the XML string as a descriptor keeps the API very simple and easy to maintain and use. Yes, there is additional processing to read the XML variable string that contains the answers but that would have to happen even in the above routine internally in the API communication.

Using RR as an API wizard combines several needs into a single method and allows maintenance and extension to be very easy. For example, the latest module that controls the DC car can now be used from the API without any new routines to be added simply by using the XML string.

Most of the routines only return bool with the exception of the rr.getVariables type of routines that do return the above list. Thus to replicate the above routine you would use something like (pseudo code only)

rr.Execute "<Harris_Corners>....</Harris_Corners>"
Sting txt = rr.getVariable("HARRIS_CORNERS")
object ArrayOfInts = split(txt, ",")

Once this is operation the GUI is no longer used. Note many uses use it in this way so the API is meant to be used outside of the GUI. Currently the only issue is that the RR interface will appear and there is currently no way to 'hide' the application when running in API mode. But aside from that it acts like an image processing server.

STeven.
Matthew from United States  [5 posts] 10 years
Perfect. That is totally cool and what I was looking for. I don't mind at all having to call the getVariables (Not that I should mind, its free) I think I just have to research the details behind the getVariable.

Thanks STeven!
Matthew from United States  [5 posts] 10 years
Almost hit it STeven, however, hit a snag. Everything runs fine. But I've been failing to discover how to get the SHAPES array variable to return. Attached a screen shot of what I'm talking about from the UI. Thanks for your patience.

            // load an image from disk
            rr.loadImage(null, "E:\\RoboRealm\\SquaresCircles.jpg");

            // run a .robo program
            rr.loadProgram("E:\\RoboRealm\\Circles.robo");
            
            //Get Variable; This works fine. Verified return value.
            string sizeVariable = rr.getVariable("SHAPE_SIZE");

            //This return a count of 0
            List<String> listOfVariables = rr.getVariables("SHAPES");
Anonymous 10 years
Matthew,

I assume you are using C/C++? If so the line would be more like (note untested code .. there will be errors):

int array[8192];

// returns "x1,y1,x2,y2,x3,y3"
char *txt = rr.getVariable("SHAPES");

int last=0;
int p=0;
int i;
for (i=0;txt[i];i++)
{
  if (txt[i]==',')
  {
    if (p<8192) array[p++] = atoi(&txt[last]);
    last = i+1;
  }
}

which would leave all the points in "array" with p total points. Note that due to the use of XML all interaction comes using text. You have to convert from text to integer, float, etc. XML is nice to read but can be a little annoying when it comes to data type conversion.

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