PDA

View Full Version : IC_SnapImage freezes



Mikluha
September 17, 2014, 05:05:57
Here is my problem. I'm adding camera to existing application, where I need to take many (few hundred) pictures with different exposures. I'm using C-wrapper.

The program looks like this:



IC Initialization(...)

for(n=0;n<number_of_shots<n++)
{

// change camera parameters

// start live view

IC_RemoveOverlay(hCamera,0);
IC_SetFormat(hCamera,Y16);
ptr=... reference to video format
IC_SetVideoFormat(hCamera,ptr);
IC_StartLive(hCamera,0);
IC_SnapImage(hCamera,-1);
ptr=IC_GetImagePtr(hCamera);

// process image

IC_StopLive(hCamera);

// something else

} // end main loop





Camera takes number of images and hangs inside IC_SnapImage. It can be any number of images, 10 or 200. It hangs randomly.


If I start live view before main loop, i.e.

IC_StartLive(hCamera,0);
for(....)
{ SnapImage....

}
IC_StopLive...


Everything works. However, I can't really do that because this has to be added to the existing code.

Switching to 8bit images doesn't help. Same problem.

I use Mingw compiler. 32bit. Multithreaded libraries

Tried couple of USB3 and USB2 cameras. Same thing.

Any ideas?

Thanks in advance

Stefan Geissler
September 24, 2014, 15:57:26
Hello

Sorry for the delay of my answer, I was on holidays.

However,

IC_SnapImage(hCamera,-1);

Will wait for ever, if no image is delivered. Therefore your application seems to freeze. Thus, please use a better time out:


for (i = 0; i < 100; i++)
{
printf(".");
IC_RemoveOverlay(grabber, 0);
IC_SetFormat(grabber, Y16);

if (IC_SetVideoFormat(grabber, "Y16 (640x480)") == IC_SUCCESS)
{
if (IC_StartLive(grabber, 0) == IC_SUCCESS)
{
if (IC_SnapImage(grabber, 5000) != IC_SUCCESS) // 5 seconds time out
{
printf("-");
}
IC_StopLive(grabber);
}
else
{
printf("s");
}
}
else
{
printf("Fail 1\n");
break;
}
}


The "printf" calls are there for debugging purposses, so I can see, whether and where an error occurred.
It can happen, after startlive no frames are delivered. This depends on used hardware and camera model. Therefore an error handling is always necessary.