PDA

View Full Version : Strange problem with several cameras and LoadDeviceStateFromFile command



Mernion
June 10, 2014, 18:37:44
In my application I'm using two cameras (DFM 22BUC03-ML) to display two video threads in two picture boxes.

Because I'm need to automatically configure cameras I saved an settings file with this code:


ICImagingControl1.SaveDeviceStateToFile(ICImagingC ontrol1.DeviceCurrent.Name + ".dat");
// check if second camera connected
if (btnGeneral2.Enabled)
{
ICImagingControl2.SaveDeviceStateToFile(ICImagingC ontrol2.DeviceCurrent.Name + ".dat");
}
;

ICImagingControl1 always work with first camera (ICImagingControl1.Device[0]) and ICImagingControl2 always work with second camera (ICImagingControl2.Device[1]):



//somewhere in the INIT func
ICImagingControl1.Device = ICImagingControl1.Devices[0].Name;
ICImagingControl2.Device = ICImagingControl2.Devices[1].Name;


But, after I moved from my computer to other i got error in my LoadSettings func:


try
{
ICImagingControl1.LoadDeviceStateFromFile(ICImagin gControl1.DeviceCurrent.Name + ".dat", true);
ICImagingControl2.LoadDeviceStateFromFile(ICImagin gControl2.DeviceCurrent.Name + ".dat", true);
}
catch
{
//error message
}


So, the error is: "Base Library Error : Device not found, please check cable connections"
(ICImagingControl1.Device[0] and ICImagingControl.Device[1] are ok at this step)
After several broken keyboards I realised that it happens if I'm changing cameras order:
For example: at first launch USB1 was connected with CAM1 and USB2 was connected with CAM2 and I saved settings.
If at next launch I will swap USB1 and USB2 it will give me error.

It also happens if I'm working with one camera and just swapping them
(If I'm working with USB1-CAM1, and then with USB1-CAM2).

How i can fix this? And why this is happens?

Stefan Geissler
June 11, 2014, 16:01:03
Hello

You can not rely on "DeviceCurrent.Name" because this name depends on which camera boots first. This can be different sequence on another computer and even on yours. However, this is has no direct relation to you issue, only it can happen, ic1 opens cam2 while ic2 opens cam1. Therefore, it is better to use more unique file names such as "device1.dat" and "device2.dat".

I tried the same with latest IC Imaging Control 3.3, but I was not able to reproduce the issue


ic1.Device = ic1.Devices[0].Name;
ic2.Device = ic2.Devices[1].Name;
ic1.LoadDeviceStateFromFile(ic1.DeviceCurrent.Name + ".dat", true);
ic2.LoadDeviceStateFromFile(ic2.DeviceCurrent.Name + ".dat", true);


I also mixed the cameras:


ic1.Device = ic1.Devices[0].Name;
ic2.Device = ic2.Devices[1].Name;
String c1 = ic1.Devices[0].Name;

ic1.LoadDeviceStateFromFile(ic2.DeviceCurrent.Name + ".dat", true);
ic2.LoadDeviceStateFromFile(c1 + ".dat", true);

Works fine.

So I can guess: there is something either with the camera name or the serial numbers. If the serial numbers saved in the "dat" file do not match to one of both cameras, then you will receive the mentioned error message. IC Imaging Control uses the camera's serial number in "LoadDeviceState" to identify the camera unique. So you may check the serial numbers of the cameras and compare them to the ones saved in your "dat" file. A little helper function:


private void Serial(TIS.Imaging.ICImagingControl ic)
{
string sn = "";
ic.DeviceCurrent.GetSerialNumber(out sn);
Console.WriteLine( ic.DeviceCurrent.Name+ " : " + sn);
}


If the serialnumbers are the issue and you only want to configure the cameras, because the are already opened, you call


ic1.Device = ic1.Devices[0].Name;
ic2.Device = ic2.Devices[1].Name;
Serial(ic1);
Serial(ic2);
ic1.LoadDeviceStateFromFile(ic1.DeviceCurrent.Name + ".dat", false);
ic2.LoadDeviceStateFromFile(ic2.DeviceCurrent.Name + ".dat", false);


However, this does not explain, why you receive the error message with your code.

Mernion
June 11, 2014, 17:58:00
So I can guess: there is something either with the camera name or the serial numbers. If the serial numbers saved in the "dat" file do not match to one of both cameras, then you will receive the mentioned error message. IC Imaging Control uses the camera's serial number in "LoadDeviceState" to identify the camera unique. So you may check the serial numbers of the cameras and compare them to the ones saved in your "dat" file.

However, this does not explain, why you receive the error message with your code.

Thanks for help! After I've changed "true" statement in LoadDeviceStateFromFile to "false" it all works nice!