mrafique
June 29, 2004, 22:20:16
Hi, I'm using IC Imaging Control 1.4 1 for capturing images from a pair of Sony DFW-X700 cameras.
I would like to synchronize the images captured from the cameras, therefore I am using an external trigger (through the parallel port).
My problem is that when I trigger the cameras, I call snapImages(1,1000) to capture the triggered image from the left and right cameras. The snapImages works for the left camera, but when I call it for the right camera it fails.
If I reverse the calling order (i.e. call snapImages for the right camera first), snapImages fails on the left camera.
Why is this happening ??
Does the image that was captured using the trigger, disappear if I wait too long?
This is the code I am using
if( !DShowLib::InitLibrary( 0 ) )
{
printf("Error - Invalid Key");
return 0;
}
DShowLib::Grabber* m_rightCamera = new DShowLib::Grabber;
DShowLib::Grabber* m_leftCamera = new DShowLib::Grabber;
// 2.0 Enumerate devices on each camera
DShowLib::Grabber::tVidCapDevListPtr
pVidCapDevList;
// 2.1 Enumerate devices on left Camera
pVidCapDevList = m_leftCamera->getAvailableVideoCaptureDevices();
// 2.1.1 Check for errors
if (pVidCapDevList==0)
{
if (m_leftCamera->getLastError())
{
cout << m_leftCamera->getLastError().c_str() << endl;
return 0;
}
else
{
cout << "Unable to get a list of devices" << endl;
return 0;
}
}
// Enough Cameras ?
if (pVidCapDevList->size() !=2)
{
cout << "Not Enough Cameras connected" << endl;
return 0;
}
m_rightCamera->openDev((*pVidCapDevList)[0]);
m_leftCamera->openDev((*pVidCapDevList)[1]);
DShowLib::Grabber::tVidFmtListPtr pVideoFormats
= m_rightCamera->getAvailableVideoFormats();
m_leftCamera->setVideoFormat( (*pVideoFormats)[2] );
m_rightCamera->setVideoFormat( (*pVideoFormats)[2] );
// 3.0 Engage the trigger
m_leftCamera->setFrameRate(133);
m_rightCamera->setFrameRate(133);
DShowLib::Grabber::tMemBufferCollectionPtr pLeftMemBufferCollection,
pRightMemBufferCollection;
pLeftMemBufferCollection = m_rightCamera->newMemBufferCollection(5);
pRightMemBufferCollection = m_leftCamera->newMemBufferCollection(5);
DShowLib::Grabber::tMemBufferPtr pLeftMemBuffer, pRightMemBuffer;
if (!m_rightCamera->setActiveMemBufferCollection(pRightMemBufferCollec tion))
{
printf("Error - Setting Left Active Buffer\n");
}
if (!m_leftCamera->setActiveMemBufferCollection(pLeftMemBufferCollect ion))
{
printf("Error - Setting Right Active Buffer\n");
}
if (!m_rightCamera->isDevOpen() || !m_leftCamera->isDevOpen())
{
printf("ERROR - DEVICES NOT OPEN");
}
if (!m_leftCamera->setExternalTrigger(true))
printf("Error - Left External Trigger\n");
if (!m_leftCamera->startLive(false))
printf("Error - Start Left Streaming\n");
if (!m_rightCamera->setExternalTrigger(true))
printf("Error - Right External Trigger\n");
if (!m_rightCamera->startLive(false))
printf("Error - Start Right Streaming\n");
Out32(888,255);
Sleep(1);
char filename[255];
double deftime1=0,deftime2=0;
// 4.0 Capture as fast as possilbe
for (int i=1; i <= 10; i++)
{
cout << "****** Trial #: " << i << endl;
cout << endl;
cout << endl;
// Capture the files
deftime1=clock();
Out32(888,0);
if (!m_rightCamera->snapImages(1,180))
cout << "Error snapImages in Right" << endl;
if (!m_leftCamera->snapImages(1,180))
cout << "Error snapImages in Left" << endl;
Out32(888,255);
deftime2=clock();
printf("Capture time: %.3f\n",(deftime2-deftime1) / CLOCKS_PER_SEC);
pLeftMemBuffer = m_leftCamera->getActiveMemBuffer();
pRightMemBuffer = m_rightCamera->getActiveMemBuffer();
// Save the files
if (pLeftMemBuffer!=NULL)
{
sprintf(&filename[0],"left%03d.bmp",i);
pLeftMemBuffer->save(filename);
}
else
cout << "Error in left buffer" << endl;
if (pRightMemBuffer!=NULL)
{
sprintf(&filename[0],"right%03d.bmp",i);
pRightMemBuffer->save(filename);
}
else
printf("Error in right buffer\n");
cout << endl;
cout << endl;
}
m_rightCamera->closeDev();
m_leftCamera->closeDev();
delete m_leftCamera;
delete m_rightCamera;
return 0;
I would like to synchronize the images captured from the cameras, therefore I am using an external trigger (through the parallel port).
My problem is that when I trigger the cameras, I call snapImages(1,1000) to capture the triggered image from the left and right cameras. The snapImages works for the left camera, but when I call it for the right camera it fails.
If I reverse the calling order (i.e. call snapImages for the right camera first), snapImages fails on the left camera.
Why is this happening ??
Does the image that was captured using the trigger, disappear if I wait too long?
This is the code I am using
if( !DShowLib::InitLibrary( 0 ) )
{
printf("Error - Invalid Key");
return 0;
}
DShowLib::Grabber* m_rightCamera = new DShowLib::Grabber;
DShowLib::Grabber* m_leftCamera = new DShowLib::Grabber;
// 2.0 Enumerate devices on each camera
DShowLib::Grabber::tVidCapDevListPtr
pVidCapDevList;
// 2.1 Enumerate devices on left Camera
pVidCapDevList = m_leftCamera->getAvailableVideoCaptureDevices();
// 2.1.1 Check for errors
if (pVidCapDevList==0)
{
if (m_leftCamera->getLastError())
{
cout << m_leftCamera->getLastError().c_str() << endl;
return 0;
}
else
{
cout << "Unable to get a list of devices" << endl;
return 0;
}
}
// Enough Cameras ?
if (pVidCapDevList->size() !=2)
{
cout << "Not Enough Cameras connected" << endl;
return 0;
}
m_rightCamera->openDev((*pVidCapDevList)[0]);
m_leftCamera->openDev((*pVidCapDevList)[1]);
DShowLib::Grabber::tVidFmtListPtr pVideoFormats
= m_rightCamera->getAvailableVideoFormats();
m_leftCamera->setVideoFormat( (*pVideoFormats)[2] );
m_rightCamera->setVideoFormat( (*pVideoFormats)[2] );
// 3.0 Engage the trigger
m_leftCamera->setFrameRate(133);
m_rightCamera->setFrameRate(133);
DShowLib::Grabber::tMemBufferCollectionPtr pLeftMemBufferCollection,
pRightMemBufferCollection;
pLeftMemBufferCollection = m_rightCamera->newMemBufferCollection(5);
pRightMemBufferCollection = m_leftCamera->newMemBufferCollection(5);
DShowLib::Grabber::tMemBufferPtr pLeftMemBuffer, pRightMemBuffer;
if (!m_rightCamera->setActiveMemBufferCollection(pRightMemBufferCollec tion))
{
printf("Error - Setting Left Active Buffer\n");
}
if (!m_leftCamera->setActiveMemBufferCollection(pLeftMemBufferCollect ion))
{
printf("Error - Setting Right Active Buffer\n");
}
if (!m_rightCamera->isDevOpen() || !m_leftCamera->isDevOpen())
{
printf("ERROR - DEVICES NOT OPEN");
}
if (!m_leftCamera->setExternalTrigger(true))
printf("Error - Left External Trigger\n");
if (!m_leftCamera->startLive(false))
printf("Error - Start Left Streaming\n");
if (!m_rightCamera->setExternalTrigger(true))
printf("Error - Right External Trigger\n");
if (!m_rightCamera->startLive(false))
printf("Error - Start Right Streaming\n");
Out32(888,255);
Sleep(1);
char filename[255];
double deftime1=0,deftime2=0;
// 4.0 Capture as fast as possilbe
for (int i=1; i <= 10; i++)
{
cout << "****** Trial #: " << i << endl;
cout << endl;
cout << endl;
// Capture the files
deftime1=clock();
Out32(888,0);
if (!m_rightCamera->snapImages(1,180))
cout << "Error snapImages in Right" << endl;
if (!m_leftCamera->snapImages(1,180))
cout << "Error snapImages in Left" << endl;
Out32(888,255);
deftime2=clock();
printf("Capture time: %.3f\n",(deftime2-deftime1) / CLOCKS_PER_SEC);
pLeftMemBuffer = m_leftCamera->getActiveMemBuffer();
pRightMemBuffer = m_rightCamera->getActiveMemBuffer();
// Save the files
if (pLeftMemBuffer!=NULL)
{
sprintf(&filename[0],"left%03d.bmp",i);
pLeftMemBuffer->save(filename);
}
else
cout << "Error in left buffer" << endl;
if (pRightMemBuffer!=NULL)
{
sprintf(&filename[0],"right%03d.bmp",i);
pRightMemBuffer->save(filename);
}
else
printf("Error in right buffer\n");
cout << endl;
cout << endl;
}
m_rightCamera->closeDev();
m_leftCamera->closeDev();
delete m_leftCamera;
delete m_rightCamera;
return 0;