View Full Version : How to speed up the snapshot ?

July 3, 2006, 14:11:10
Hi everybody !

I have to set up a VB6 exe in order to take photos of an object. The camera (a Sony SX910) is moving above the object .

First, I have to say that i'm a neewbie in VB6 :)

The goal is to take photos at a high resolution (Y800 1280*960) and at a high rate ( max 1s between each shot, 0.5s would be nice ). I use the trigger input and do a memorysaveimage in the imageavaillable function but it takes up to 5 seconds to save the image to the hard disc.

How to speed this up ? ( I just want to save the current image, I don't have any filter to apply )

Thanks in advance.

Stefan Geissler
July 3, 2006, 15:59:42

Could you post some of your code, so I can see, how you start the camera?

Thank you.

July 3, 2006, 16:45:27
Here is what I do:

Sub Main()
Dim Args As String
Dim photoMax As Integer
Dim arguments() As String
Dim trigger As Boolean

'Lecture des arguments
Args = Command()
arguments = Split(Args, ",")

'Arguments: Brightness,Contrast & Exposure
If (IsNumeric(arguments(0)) = False) Then arguments(0) = 0
If (IsNumeric(arguments(1)) = False) Then arguments(1) = 0
If (IsNumeric(arguments(2)) = False) Then arguments(2) = 384
If (IsNumeric(arguments(3)) = False) Then arguments(3) = -16
If (CInt(arguments(1)) < 0) Then
arguments(1) = 0
ElseIf (CInt(arguments(1)) > 511) Then
arguments(1) = 511
End If
If (CInt(arguments(2)) < 384) Then
arguments(2) = 384
ElseIf (CInt(arguments(2)) > 1023) Then
arguments(2) = 1023
End If
If (CInt(arguments(3)) < -16) Then
arguments(3) = -16
ElseIf (CInt(arguments(3)) > 5) Then
arguments(3) = 5
End If

'Reading Photo name and path in the INI file
filePath = INIRead("Image", "DirPath", "C:\\Tiny_Works\\Macros\\prise de vue\\Inifiles\\prise de vue.ini") + "\"
If (filePath = "") Then filePath = "C:\"
fileName = INIRead("Image", "ImageName", "C:\\Tiny_Works\\Macros\\prise de vue\\Inifiles\\prise de vue.ini") + ".bmp"
If (fileName = "") Then fileName = "image"

photoMax = arguments(0)
frmMain.ICImagingControl1.Brightness = arguments(1)
frmMain.ICImagingControl1.Contrast = arguments(2)
frmMain.ICImagingControl1.Exposure = arguments(3)
frmMain.ICImagingControl1.Device = frmMain.ICImagingControl1.Devices.Item(1).Name
frmMain.ICImagingControl1.ContrastAuto = False
frmMain.ICImagingControl1.ExposureAuto = False
frmMain.ICImagingControl1.LiveDisplay = False
frmMain.ICImagingControl1.LiveCaptureContinuous = True
frmMain.ICImagingControl1.LiveCaptureLastImage = False
frmMain.ICImagingControl1.VideoFormat = "Y800 (1280x960)"
frmMain.ICImagingControl1.DeviceFrameRate = 60 '15
frmMain.ICImagingControl1.LiveCapturePause = False
frmMain.ICImagingControl1.MemorySnapTimeout = -1 '500
frmMain.ICImagingControl1.MemoryCurrentGrabberColo rformat = ICY8
frmMain.ICImagingControl1.ImageRingBufferSize = 1 '3
frmMain.ICImagingControl1.DeviceTrigger = True
frmMain.ICImagingControl1.LiveStart 'Enclenchement mode live

photoSauvee = False
For currentPhoto = 1 To photoMax Step 1
PhotoName = filePath + numPhoto(currentPhoto) + fileName
While photoSauvee = False
'Sleep 10
photoSauvee = False

frmMain.ICImagingControl1.DeviceTrigger = False
End Sub

Private Sub ICImagingControl1_ImageAvailable(ByVal BufferIndex As Long)
On Error GoTo Err_ImageAvailable_Handler
Dim currentBuffer As ImageBuffer
Set currentBuffer = ICImagingControl1.ImageBuffers(BufferIndex)
frmMain.ICImagingControl1.DisplayImageBuffer currentBuffer
frmMain.ICImagingControl1.MemorySaveImage (PhotoName)
photoSauvee = True
Debug.Print Err.Description
End Sub

Do you see anything wrong ?

Stefan Geissler
July 3, 2006, 17:01:06

you may call

frmMain.ICImagingControl1.DisplayImageBuffer(ICIma gingControl1.ImageBuffers(BufferIndex))

This save one copy process.

Important: Set the rinbguffer size to at least 3. This allows IC to read a new image, while the previous is saved to harddisk.

July 3, 2006, 17:54:49
This doesn't change anything ...

All the process takes about 10 seconds ... ( I was wrong when I wrote 'up to 5 secs' , it's up to 10 secs).

I tried to change some parameters but ...

I note that it takes about 9 seconds between the firing of the trigger event and the execution of the ImageAvaillable function (the camera LED is orange during this time) . What is occuring during this time ? How to reduce it ?

Thanks in advance :D

Stefan Geissler
July 3, 2006, 18:00:34
Just a question:
What is your exposure time?

July 4, 2006, 08:22:28
Most of the time, exposure is at -8 ( maximum -5)
Brightness is at 0 and contrast at 400 (if that can help)

Stefan Geissler
July 4, 2006, 10:50:54

Could you please zip your project and send the file to support@imagingcontrol.com? I will have a look on it.

July 4, 2006, 17:19:25
Here is my project.

Stefan Geissler
July 5, 2006, 11:15:56

Thank you for the project, i have tested it.

First of all some hints:
Disable all automatics before you set a value. Otherwise you might get an error if a new camera is connected.

In your application you do all in the Main thread, before the program's window (and ICImagingControl's window) is created. This is working, but i think it is not very good. This means, that the lines

Set currentBuffer = ICImagingControl1.ImageBuffers(BufferIndex)
frmMain.ICImagingControl1.DisplayImageBuffer currentBuffer
will make no sense, because nothing is visible. Only some time is lavished from some unneccesary copy functions.

The ImageAvailable event was called within less than one second on my computer. Thus i would like you to test your program with exposure=-5, that is 1/32 second.

July 5, 2006, 16:29:23
I have tested my Soft with Exposure=-5 but ...

EDIT: I completly re-wrote my soft and now, it seems to run very fine. I will let you know the result :D

(Thanks for all, it's nice to have a good support team to talk with )

EDIT2: How to know the correspondance between the exposure unit (-8.. -5 .. etc) and the "time" format (1/32, 1/2000... etc) ? Does a conversion function exist ?

Stefan Geissler
July 5, 2006, 17:58:34

Thank you for the compliment.

The -5, -6 ... is calculated as 2^n. This means 2^(-5) = 1/32 second, 2^(-6) = 1/64 second and so on.