FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How to annotate images using imaq calls?

We're doing Vision recognition using NI Vision and the imaq APIs. The Vision recognition part is working pretty well (although I do have some questions about particle measurements -- but I might ask those in a separate post).

But we'd like to make up the image before sending it to the Driver Station to, for example, highlight the target we've identified put a line in the center of the image so the driver can manually line up the shot, etc., and we're having a great deal of trouble with that.

The imaqOverlay family of calls seems obvious for this, but none of our annotations are displayed on the image that we send to the Driver Station. We're using a slightly modified version of the WPILib CameraServer classes, that sends each image using the SetImage call (which seems to more or less do a network write of the raw image data with "kMagicNumber" in front of each image).

So we figured that the overlay needed to be merged with the image before sending, so we tried:

    

imaqMergeOverlay(image, image, NULL, 0, NULL);

but that still didn't show the overlays (bear in mind that we're sending a full RGB image, not a U8).

So next we tried the imaqDraw family, as in:

    

     imaqDrawLineOnImage(image, image, IMAQ_DRAW_VALUE, start, end, 1.0);

This does annotate the image -- but only in black, and without any transparency. The last argument "newPixelValue" (set to 1.0 in the above example), is a float -- and the scant documentation implies it's gray scale only, but doesn't mention the range. We tried numbers greater than 1.0, and those showed nothing, so I'm now guessing that it's a float gray scale valuee between 0.0 and 1.0 -- with 1.0 giving us the pure black.

We'd really like to be able to use colors -- green (for target lock), red (no target lock), yellow (for center line, etc.) -- ideally with some transparency control. Is there any way to do that?



0 Kudos
Message 1 of 4
(4,527 Views)

Bump. There's no one from NI who can answer this?

0 Kudos
Message 2 of 4
(3,867 Views)

Hello cbf,

I understand you are trying to overlay color lines onto an image acquired from your camera. You can find documentation for using NI Vision functions in C within the NIVisionCSupport.chm file at this disk location: C:\Program Files (x86)\National Instruments\Vision\Help

That document contains a lot of information but I encourage you to look at functions like imaqOverlayLine, imaqOverlayArc, imaqOverlayPoints, etc. These functions all allow you to specify color for the shape you are overlaying on the image. Please note, as stated in the documentation, that these functions do not support the alpha color channel so you are unable to achieve transparency.

Hopefully you find this documentation and these functions useful for your strategy.

0 Kudos
Message 3 of 4
(3,867 Views)

That's exactly what we tried. This call:


imaqOverlayOval(image, {top, left, rectheight, rectwidth}, pColor, IMAQ_DRAW_VALUE, NULL);

(where pColor points to something like IMAQ_INIT_RGB_YELLOW) drew nothing at all on the image -- even when we tried the MergeOverlay call.

This call:

imaqDrawShapeOnImage(image, image top, left, rectheight, rectwidth}, IMAQ_DRAW_VALUE, IMAQ_SHAPE_OVAL, 1.0);

drew the oval we wanted, but we could only get it in black. The documentation says the last parameter (which has the value of 1.0 in the above example) is:

newPixelValue  float  If you set mode to IMAQ_DRAW_VALUE or IMAQ_PAINT_VALUE, newPixelValue sets the pixel value that the function uses to draw a shape

but I can find no information of what values result in what display colors. We've tried many values and we get either black or nothing. Unfortunately, since this is a float, the possible range of values is enormous, so it's hard to crack this by trial and error.

If we could get the Overlay calls to show something, at least those take an RGBValue for the color and we'd know how to get our colors (it would be even better if the Alpha channel worked).

0 Kudos
Message 4 of 4
(3,867 Views)