drgolf
September 29, 2010, 17:29:20
I'm using the code below to grab images from the camera.
The first time I trigger the camera --> it doesn't return an image.
However, sebsequent triggers work.
Any ideas as to what might be causing this?
bool CCameraDLL::Initialize()
{
cout << "Initialing......\n";
result = DShowLib::InitLibrary("--------");
if (result == false)
{
printf("FAILED\n");
cin.get();
}
grabber.openDev(" ------");
grabber.setVideoFormat("Y800 (640x480)");
pSink = FrameHandlerSink::create( eY800, 1 );
pSink->setSnapMode( true );
grabber.setSinkType( pSink );
tIVCDPropertyItemsPtr pItems = grabber.getAvailableVCDProperties();
tIVCDRangePropertyPtr pRange;
pItems->findInterfacePtr(VCDID_Gain,VCDElement_Value,pRang e);
long pMax;
long pMin;
pRange->get_RangeMax(&pMax);
pRange->get_RangeMin(&pMin);
pRange->setValue(gain); // 4 to 31
pItems->findInterfacePtr(VCDID_Exposure,VCDElement_Value,p Range);
pRange->get_RangeMax(&pMax);
pRange->get_RangeMin(&pMin);
pRange->setValue(exposure); // -2 to -13
result = grabber.prepareLive( false ); // this allows getting info
if (result == false)
{
printf("FAILED\n");
cin.get();
}
pSink->getOutputFrameType( info );
pBuf = new BYTE[info.buffersize];
result = grabber.setExternalTrigger(true);
grabber.startLive();
Sleep(1000);
cout << "Done\n\n";
return true;
}
bool CCameraDLL::GetBuffer()
{
pSink->snapImages(1);
pBuf = (BYTE*)pSink->getLastAcqMemBuffer()->getPtr();
return true;
}
The first time I trigger the camera --> it doesn't return an image.
However, sebsequent triggers work.
Any ideas as to what might be causing this?
bool CCameraDLL::Initialize()
{
cout << "Initialing......\n";
result = DShowLib::InitLibrary("--------");
if (result == false)
{
printf("FAILED\n");
cin.get();
}
grabber.openDev(" ------");
grabber.setVideoFormat("Y800 (640x480)");
pSink = FrameHandlerSink::create( eY800, 1 );
pSink->setSnapMode( true );
grabber.setSinkType( pSink );
tIVCDPropertyItemsPtr pItems = grabber.getAvailableVCDProperties();
tIVCDRangePropertyPtr pRange;
pItems->findInterfacePtr(VCDID_Gain,VCDElement_Value,pRang e);
long pMax;
long pMin;
pRange->get_RangeMax(&pMax);
pRange->get_RangeMin(&pMin);
pRange->setValue(gain); // 4 to 31
pItems->findInterfacePtr(VCDID_Exposure,VCDElement_Value,p Range);
pRange->get_RangeMax(&pMax);
pRange->get_RangeMin(&pMin);
pRange->setValue(exposure); // -2 to -13
result = grabber.prepareLive( false ); // this allows getting info
if (result == false)
{
printf("FAILED\n");
cin.get();
}
pSink->getOutputFrameType( info );
pBuf = new BYTE[info.buffersize];
result = grabber.setExternalTrigger(true);
grabber.startLive();
Sleep(1000);
cout << "Done\n\n";
return true;
}
bool CCameraDLL::GetBuffer()
{
pSink->snapImages(1);
pBuf = (BYTE*)pSink->getLastAcqMemBuffer()->getPtr();
return true;
}