PDA

View Full Version : getCurrentMaxAvailableFPS in DBx 21AG04



AngelSastre
November 12, 2009, 12:14:24
Hi,

I recently purchased some DBx 21AG04 cameras. Im running into some trouble on the initialization code.

Basically all I need to do is to initialize whichever camera is attached to the highest fps available in RGB24 mode. I cant use setupDeviceFromFile() because im writing a fullscreen DirectX application.

Currently, on the initialization code Im using Grabber::getCurrentMaxAvailableFPS to get the maximum frames per second available, so I can set the fps correctly.

This is proving a bit problematic because the new cameras give back 3.75 as the maximum FPS available, when in fact it should be 60 (and it does go up to 60 fps in the demo application).

Previously I was using the DBx 21AF04 and it was no problem doing it this way since the maximum FPS always came back as being 60, as expected.

This is the full initialization code Im using right now:


Grabber::tVidCapDevListPtr pVidCapDevList = m_pGrabber->getAvailableVideoCaptureDevices();
if( pVidCapDevList == 0 || pVidCapDevList->empty() )
{
delete m_pGrabber;
return -1; //no device available.
}

m_pGrabber->openDev((*pVidCapDevList)[0]);
if(!m_pGrabber->isDevValid())
{
return -1;
}

//create the frame handler sink
tFrameHandlerSinkPtr m_pSink = FrameHandlerSink::create(eRGB24, 2);

//disable snap mode
m_pSink->setSnapMode(false);

//apply the sink to the grabber.
m_pGrabber->setSinkType(m_pSink);

//set highest possible FPS value
double highestFps = m_pGrabber->getCurrentMaxAvailableFPS();
//highestFps = 60.0; //uncomment this and it will work perfectly at 60 fps!
m_pGrabber->setFPS(highestFps);
double currentFps = m_pGrabber->getFPS();

//start the grabber
m_pGrabber->startLive(false);

Please note that if I just override the highest fps to 60.0, it will work perfectly, as shown in the comments.

Ideally, Id like a piece of code which will solve this problem and always initialize to the maximum framerate at RGB24.

Thanks very much!

Stefan Geissler
November 12, 2009, 14:52:43
Hi,

I suggest to run through the available frame rates, after the video format has been set, and get the biggest one, which is used to be set at the grabber:


float maxrate = 0.0f;

for ( Grabber::tFPSList::iterator it = pFrameRateList->begin(); it != pFrameRateList->end(); ++it )
{
if( (*it) > maxrate )
{
maxrate = (*it);
}
}

m_pGrabber->setFPS(maxrate);


(I did not test the loop on my own, I just copied it from another sample ("Making Device Settings")). This attempt should do the job, regardless the sort of frame rates in the list.