Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

VisionImage WriteVisionFile with overlay - .NET

Solved!
Go to solution

I am using the VBAI API for .NET to run projects created in Vision Builder 2014.  My VBAI project applies an overlay (red rectangle, black text) near the end of the inspection.  I then do

 

VisionImage image = engine.GetInspectionImage("", 1, 1, out NewImageAvailable) and attach the resulting VisionImage object to an NI Image Viewer (straight from the .NET API Example).  The viewer was able to show the image and the overlay that was applied.  However, when I call

 

image.WriteVisionFile("C:\\test.png"), the resulting PNG file is still missing the overlay and contains only the captured image.  What is the missing step to get the WriteVisionFile to output a PNG with the overlay?

Message 1 of 3
(4,029 Views)
Solution
Accepted by tetraq

How are you opening the file to verify that the overlay is not there? If you just open the PNG file with a 3rd party image viewer, you're not going to see the overlay. The overlay in Vision Development Module is non destructive overlay that is attached as extra information to the png image saved.

The png saved contains the overlay. If you open the resulting png saved with WriteVisionFile using the ReadVisionFile function, it will read the overlay saved in the png file and display it when you display the image in the image viewer.

 

If you want the overlay to be seen in the resulting image saved on disk, you need to first merge the overlay information to the image.

You can do that using the Merge function: image.Overlays.Default.Merge()

Note that when you do that, the underlying data will be lost and replaced by the overlay color.

Once the overlay is merged, you can save it using any of the Write functions.

 

Hope this helps,

 

Best regards,

 

-Christophe

 

Message 2 of 3
(4,020 Views)

Christophe,

 

The Merge function was the step that I was missing.  The PNG is displayed after all the analysis is complete, so it is ok that the underlying data gets lost at this point.  Thanks again!

0 Kudos
Message 3 of 3
(3,926 Views)