loading
 
GetImage function in RR_COM_API.dll broken?
from United States  [214 posts]
8 years
Hi STeven,

I am having trouble getting the GetImage function to work properly in RR version 2.2.9.  I am using C# and Visual Studio 2005 and I am referencing the RR_COM_API.dll included in the RR package.  I have also run regsvr32 on the RR_COM_API.dll.  I am simply trying to get the image bytes from RoboRealm so I convert them into a Bitmap and do some analysis on the raw pixels.

RR is up and running before I execute my test C# program and the API Server box is checked and running on port 6060 with timeout 0 and number of threads 1.  The only module I am running in RoboRealm is Reception_Quality so I have a variable to test from my C# program.  I am using a Philips webcam attached to a USB port and the video displays fine in RoboRealm at 320x240 resolution.

My test program can successfully retrieve variables from RR using the GetVariable method.  However, using the GetImage method returns huge numbers for the image width and height, such as 2163008 x 2228464 instead of 320x240.

I have attached my test C# solution in case it can help you solve my problem.

Thanks!
patrick

TestRR.zip
Anonymous 8 years
Patrick,

Not sure why but for some reason that routine is treating width and height like a short (16 bits) but assigning it to an int (32 bits). Seems that something strange is going on in the C# marshaling of that COM object.

I'd recommend using the C# API routines provided in the examples download. That allows for much more direct C# integration as the API is written in C#.

If not you can use the following to *hack* around this error but ignoring the incorrect upper 16 bits by anding the result with 65535 as in

Console.WriteLine(dimension + " : " + (((int)width)&65535) + " x " + ((int)height&65535));

which produces the correct image dimension (at least in our tests).

Thanks for zipping your example ... makes it much easier to understand your error!

STeven.
from United States  [214 posts] 8 years
Hi STeven,

Many thanks for the hack.  The reason I was trying out the COM version of the API was because I was having some difficulty using the C# version of the API.  As I posted a while back, I was occasionally and randomly getting black lines at the top of my bitmaps when using the C# getImage function.  However, I just now downloaded the latest API zip from your website and there have been some changes since I last downloaded it.  In particular, the waitImage() method now takes a timeout argument which my old version does not.  The good news is that by setting the timeout value to 1, my "black lines problem" has disappeared!  So I will go back to using the C# API and I think I am good to go.

--patrick

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