PDA

View Full Version : MemorySnapTimeout



shahaf
July 2, 2006, 08:47:13
Hi.
I need to snap images at request.
(the time between frames is important for me so im not using the imageavailable event.)
i'v set the display mode to false.
and the MemorySnapTimeout to -1.
however when i call MemeorySnaImage i sometime get the error msg:

"the timeout passed to snapImages(...) did elaps before all images could be snaped"

can u help me
thanks
shahaf.

Stefan Geissler
July 3, 2006, 15:03:25
Hello,

Even if MemorySnapTimeout has been set to -1, it is possible, that a timeout occurs. This happens, if LiveStart has not been called previously. To avoid a debug exception, an error handler should be implemented. The following code sample is for Visual Basic 6.

The following function implements the MemorySnapImage and an error handler. It returns true, if an image could be snapped and false, if some error has occurred:


Private Function SnapImage() As Boolean
On Error GoTo snaperror
ICImagingControl1.MemorySnapImage
SnapImage = True
Exit Function
snaperror:
SnapImage = False
End Function

This function should be called in a little frame work, that reacts on errors:


Private Sub TryToSnapAnImage()
Dim Tries As Integer

Tries = 0
While SnapImage() = False And Tries < 3
Tries = Tries + 1
Debug.Print "Snap Images failed", Tries
Wend

If Tries >= 3 Then
MsgBox "I was not able to snap an Image."
End If
End Sub


It uses an integer variable "Tries" to count the tries of snapping an image. In the "While" loop the "SnapImage" function is called the the result is to be evaluated. If it is false, the number of tries is incremented and "SnapImage" is called again. If 3 tries failed, a message box is displayed and your program should handle this problem, e.g. restart the camera by a call to LiveStop and LiveStart.
The timeout problem can be reduced, if LiveStart has been called previously somewhere in the program.

shahaf
July 13, 2006, 10:19:52
HI,
thanks for the reply.
however,
LiveStart has been called previously
LiveDisplay was set to false
and the ring buffer is 2

and i still got the timeout error

Stefan Geissler
July 13, 2006, 13:08:50
Hi,

In this case, i suggest to call LiveStop and LiveStart in the error handler


While SnapImage() = False And Tries < 3
Tries = Tries + 1
Debug.Print "Snap Images failed", Tries
ICImagingControl1.LiveStop
ICImagingControl1.LiveStart
Wend

This costs some time but i guess this avoid the timeout error.