Aurora Visio Studio TOP » Program Examples » HMI Grab Single Image
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.
Solution (AVS)
-
Create the 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 the EnumerateImages to get images from a directory. Create a output of type Image and connect it with the outImage.
-
Add the Delay filter for simulating the camera's delay.
-
Add the Variant macrofilter StoreImage with the forking port inButtonPressed of type Bool.
-
To the variant True:
- Add the CurrentDateTime filter to create a timestamp in format YYYY_MM_DD-hh_mm_ss.
- Add the Formula to create the FilePath to location where an image will be saved.
- Add the 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 the 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 the Label control, available in the Controls category and set its Text property as Grab Single Image.
-
To allow the end-user to select a directory where an image should be saved, add the DirectoryPicker control from the 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 outValue output to the StoreImage's macrofilter forking port.
-
Add the EnumBox control available in the Controls category and set its Type property to the ImageFileFormat. Connect the outValue output with the inImageFileFormat input.
-
Add the TextBox control to enable the user to enter a prefix of FileName. Connect its outText output with the InFileNamePrefix input of the previously created formula.
マクロフィルタ メイン
Macrofilter GrabImages
Macrofilter StoreImage(True)
Macrofilter StoreImage(False)
使用したフィルタ
アイコン | 名前 | 説明 |
---|---|---|
Delay | Suspends the program workflow for inTime milliseconds. | |
SaveImage | Saves an image to a file. | |
EnumerateImages | ディスクに保存された画像を使用して画像取得をエミュレートします。 | |
CurrentDateTime | Returns a string containing the date time information in selected format and all of the date time data separately. |