loading
 
About API + C++
Jafni from Malaysia  [29 posts]
8 years
For the time been, i have success to show live video at GUI through Roborealm and detect several unique pattern that i have already save that pattern in the roborealm. My problem is how can i get the name of the pattern that i already save in the roborealm so that i can display it in GUI since i have several pattern so i could differentiate it by its name.

Example: I save a triangle (with the name of triangle) in roborealm and it can detect the triangle and show it on the GUI. But how can i get the name of the "triangle" and show it on the GUI. Hope you could give me some of the source code.

Please Help me. Thanks
Anonymous 8 years
Jafni,

I assume you are using the Shape_Match module? If so have a look at the variable SHAPE_FILENAME

documented in

http://www.roborealm.com/help/Shape_Match.php

which will contain the name of the template file matched to an object in the image. Assuming you name the filename something you can understand you can then act on that.

Assuming just one shape is being found using the VBScript module and the following will create a single variable with the matched filename in it.

shapes = GetArrayVariable("SHAPES")
names = GetStrVariable("SHAPES_PATH")

if isArray(shapes) then
  if ubound(shapes) > 0 then

    nstart = shapes(7)
    nend = shapes(8)
    SetVariable "Matched_Filename", mid(names, nstart, nend)

  end if
end if

which will create a Matched_Filename variable for the one and only shaped matched. For multiple shapes see this type of code in the documentation for the shape_matching module.

STeven.
Jafni from Malaysia  [29 posts] 8 years
I had try to put VBScript in my Roborealm module, it work fine but how I want to display this character in C++ when it detect object? Can you show it to me? I really need help..
Anonymous 8 years
Jafni,

Use

RR_API rr;

rr.open("c:\\RoboRealm\\RoboRealm.exe", 6060);

if (!rr.connect("localhost", 6060))
{
    printf("RoboRealm does not appear to be running.\nPlease run RoboRealm and try again.");
    exit(0);
}

char buffer[64];
rr.getVariable("Matched_Filename", buffer, 64);

rr.disconnect();

in your C++ program and that should do it. Note that the variable will then be in the buffer char array. Also note that if you wish to query for this variable multiple times you need not open and disconnect on each request ... you can just use the getVariable inside a loop if needed.

Be sure you include the RR_API.cpp with your C++ program. See the main.cpp inside the API download for a complete example.

http://www.roborealm.com/downloads/API.zip

STeven.
Jafni from Malaysia  [29 posts] 8 years
STeven,

Can i use static text in C++ to mentioned user when i differentiate shape? I had try to put printf but it doesn't appear anything, then i use message box with kill timer it work but have to press ok and get image all the time. Now i think i want to use static text, but i don't know how? Or you can suggest me to use other than static text? I'm actually a new guy in C++.. Can you show it to me? Please help me..
Jafni from Malaysia  [29 posts] 8 years
Example, if that camera detect "1.jpg", then static text will show "1.jpg" and if that camera detect "2.jpg", it will show "2.jpg" in C++....
pranavtrehun007 from United Kingdom  [33 posts] 8 years
what you get from Roborealm's API is a string. so all you have to do is to printf the string. its been quiet some time since i used C++ ( i now use C#), the following code may show you about handling strings in C++.

http://www.sourcecodesworld.com/source/show.asp?ScriptID=1157

Anonymous 8 years
Jafni,

Are you using a window GUI based program or a DOS based program? Sounds like a GUI from your previous message. If so add a static text area to you GUI application and use an id that you will remember. It will default to IDC_STATIC so change it to IDC_NAME and then right where you had the message box place the line

GetDlgItem(IDC_NAME)->SetWindowText(name);

where "name" is what you've gotten from RR and had printed using printf.

Note that this is very basic windows GUI work and you can find a lot more information about how to do these types of things from other sites. But hopefully this is enough to point you in the right direction.

STeven.
Jafni from Malaysia  [29 posts] 8 years
Thank's a lot... I think now I know how to make it.. For now on my project are 70% done.. Thank you very much..

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