PDA

View Full Version : optimization



gima67
January 27, 2011, 15:39:40
Good morning
I'm setting a system with five cameras, DMK31AG03.
From each camera i must acquire an image, and i have no need to acquire them simultaneously. The images are then saved to a file.
It is important that the acquisition takes place as quickly as possible, say 20 to 30 mSec.

With this command i active the 5 cameras:
IcImgCntrl_A.LiveStart ()
IcImgCntrl_B.LiveStart ()
...
...
...

And with that grab the image
if IcImgCntrl_A.DeviceValid then
IcImgCntrl_A.MemorySnapImage ()
IcImgCntrl_A.MemorySaveImage ("C: \ img_A.bmp)
end if
...
...
...


Everything works fine, but the program takes up about 50% of PC hardware. As for most of the time the cameras are inactive, can I not occupy the resources but take a picture quickly?

The saved image has a size of 1024x768 24bpp. In order to reduce the size of data flow from the camera, is it possible setup the camera so that i can acquire with a resolution of 1024x768 8bpp?

Unfortunately for this application I have a certain urgency, I trust in a rapid response

Sincerely

Stefan Geissler
January 27, 2011, 16:51:30
Hi,

In order to save CPU load while the camera are not needed, you should use the software. That means, enable the trigger, start the live video. Then nothing will happen, until you "push" the software trigger.
However, you can not use "MemorySnapImage" anymore, but you use the ImageAvailable event and have set "LiveCaptureContinuous" to true before calling "LiveStart".
You use the software trigger as follows:

Declare a varialbe first for each camera:


private VCDButtonProperty SoftTrigger[5];

After you have opened the cameras



SoftTrigger[0] = (VCDButtonProperty)icImagingControl1.VCDPropertyIt ems.FindInterface(VCDIDs.VCDID_TriggerMode + ":{FDB4003C-552C-4FAA-B87B-42E888D54147}:" + VCDIDs.VCDInterface_Button);
SoftTrigger[1] = (VCDButtonProperty)icImagingControl2.VCDPropertyIt ems.FindInterface(VCDIDs.VCDID_TriggerMode + ":{FDB4003C-552C-4FAA-B87B-42E888D54147}:" + VCDIDs.VCDInterface_Button);
SoftTrigger[2] = (VCDButtonProperty)icImagingControl3.VCDPropertyIt ems.FindInterface(VCDIDs.VCDID_TriggerMode + ":{FDB4003C-552C-4FAA-B87B-42E888D54147}:" + VCDIDs.VCDInterface_Button);
SoftTrigger[3] = (VCDButtonProperty)icImagingControl4.VCDPropertyIt ems.FindInterface(VCDIDs.VCDID_TriggerMode + ":{FDB4003C-552C-4FAA-B87B-42E888D54147}:" + VCDIDs.VCDInterface_Button);
SoftTrigger[4] = (VCDButtonProperty)icImagingControl5.VCDPropertyIt ems.FindInterface(VCDIDs.VCDID_TriggerMode + ":{FDB4003C-552C-4FAA-B87B-42E888D54147}:" + VCDIDs.VCDInterface_Button);



If you need the images, you call


for( int i = 0; i < 5; i++ )
{
SoftTrigger[i].push();
}


Then the matching ImageAvailable events will be called automatically and you can save the images.

In order to save the image with 8 bits per pixel, you set the property "MemoryCurrentGrabberColorFormat" to "ICY800".

gima67
February 1, 2011, 13:23:09
Thank you Mr. Geissler,
I've tried your example but i'm using VB.NET not C;

the instruction

SoftTrigger(0) = DirectCast(icImagingControl1.VCDPropertyItems.Find Interface(VCDIDs.VCDID_TriggerMode + ":{FDB4003C-552C-4FAA-B87B-42E888D54147}:" + VCDIDs.VCDInterface_Button), VCDButtonProperty)

does not create a valid object (SoftTrigger(0) remains Nothing). Which can be the reason? What does that string "FDB..." means?

Thank you very much,
Gima67

Stefan Geissler
February 1, 2011, 17:22:20
The reason my is a firmware version below 1022 of your camera or an old IC 3.0 or 3.1 version.

gima67
February 2, 2011, 09:26:09
I'm using the following cameras:

DMx31AG03 S/N: 39010586 Firmware 1022
DMx31AG03 S/N: 37010371 Firmware 1022
DMx31AG03 S/N: 37010336 Firmware 1022
DMx31AG03 S/N: 37010339 Firmware 1022
DMx31AG03 S/N: 37010332 Firmware 1022

IC 3.1.0

Microsoft Visual Studio 2005
Framework 2.0.50727

what's wrong?

Sincerely

Stefan Geissler
February 2, 2011, 10:44:28
Please create a support case at http://www.imagingcontrol.com/en_US/support/case/. I will send you a download link to latest IC 3.1. I guess, you muss the USB camera adapter.

gima67
February 4, 2011, 09:06:56
Hello,

I have open a support case (number 202623), download and installed ic3.1setup.exe

I also installed the latest version of the Device driver for The Imaging Source GigE cameras and I verified the installation of DirectX9.0c. However, the problem remains.
I sent an email with an attachment containing a short code written on Visual Basic 2005 to replicate the problem.
The email has been sent to (email address removed)

Best regards
gima67

Stefan Geissler
February 4, 2011, 11:37:45
The following function works fine:


Private Sub btn_softTrigger_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_softTrigger.Click
If IcImagingControl1.DeviceTrigger = True Then
Dim SoftTrigger As TIS.Imaging.VCDButtonProperty
SoftTrigger = IcImagingControl1.VCDPropertyItems.FindInterface(T IS.Imaging.VCDIDs.VCDID_TriggerMode + ":{FDB4003C-552C-4FAA-B87B-42E888D54147}:" + TIS.Imaging.VCDIDs.VCDInterface_Button)
If Not SoftTrigger Is Nothing Then
SoftTrigger.Push()
Else
MessageBox.Show("No software trigger available.")
End If
End If
End Sub

Please test the attached sample.

Stefan Geissler
February 4, 2011, 11:38:52
Your email did not arrive, sorry for that.

gima67
February 4, 2011, 17:18:39
Hello,

I try your software, everything works fine except the function call IcImagingControl1.DeviceTrigger, which returns an error. :-(
I send you some information about the error.

I have not used the source you sent me because my Visual Studio 2005 does not open it, I get a notice that yours is made with a previous version. So I created a new project and copied your code.

I also tried to run the executable code in the folder software_trigger/bin but it ends without any error message. :confused:

Sincerely

Stefan Geissler
February 4, 2011, 17:22:48
Hello,

Could you please check with IC Capture, whether the camera has software trigger, resp. trigger at all?

(Right mouse click on live video, "Properties" and then the last tab in the dialog.)

gima67
February 7, 2011, 10:07:48
Hello,

I can't find the trigger, I attach a picture of the window properties.

As mentioned previously, the cameras are of the kind DMx31AG03. This model has the possibility to use a software trigger? If it is not possible, there is a firmware update?

Best regards
gima67

Stefan Geissler
February 7, 2011, 10:25:03
In this case I must say, it seems, the "AG" model does not support software trigger. The "BG" model does. I am very sorry for not knowing this, I guessed all cameras have software trigger.

Now there are two ways getting around this problem:
1.) Hard way: Exchange the cameras against the "BG" model
2.) Use the "LivePause" property. http://www.imagingcontrol.com/en_US/support/documentation/dotnet/prop_descICImagingControl_LivePause.htm

I suggest to try LivePause first.

gima67
February 7, 2011, 16:37:43
Hello.
I tried the function LivePause. Now I save CPU load. This is good.

Now I have four cameras connected to a switch, and the switch connected to the PC.
During normal operation, (even with all four cameras configured as LivePause), I see the four LEDs on the switch flash quickly. So I assume that there is a continuous flow of data from cameras to PC.
If I'm right I would have: 1024 x 768 x 30 (fps) x 4 (cameras) = 94,371,840 bytes / sec. An heavy duty for the network. In order to prevent failure I have set the cameras to operate at 15 fps.

Is this solution reliable in the long run?
Is the use of cameras with built-in trigger, such as the DMK 31BG03.H (with SoftTrigger.Push function enabled) good to save bandwidth on the switch and then work at 30 fps?

I noticed that the grab's time varies from 3 to 70 mSec. Why have I a variation so high? Can i reduce the variability if I use the DMK 31BG03.H camera?

Best regards
gima67

Stefan Geissler
February 7, 2011, 16:50:51
Hello,


Is this solution reliable in the long run?
Yes. Also if 30 fps work, then this will work on the lung run too.


Is the use of cameras with built-in trigger, such as the DMK 31BG03.H (with SoftTrigger.Push function enabled) good to save bandwidth on the switch and then work at 30 fps?

No, because the cameras are communication a little bit all the time. But this is standard network stuff.


I noticed that the grab's time varies from 3 to 70 mSec. Why have I a variation so high? Can i reduce the variability if I use the DMK 31BG03.H camera?

No, because we do not know, when the image will come. The 70 msec nearly the full frame rate, that means, the camera just started a new image, while 3ms seems a little bit fast. If the camera is in LivePause, it runs and exposes all the time, but simply does not deliver images. Thus it depends on when live pause is reset in the camera's cycle how fast the image is provided. The software trigger will work more reliable.

gima67
February 7, 2011, 18:08:41
hello,

Quote:
Is this solution reliable in the long run?
Yes. Also if 30 fps work, then this will work on the lung run too.


Does not work.
I tried with IcCapture. Up to three cameras, everything work fine, but when I add the fourth, I see a black image with an error.
I enclose a sample image.

Best regards
gima67

gima67
February 7, 2011, 18:23:16
PS:

Of course, everything works fine at 15 fps

Stefan Geissler
February 10, 2011, 17:10:35
Then you have a bandwidth problem. This can be solved only be reducing framerate as you already did.