PDA

View Full Version : Determine the real FPS and custom formats



nikkadim
October 10, 2012, 23:30:31
Could you please advice, how I can determine the real FPS in callback capturing mode?
Should I use grabber.getFPS() or 1000/grabber[i].getFrameRate() between grabber[i].startLive(false) and grabber[i].stopLive()?


Am I right that I can use my own image format (X*Y) via [I]createVideoFormat(...), and no needs to use formats that I can see in
Grabber::tVidFmtListPtr pVidFmtList = grabber[i].getAvailableVideoFormats();


Thank you.

Stefan Geissler
October 15, 2012, 10:43:25
Could you please advice, how I can determine the real FPS in callback capturing mode?
Should I use [I]grabber.getFPS() or [I]1000/grabber.getFrameRate() between[I] grabber.startLive(false) and [I]grabber.stopLive()?

You declare some variables in your Listener class:


LARGE_INTEGER start;
LARGE_INTEGER end, freq;
int m_iCounter;
bool m_bStarted;

In the constructor you do following:


CListener::CListener()
{

m_iCounter = 0;
QueryPerformanceFrequency(&freq);

}

In the frameready you measure time and count frames:


void CListener::frameReady( Grabber& param, smart_ptr<MemBuffer> pBuffer, DWORD FrameNumber)
{
char szText[20];
pBuffer->lock();
m_iCounter++;
if( !m_bStarted)
{
m_bStarted = true;
QueryPerformanceCounter(&start);
}
QueryPerformanceCounter(&end);

__int64 dStart = start.QuadPart;
__int64 dEnd = end.QuadPart;
__int64 dFreq = freq.QuadPart;
long double dDiff = ((long double)(dEnd - dStart)) / dFreq;

if( dDiff >= 1.0) // Reset after one second.
{
sprintf(szText,"%5.1f Hz", m_iCounter/dDiff);
//m_pFrequencyLabel->SetWindowText(szText);
m_iCounter = 0;
QueryPerformanceCounter(&start);
}
pBuffer->unlock();
}

This is, what we are doing for querying the real framerate.


Am I right that I can use my own image format (X*Y) via createVideoFormat(...), and no needs to use formats that I can see in
This depends on the used camera model. You can check the camera's properties for the available video format properties:


Grabber::tVidFmtDescListPtr DecriptionList;

DecriptionList = cGrabber.getAvailableVideoFormatDescs();

for( Grabber::tVidFmtDescList::iterator pDescription = DecriptionList->begin(); pDescription != DecriptionList->end(); pDescription++ )
{
SIZE s = (*pDescription)->getStepSize();
if( s.cx > 1 && s.cy > 1 )
{
// The current video capture device allows many video formats with any sizes
// between min and max size.
printf("Description : %s\n", (*pDescription)->toString().c_str());
VideoFormatItem VideoFormat = (*pDescription)->createVideoFormat((*pDescription)->getMaxSize());
printf("Maximum Format : %s", VideoFormat.toString().c_str());
}
else
{
// The current video capture has only some static video formats.
VideoFormatItem VideoFormat = (*pDescription)->createVideoFormat((*pDescription)->getMaxSize());
printf("Video Format : %s", VideoFormat.toString().c_str());
}
printf("\n");
}

If you can set the video format with your own resolution, then you set it like:


cGrabber.setVideoFormat("RGB32 (640x188) [Binning 4x]");