loading
 
API Image display in VB.Net
Gary  [5 posts]
15 year
Hello,

I am trying to connect a VB.net applicataion to RR through API. I can get the variables passed fine but I am having trouble displaying the processed image in a picturebox in the VB.Net application. I downloaded the example files and it seems to lockup on the GetImage call. Is that even the way to do it? I tried writing an image in the .robo file and then reading that image from VB.Net app, that seems to work ok if you don't want the image to continuously update at a reasonable frame rate.

I found another example in the C++ examples about displaying a Bitmap in a picturebox, but I'm not a C++ guy and can't really see what's happening.

Is there an example of how to get the currently processed image to continuously display in a VB.Net picturebox?

Thanks,
Gary
Anonymous 15 year
Hi Gary,

   Take a look at the following post it was done in C# but it should be easy enough to convert it to VB.Net (http://www.roborealm.com/forum/index.php?thread_id=2928#2) You should be able to use a C# to VB.Net converter (http://www.dotnetspider.com/convert/CSharp-To-Vb.aspx). Please post you code if your having difficulties converting it.

Nomis
Gary  [5 posts] 15 year
Hello Norris,

Thanks for the link. I think I'm one step before the part where I need to convert the bitmap from RGB to BGR. I'm not sure how to get the image. I've tried using:

  Dim pixels(230400) As Byte
  Dim width, height As Integer

        rr.GetDimension(width, heigt)

        rr.GetImage(" ", pixels, width, height)

        rr.Saveppm("C:\test\TestImage3.PPM", pixels, width, height)
      
      
But The file that gets saved has no data, or the program just stops. Any Ideas?

Thanks,
Gary

Anonymous 15 year
Ok just checking the basics did you start RR and have the "Active RoboRealm Server" checked under the API tab and did you add a reference to the com object; see attached image syou should see RR_COM_APILib in your reference folder.

Nomis

Gary  [5 posts] 15 year
Thanks Norris,
I did have the rr server turned on and I have registered the RR_COM_API.dll file. I had not added a reference to the rr_com_api.dll, but now I have. On the demo file I downloaded there is a little different declaration of the rr api.
When I run the program with the

rr = CreateObject("RoboRealm.API.1")

declaration the image width and height variables are correct and I can pass variables fine, the GetImage line seems to get something, then the savePPM line saves a file, but the file is empty.

When I run the program with the

Dim rr As New RR_COM_APILib.API_Wrapper

declaration the width and height variables are not correct and the program locks up on the getImage line.


Are these two declarations trying to do the same thing? Is saving the file as a .ppm and getting an empty file a symptom of a GetImage problem?

Thanks for any help,
Gary

Justin Ratliff from United States  [3 posts] 15 year
Gary,

I encounted some of the same problems as you with getting an image update from RoboRealm to my vb.net application.  So I decided to cheat and instead of using a picture box, I used a WebBrowser object from vb.net and and set RoboRealm to transmit it to a webpage that I could call up in VB.  

It's not as pretty as a picturebox solutution (I'd still like to see that work) but it transmits video nicely to your app.


First you need to add a WebBrowser object to your app and name it: webRoboRealm


Then create a new class in your project named: WebBrowserControls

This is the code for the class:

Public Class WebBrowserControls

    Private _NavigateUrl As String

    Public Property NavigateURL() As String
        Get
            Return _NavigateURL
        End Get
        Set(ByVal value As String)
            Me._NavigateUrl = value

        End Set
    End Property

End Class


This is the code I used in my app for the web browser object:

        Dim wbControls As New WebBrowserControls
        wbControls.NavigateURL = "http://localhost:8080/index.html"
        Me.webRoboRealm.Navigate(wbControls.NavigateURL)


Make sure robotrealm is set to transmit to that webpage by going to Options (in RoboRealm) click the webserver tab and make sure Active RoboRealm web server is checked.

-Justin Ratliff
www.trcy.org
Anonymous 15 year
Thanks Justin,

That's a clever idea. It seems to work pretty good. It seems like a little slower frame update rate than the RR application itself, but workable.

Thanks for the idea Justin, I think I'll go with it!

Gary

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