Using Automation in Visual Basic  
Top  Previous  Next

This section shows how to get started with ImageWarp automation in Visual Basic. With just a few mouse clicks and a few lines of code, you will be able to display a live video image in ImageWarp and report the average luminance of each frame in your VB application in real time.

Creating the Project

Begin by selecting the New Project command from the file menu, and select Standard EXE as your project type. Then use the Project / References... command and select ImageWarp 1.0 type library from the list.

Creating ImageWarp object

Create ImageWarp application object by adding the following code to the Form source:

Dim WithEvents iw As ImageWarp

Private Sub Form_Load()
Set iw = New ImageWarp
End Sub

Private Sub Form_Unload()
iw.Stop
Set iw = Nothing
End Sub


Using ImageWarp object

Click the button icon on the toolbox and draw a small rectangular area on the form. A button Command1 will appear on the form. Double-click on the button and add the following code:

Private Sub Command1_Click()
iw.Show
iw.Call ("do \n grabim(1) \n measHistogram(1,CH_LUM,HS_STAT) \n pause(CUR_THREAD) \n loop")
End Sub


This will instruct ImageWarp to perform image acquisition and collect the histogram statistics.


Using Suspended event

Click the label icon on the toolbox and draw a small rectangular area on the form. A label Label 1 will appear on the form. From the list of objects on the top of the source window select iw, and then select Suspended from the event list. An empty subroutine iw_Suspended will appear in the source. Add the following code to it:

Private Sub iw_Suspended (ByVal index As Long)
iw.Run
label1.Caption=iw.GetParam("Histogram", 0)
End Sub



Running the application

You are now ready to hit F5 and watch ImageWarp display a live video while your program reports the average luminance of each frame in real time.