Unregistered
November 9, 2004, 23:52:19
Hi,
I have a strange problem when write my program to capture synchronized video from several Sony DFW-X700 cameras using the IC Imaging Control 1.41 library.
The driver is downloaded trial version from imagingsource. I modify the program based on the example MemBufferCollection. It setup all the video capture devices (3 sony camera) using a single video format and allocate a set of buffers to store frames. The camera is set to external trigger mode and the program set out tigger signal through parallel port to trigger the cameras.
The problem shows up when try to capture videos in 1024x768 format, the startLive() for the second device will generate problem. It seems it is calling an DShow filter CalibFilter.ax (comes from OpenCV) and generate an access vilation. And it only happen in 1024x768 and more than one camera were used. 640 * 480 with 3 camere or 1024*768 with 1 camera all works fine.
The code looks like this:
printf("Initializing cameras\n");
Grabber grabber;
Grabber::tVidCapDevListPtr pVidCapDevList = grabber.getAvailableVideoCaptureDevices();
if( pVidCapDevList == 0 || pVidCapDevList->empty() )
{
return false;
}
grabber.openDev( pVidCapDevList->at(0) );
// Get the list of all available video formats.
printf( "\n\nAvailable video formats: \n" );
Grabber::tVidFmtListPtr pVidFmtList = grabber.getAvailableVideoFormats();
if ( pVidFmtList == 0 )
{
if ( grabber.getLastError() )
{
fprintf( stderr, "Error: %s\n", grabber.getLastError().c_str() );
}
return false;
}
// Iterate the list of available video formats and print the name of each
// format.
int i = 0;
for ( Grabber::tVidFmtListPtr::value_type::iterator fmt_it =
pVidFmtList->begin();
fmt_it != pVidFmtList->end();
++fmt_it )
{
printf( "[%i] %s\n", i++, fmt_it->c_str() );
}
int input=0;
int choice;
// Prompt the user to select a video format.
printf( "Your choice: ");
input=scanf( "%i", &choice );
if ( input == 0 || choice < 0 || choice >= pVidFmtList->size() )
{
return -1;
}
// Set the selected video format.
grabber.setVideoFormat( pVidFmtList->at( choice ) );
if ( grabber.getLastError() )
{
fprintf( stderr, "Error: ", grabber.getLastError().c_str() );
return -1;
}
// do the same thing for the rest of the camera
int camNum = pVidCapDevList->size();
pGrabber *pGrabArray = new pGrabber[camNum];
//pGrabArray[0] = &grabber;
for ( i = 0; i < camNum; i++) {
pGrabArray[i] = new Grabber();
//pVidCapDevList = pGrabArray[i]->getAvailableVideoCaptureDevices();
pGrabArray[i]->openDev( pVidCapDevList->at(i) );
// not set the video norm, what is this?
//pVidFmtList = pGrabArray[i]->getAvailableVideoFormats();
pGrabArray[i]->setVideoFormat( pVidFmtList->at( choice ) );
}
#define FRAME_NUM 25
Buf3Array pBufArray = new Buf2Array[camNum];
int size_buffer = grabber.getAcqSizeMaxX() * grabber.getAcqSizeMaxY() * 3; //3 byte per pixel.
Grabber::tMemBufferCollectionPtr *pMemBufferCollection = new Grabber::tMemBufferCollectionPtr[camNum];
// set the external trigger
for (i = 0; i < camNum; i++) {
if (!pGrabArray[i]->setExternalTrigger(true)) {
printf("Error - pGrabArray[%d]'s External Trigger\n", i);
return -1;
}
pGrabArray[i]->setSinkType( FrameGrabberSink( FrameGrabberSink::eGRAB) );
pBufArray[i] = new Buf1Array[FRAME_NUM];
for (int j = 0; j < FRAME_NUM; j++) {
pBufArray[i][j] = new BYTE[size_buffer];
}
// Create a new membuffer collection that uses our own image buffers.
pMemBufferCollection[i] = pGrabArray[i]->newMemBufferCollection( size_buffer, pBufArray[i], FRAME_NUM);
// Make the collection the active one.
pGrabArray[i]->setActiveMemBufferCollection( pMemBufferCollection[i] );
if( pGrabArray[i]->getLastError() ) {
printf("%s\n", pGrabArray[i]->getLastError().c_str());
return -1;
}
}
std::cout << "Press any key to start grabbing" << std::endl;
getchar();
for (i = 0; i < camNum; i++) {
if (!pGrabArray[i]->startLive(false)) {
/************ Problem here !!!! **************
// startLive for the second camera calls the CalibFilter.ax from OpenCV, and generate an access vilation error. This is really strange, it only happens when VideoFormat set to 1024x768 (640*480 works fine for the whole program) I have tried to uninstall OpenCV (or unregister the CalibFilter.ax ), then the program complains about the "CFilter->getInputPin()" in DShowLib, says "no pin is found" Please Help!
****************************************/
printf("Error - Start grabber Streaming\n");
}
}
Thanks!
Tianli.
I have a strange problem when write my program to capture synchronized video from several Sony DFW-X700 cameras using the IC Imaging Control 1.41 library.
The driver is downloaded trial version from imagingsource. I modify the program based on the example MemBufferCollection. It setup all the video capture devices (3 sony camera) using a single video format and allocate a set of buffers to store frames. The camera is set to external trigger mode and the program set out tigger signal through parallel port to trigger the cameras.
The problem shows up when try to capture videos in 1024x768 format, the startLive() for the second device will generate problem. It seems it is calling an DShow filter CalibFilter.ax (comes from OpenCV) and generate an access vilation. And it only happen in 1024x768 and more than one camera were used. 640 * 480 with 3 camere or 1024*768 with 1 camera all works fine.
The code looks like this:
printf("Initializing cameras\n");
Grabber grabber;
Grabber::tVidCapDevListPtr pVidCapDevList = grabber.getAvailableVideoCaptureDevices();
if( pVidCapDevList == 0 || pVidCapDevList->empty() )
{
return false;
}
grabber.openDev( pVidCapDevList->at(0) );
// Get the list of all available video formats.
printf( "\n\nAvailable video formats: \n" );
Grabber::tVidFmtListPtr pVidFmtList = grabber.getAvailableVideoFormats();
if ( pVidFmtList == 0 )
{
if ( grabber.getLastError() )
{
fprintf( stderr, "Error: %s\n", grabber.getLastError().c_str() );
}
return false;
}
// Iterate the list of available video formats and print the name of each
// format.
int i = 0;
for ( Grabber::tVidFmtListPtr::value_type::iterator fmt_it =
pVidFmtList->begin();
fmt_it != pVidFmtList->end();
++fmt_it )
{
printf( "[%i] %s\n", i++, fmt_it->c_str() );
}
int input=0;
int choice;
// Prompt the user to select a video format.
printf( "Your choice: ");
input=scanf( "%i", &choice );
if ( input == 0 || choice < 0 || choice >= pVidFmtList->size() )
{
return -1;
}
// Set the selected video format.
grabber.setVideoFormat( pVidFmtList->at( choice ) );
if ( grabber.getLastError() )
{
fprintf( stderr, "Error: ", grabber.getLastError().c_str() );
return -1;
}
// do the same thing for the rest of the camera
int camNum = pVidCapDevList->size();
pGrabber *pGrabArray = new pGrabber[camNum];
//pGrabArray[0] = &grabber;
for ( i = 0; i < camNum; i++) {
pGrabArray[i] = new Grabber();
//pVidCapDevList = pGrabArray[i]->getAvailableVideoCaptureDevices();
pGrabArray[i]->openDev( pVidCapDevList->at(i) );
// not set the video norm, what is this?
//pVidFmtList = pGrabArray[i]->getAvailableVideoFormats();
pGrabArray[i]->setVideoFormat( pVidFmtList->at( choice ) );
}
#define FRAME_NUM 25
Buf3Array pBufArray = new Buf2Array[camNum];
int size_buffer = grabber.getAcqSizeMaxX() * grabber.getAcqSizeMaxY() * 3; //3 byte per pixel.
Grabber::tMemBufferCollectionPtr *pMemBufferCollection = new Grabber::tMemBufferCollectionPtr[camNum];
// set the external trigger
for (i = 0; i < camNum; i++) {
if (!pGrabArray[i]->setExternalTrigger(true)) {
printf("Error - pGrabArray[%d]'s External Trigger\n", i);
return -1;
}
pGrabArray[i]->setSinkType( FrameGrabberSink( FrameGrabberSink::eGRAB) );
pBufArray[i] = new Buf1Array[FRAME_NUM];
for (int j = 0; j < FRAME_NUM; j++) {
pBufArray[i][j] = new BYTE[size_buffer];
}
// Create a new membuffer collection that uses our own image buffers.
pMemBufferCollection[i] = pGrabArray[i]->newMemBufferCollection( size_buffer, pBufArray[i], FRAME_NUM);
// Make the collection the active one.
pGrabArray[i]->setActiveMemBufferCollection( pMemBufferCollection[i] );
if( pGrabArray[i]->getLastError() ) {
printf("%s\n", pGrabArray[i]->getLastError().c_str());
return -1;
}
}
std::cout << "Press any key to start grabbing" << std::endl;
getchar();
for (i = 0; i < camNum; i++) {
if (!pGrabArray[i]->startLive(false)) {
/************ Problem here !!!! **************
// startLive for the second camera calls the CalibFilter.ax from OpenCV, and generate an access vilation error. This is really strange, it only happens when VideoFormat set to 1024x768 (640*480 works fine for the whole program) I have tried to uninstall OpenCV (or unregister the CalibFilter.ax ), then the program complains about the "CFilter->getInputPin()" in DShowLib, says "no pin is found" Please Help!
****************************************/
printf("Error - Start grabber Streaming\n");
}
}
Thanks!
Tianli.