HMI Grab Single Image
The task is to create simple application for grabbing and saving images from a camera.
For training purpose it is not needed to have a camera connected to PC. Instead of this, you can load images from a disk directory.
Create Step macrofilter GrabImage. This macrofilter simulates the operation of filters for acquiring images from cameras. If you have a connected camera compliant with any supported standard, add the appropriate filter from the Image Acquisition category and go to step 4.
Add a Delay filter for simulating the camera's delay.
Add Variant macrofilter StoreImage with forking port inButtonPressed of type Bool.
To the variant True:
- Add CurrentDateTime filter to create a timestamp in format YYYY_MM_DD-hh_mm_ss.
- Add Formula to create FilePath to location where an image will be saved.
- Add Formula's input inDateAndTime of type String and connect it with the outDateTimeString. Then add another inputs of type String inDirectory and inFileNamePrefix. These inputs will be connected to specific HMI controls, since user has to be able to set a destination directory and a name prefix of file.
- Add SaveImage filter to save an image to a file.
The next step is to create HMI using HMI Designer available in the toolbar.
At the top of your HMI put Label control, available in Controls category and set its Text property as "Grab Single Image".
To allow end-user to select a directory where an image should be saved, add DirectoryPicker control from File System category. Connect its output outDirectory with the formula's input of the same name.
To display the loaded image, add VideoBox control from Video Box category and connect its input with the output of GrabImage macrofilter.
The task of this application is to grab and save an image in certain time, not in every iteration. Therefore ImpulseButton available in the Controls category can be used as a trigger. Connect its output outValue to the StoreImage's macrofilter forking port.
Add TextBox control to enable the user to enter a prefix of FileName. Connect its output outText with the input InFileNamePrefix of the previously created formula.
|Delay||Suspends the program workflow for inTime milliseconds.|
|EnumerateImages||Emulates image acquisition with images stored on disk.|
|SaveImage||Saves an image to a file.|
|CurrentDateTime||Returns a string containing the date time information in selected format and all of the date time data separately.|