07-14-2010 04:09 PM
I think my request is fairly simple.
I would like to be able to overlay arbitrary polygons onto an image in a manner similar to the other IMAQ images.
Is there a simple and efficient way to do this?
Specifically, I would like to be able to overlay triangles (to make arrows).
I can envisage how to do this using a combination of ROI descriptors and masks, but I was wondering if there already exists a simple and elegant solution, whether in LabVIEW or open source.
Solved! Go to Solution.
07-14-2010 08:00 PM
It is pretty easy to draw straight lines in an overlay using "IMAQ Overlay Line" or "IMAQ Overlay Multiple Lines". I don't think it would be too difficult to write a quick routine that would draw all the lines necessary for an arrow. You could make it really simple (alway same direction, specify tip location) or fairly complex (angle, length/size, tip location).
Bruce
07-14-2010 11:11 PM
Thanks Bruce.
I sort of need filled arrows, so the straight line approach is not the best - I already tried it and it didn't look too great for this application. Also, I will have potentially many hundred of arrows on my display (at arbitrary angles), so the method for painting them onto the image needs to be as efficient as possible.
I am a little bit surprised that the need to draw a triangle on an image has not come up before. To me it seems like the kind of thing people might want to do.
07-15-2010 05:46 AM
If you know the end points, you can overlay triangle using overlay multiple lines
07-15-2010 08:33 AM
Did you try using "Filled" instead of "Frame" with Overlay Multiple Lines? It looks like it will fill in the polygon for you. I wrote the rest of this post before noticing that option. It sounds like exactly what you need - draw the triangle filled, then draw a line separately to complete the arrow.
If you want the same solid object over and over again, the Overlay Bitmap is probably your best choice. You have to create a bitmap of what you want to draw in a rectangular array (transparent color works great where you don't want to draw anything). You also need to subtract an offset from the coordinates if the tip of the arrow isn't at 0,0 in your bitmap.
I use this frequently to draw thick crosshairs and other objects on an image and it works great.
If you want them at different angles, it gets a little more difficult. You could have several prerotated bitmaps generated (every 45 degrees, for example), but there isn't any way to do an arbitrary angle with the bitmap.
One idea, completely untested, would be to use Overlay Arc to make a pointy arrow head. The backside of the arrowhead would be rounded, but probably not too bad. You could specify the start and end angles based on the rotation of the arrow, and specify fill to make it solid. Draw a line from the tip back, and you have a nice arrow.
Bruce
07-15-2010 11:52 AM
Attached small VI (originally from NI).
Hopefully it will be helpful for you, at least as starting point
Andrey.
07-15-2010 11:55 AM
That looks ideal. Do you have the VI available for version 8.6?
Thanks,
-Graham
07-15-2010 12:03 PM
@Caleyjag wrote:
That looks ideal. Do you have the VI available for version 8.6?
Thanks,
-Graham
Downsaved for 8.6.1
07-15-2010 01:38 PM
Thanks,
This will do the job nicely.
Bruce was on the right track with the filling a shape drawn with Overlay Multipple Lines. This VI adds the math for calculating the shift of the trangle vertices as the angle of the line evolves. Perfect.
Something like this should be included in the full Vision package!
-Graham
07-16-2010 12:31 AM
@Caleyjag wrote:
Thanks,
Something like this should be included in the full Vision package!
-Graham
Vision Development Module offer the basic primitives only. Line with arrows, as well as different marks, etc - there are relative "high level" blocks, which can be constrained from low level primitives. Every user will need something special, and there are no way to do fully universal library which will meet all possible requirements.
But you're right in general - I also miss line with arrow in standard package...
Andrey.