loading
 
Getimage & Annotation
Michel van de Vorst from Netherlands  [5 posts]
7 years
I am using the API, VB.NET and the Getimage command to obtain the result of the RR processing. I have to process a single image several times, so I use display as annotation to show all the results in the final picture.

If I save the image, the annotations are saved with it. If I use GetImage, no annotations are send with it. Saving and loading an image is very slow and I try to avoid this.

How can I get an image with the annotations using a GetImage command? Because there are multiple steps involved it is insufficient to uncheck the 'display as annotation' checkbox to solve this problem




Anonymous 7 years
Michel,

First be sure that you are specifying "processed" as the image name in the call to GetImage. If you don't supply any name it should default to "processed" but just in case.

Second, are you using something like

rr.waitImage

just before you get the image back? Is this an image coming from the webcam or are you sending it via the API?

The API should get the image WITH the displayed graphics ... this was just verified using the C++ API.

STeven.
Michel van de Vorst from Netherlands  [5 posts] 7 years
Steven,

Thanks for your swift reply

Now I am using a marker on the end of the rr-program named "final". I use a waitvariable to see if the rr-program is finished. Afterwards a getimage is processed. The startimage is loaded in RR using the VB.net API. The camera involved is not supported by RR, but using the API I can load images in RR.

The procedure has the next steps

All Pixels, PixelsIn arrays are byte arrays. The correct type is very important because of the exchange between pointers and variables

The camera image memory is received by a pointer (Imagepntr)

Marshal.copy is used to copy this in a array (PixelsIn)

Marshal.copy(Imageptr, PixelsIn, 0, Pixelssize-1)

Because pixelsIn is grey level, the pixelsIn is copied to a 3x larger array to add two additional bytes per pixels.
Afterwards, setimage is used.

rr.setimage("source", pixels, width, height)

As long as the pixels array size is less or equal to 960 * 1280 - 1 elements it works, otherwise a black screen is the result.

The RR program contains the next lines

At start:
Set DONE=0

At end
marker[final]
Set DONE=1


The VB.net program

rr.run("on")
Dim test as boolean =rr.waitvariable("DONE",1,5000)

The variable test is checked if processing was succesfull

If succesfull, getimage is used to collect the image, and a special get_RR data subroutine to get the other data.

The complete getimage command is

rr.getimage("final",pixels, width, height)

The pixels array is changed to a bitmap by
1. Exchanging the R and B in the pixels array in a loop
2. Copying the pixels array to a pointer using

Marshal.copy(pixels, 0, pnt, pixels.length)

3. Create a bitmap using:

Dim bm as new Bitmap(width , height , 3*width, Imaging.pixelformat.format24bppRgb, pnt)

4. show the bitmap in the picturebox

Picturebox1.image=bm
Picturebox1.refresh()  

And I end with a bitmap without any annotations.

I will try the getimage with "processed" instead of "final", and see if this changes the result. I let you know by tomorrow.

Concerning rr.waitimage, there is no example in the VB.net API for waitimage, so I avoided it by checking a variable.

Michel van de Vorst from Netherlands  [5 posts] 7 years
Hi Steven,

Today I tried the "processed" and empty getimage commands, and now I do get the annotations.

Thank you very much!
Anonymous 7 years
Michel,

Thanks for the update. Glad that it worked out for you.

One thing you may also try is to set the "Include Overlay Graphics in Marker" checkbox in the marker module which should give you back the graphics when requesting a marked image. This saves you from going to all the different modules and selecting that option. Plus it also prevents the graphics from messing up with successive processing.

In terms of examples using the waitImage something like

rr.run("on")

rr.setimage("source", pixels, width, height)
rr.waitImage()

should do the trick .. but using the vars will work too.

In your case I would probably do a

rr.setVariable("DONE", 0)

from the API before using the setImage to ensure that you accidentally don't get back an image while the pipeline is inbetween the DONE=1 at the end and DONE=0 at the start. It is ulikely but still possible that your code would setImage just after the DONE=1 and then get back the results before the DONE=0 is reached. Setting via the API will ensure that this race condition does not happen.

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