Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware Triggers in VB - Grab locks screen

I'm trying to acquire images from an AVT camera using hardware triggering. The trigger works fine in MAX but in a Visual Basic program I wrote using IMAQdx it locks up the screen until the hardware trigger is triggered and it is also not very consistent in grapping every image. Here's a snip of the code I'm using:

 

----------------------------------------------------------------

 

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Static inTimer As Boolean = False
        If inTimer Then Exit Sub
        inTimer = True
        errorCode = CWIMAQdx.Grab(sid, myImage, True, bufferNumActual)
        If errorCode = [Error].Success And TriggerMode = TriggerModes.PhotoEye Then RaiseEvent PictureAquired(bufferNumActual)
        inTimer = False
    End Sub

 

----------------------------------------------------------------

I have experimented with the timer1.interval loop and the camera timeout and still can't get it to work right.Also couldn't find any examples for grapping with a hardware trigger for Visual Basic so that would be helpfull too.

 

Thanks,

John

 

 

0 Kudos
Message 1 of 2
(2,930 Views)

Hi John,

 

It looks like you are running that code from a timer callback. This runs in the UI thread. If you then do a blocking call (Grab) from the UI thread it blocks the UI from updating. Since I don't think VB6 (if that is what you are using) supports threads, one option would be to query the latest frame done first and only do a Grab if the frame has been acquired. I don't think the old VB6 interface supported events (the new VB .NET one does).


Eric

0 Kudos
Message 2 of 2
(2,922 Views)