Image and AVI Capture This programming example (VB.NET) shows how to capture AVI files and JPEG images using IC Imaging Control simultaneously.
This problem is solved using a special frame filter that saves images to JPEG files. The frame filter is included in the sample's setup file. Following functionallity is implemented in the sample:
Most of the listed tasks are explained in the other samples of the code library. Thus only the use of the "Save Image" frame filter will be explained. First of all a variable of type TIS.Imaging.FrameFilter is to be declared on top of the form. This variable is named SnapImageFilter and will be used for accessing the frame filter for image saving. VB.NET Dim SnapImageFilter As TIS.Imaging.FrameFilter The "Save Image" filter will be loaded in the Form1_load sub. After it has been tried to load the filter, the content of SnapImageFilter is checked whether it is Nothing. If SnapImageFilter is Nothing, the filter has not been loaded. This happens, if the filter file SaveImageFrameFilter.FTF is not located in the application's path. The frame filter is added to the solution. Its action property is set tp "Copy if newer", so the frame filter is copied to the application. If the SnapImageFilter has been loaded successfully, it is inserted into the device path of IC Imaging Control. VB.NET SnapImageFilter = IcImagingControl1.FrameFilterCreate("Save Image", "") If SnapImageFilter Is Nothing Then MessageBox.Show("Failed to load the Snap Image filter", "Filter Loading", MessageBoxButtons.OK, MessageBoxIcon.Warning) Else IcImagingControl1.DeviceFrameFilters.Add(SnapImageFilter) End If The images should be saved using a button on the application's form. Thus a button handler is to be inserted into the source code. There are some checks performed in the button handler btnSnapImage_Click before the image is saved:
The parameter "ImageName" of the SnapImageFilter must be set to a valid file name. This causes the SnapImageFilter to save an image. Since this is a parameter transfer between the application's thread and the IC Imaging Control video thread, this must be set into BeginParameterTransfer and EndParameterTransfer calls. The SnapImageFilter will capture the next incoming image after the parameter "ImageName" has been set. VB.NET Private Sub btnSnapImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSnapImage.Click With IcImagingControl1 If .DeviceValid = True Then If .LiveVideoRunning = True Then If Not SnapImageFilter Is Nothing Then ImageCounter = ImageCounter + 1 Dim ImageFileName As String ImageFileName = String.Format("Image{0}.jpg", ImageCounter) SnapImageFilter.BeginParameterTransfer() ' Passing the image name to the SnapImageFilter will snap the image SnapImageFilter.SetStringParameter("ImageName", ImageFileName) SnapImageFilter.EndParameterTransfer() End If End If End If End With End Sub |