11-19-2015 04:41 PM
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?
Solved! Go to Solution.
11-19-2015 05:33 PM
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
11-30-2015 08:52 AM
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!